Skip to content

Commit

Permalink
WIP: build flag enabled, code just compiles
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexeyBarabash committed Nov 3, 2020
1 parent 8f78c8f commit fdd2c76
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 4 deletions.
13 changes: 10 additions & 3 deletions browser/brave_local_state_prefs.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
#include "brave/components/p3a/brave_p3a_service.h"
#include "brave/components/p3a/buildflags.h"
#include "brave/components/tor/buildflags/buildflags.h"
#include "chrome/browser/first_run/first_run.h"
#include "chrome/common/pref_names.h"
#include "components/metrics/metrics_pref_names.h"
#include "components/prefs/pref_registry_simple.h"
Expand All @@ -36,8 +35,9 @@
#include "brave/components/ipfs/ipfs_service.h"
#endif

#if !defined(OS_ANDROID)
#include "brave/browser/p3a/p3a_core_metrics.h"
#if !defined(OS_ANDROID)
#include "chrome/browser/first_run/first_run.h"
#endif // !defined(OS_ANDROID)

#if BUILDFLAG(ENABLE_WIDEVINE)
Expand Down Expand Up @@ -71,7 +71,14 @@ void RegisterLocalStatePrefs(PrefRegistrySimple* registry) {

#if BUILDFLAG(BRAVE_P3A_ENABLED)
brave::BraveP3AService::RegisterPrefs(registry,
first_run::IsChromeFirstRun());
#if !defined(OS_ANDROID)
first_run::IsChromeFirstRun()
#else
// BraveP3AService::RegisterPrefs
// doesn't use this arg on Android
false
#endif // !defined(OS_ANDROID)
);
#endif // BUILDFLAG(BRAVE_P3A_ENABLED)

brave_shields::RegisterShieldsP3APrefs(registry);
Expand Down
9 changes: 9 additions & 0 deletions browser/p3a/p3a_core_metrics.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@

#include "base/timer/timer.h"
#include "brave/components/weekly_storage/weekly_storage.h"
#if !defined(OS_ANDROID)
#include "chrome/browser/resource_coordinator/usage_clock.h"
#include "chrome/browser/ui/browser_list_observer.h"
#endif // !defined(OS_ANDROID)

class PrefService;
class PrefRegistrySimple;
Expand All @@ -31,14 +33,20 @@ class BraveUptimeTracker {
void RecordUsage();
void RecordP3A();

#if !defined(OS_ANDROID)
resource_coordinator::UsageClock usage_clock_;
#endif // !defined(OS_ANDROID)
base::RepeatingTimer timer_;
base::TimeDelta current_total_usage_;
WeeklyStorage state_;

DISALLOW_COPY_AND_ASSIGN(BraveUptimeTracker);
};

// BraveWindowTracker is under !OS_ANDROID guard because
// BrowserListObserver should only be only on desktop
// Brave.Uptime.BrowserOpenMinutes doesn't work on Android
#if !defined(OS_ANDROID)
// Periodically records P3A stats (extracted from Local State) regarding the
// time when incognito windows were used.
// Used as a leaking singletone.
Expand All @@ -62,6 +70,7 @@ class BraveWindowTracker : public BrowserListObserver {
PrefService* local_state_;
DISALLOW_COPY_AND_ASSIGN(BraveWindowTracker);
};
#endif // !defined(OS_ANDROID)

} // namespace brave

Expand Down
2 changes: 1 addition & 1 deletion components/p3a/buildflags.gni
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import("//build/config/features.gni")

declare_args() {
brave_p3a_enabled = !is_ios && !is_android
brave_p3a_enabled = !is_ios
}

0 comments on commit fdd2c76

Please sign in to comment.