Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(100)

Side by Side Diff: chrome/browser/metrics/metrics_service.h

Issue 282093012: Remove dependencies of Metrics{Service,Log} on g_browser_process->local_state() (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Android compile fix Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // This file defines a service that collects information about the user 5 // This file defines a service that collects information about the user
6 // experience in order to help improve future versions of the app. 6 // experience in order to help improve future versions of the app.
7 7
8 #ifndef CHROME_BROWSER_METRICS_METRICS_SERVICE_H_ 8 #ifndef CHROME_BROWSER_METRICS_METRICS_SERVICE_H_
9 #define CHROME_BROWSER_METRICS_METRICS_SERVICE_H_ 9 #define CHROME_BROWSER_METRICS_METRICS_SERVICE_H_
10 10
(...skipping 26 matching lines...) Expand all
37 class GoogleUpdateMetricsProviderWin; 37 class GoogleUpdateMetricsProviderWin;
38 class MetricsReportingScheduler; 38 class MetricsReportingScheduler;
39 class PrefService; 39 class PrefService;
40 class PrefRegistrySimple; 40 class PrefRegistrySimple;
41 class PluginMetricsProvider; 41 class PluginMetricsProvider;
42 42
43 namespace base { 43 namespace base {
44 class DictionaryValue; 44 class DictionaryValue;
45 class HistogramSamples; 45 class HistogramSamples;
46 class MessageLoopProxy; 46 class MessageLoopProxy;
47 class PrefService;
47 } 48 }
48 49
49 namespace variations { 50 namespace variations {
50 struct ActiveGroupId; 51 struct ActiveGroupId;
51 } 52 }
52 53
53 namespace content { 54 namespace content {
54 } 55 }
55 56
56 namespace metrics { 57 namespace metrics {
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 UNINITIALIZED_PHASE = 0, 97 UNINITIALIZED_PHASE = 0,
97 START_METRICS_RECORDING = 100, 98 START_METRICS_RECORDING = 100,
98 CREATE_PROFILE = 200, 99 CREATE_PROFILE = 200,
99 STARTUP_TIMEBOMB_ARM = 300, 100 STARTUP_TIMEBOMB_ARM = 300,
100 THREAD_WATCHER_START = 400, 101 THREAD_WATCHER_START = 400,
101 MAIN_MESSAGE_LOOP_RUN = 500, 102 MAIN_MESSAGE_LOOP_RUN = 500,
102 SHUTDOWN_TIMEBOMB_ARM = 600, 103 SHUTDOWN_TIMEBOMB_ARM = 600,
103 SHUTDOWN_COMPLETE = 700, 104 SHUTDOWN_COMPLETE = 700,
104 }; 105 };
105 106
106 // Creates the MetricsService with the given |state_manager| and |client|. 107 // Creates the MetricsService with the given |state_manager|, |client|, and
107 // Does not take ownership of |state_manager| or |client|; instead stores a 108 // |local_state|. Does not take ownership of the paramaters; instead stores
108 // weak pointer to each. Caller should ensure that |state_manager| and 109 // a weak pointer to each. Caller should ensure that the parameters are valid
109 // |client| are valid for the lifetime of this class. 110 // for the lifetime of this class.
110 MetricsService(metrics::MetricsStateManager* state_manager, 111 MetricsService(metrics::MetricsStateManager* state_manager,
111 metrics::MetricsServiceClient* client); 112 metrics::MetricsServiceClient* client,
113 PrefService* local_state);
112 virtual ~MetricsService(); 114 virtual ~MetricsService();
113 115
114 // Initializes metrics recording state. Updates various bookkeeping values in 116 // Initializes metrics recording state. Updates various bookkeeping values in
115 // prefs and sets up the scheduler. This is a separate function rather than 117 // prefs and sets up the scheduler. This is a separate function rather than
116 // being done by the constructor so that field trials could be created before 118 // being done by the constructor so that field trials could be created before
117 // this is run. 119 // this is run.
118 void InitializeMetricsRecordingState(); 120 void InitializeMetricsRecordingState();
119 121
120 // Starts the metrics system, turning on recording and uploading of metrics. 122 // Starts the metrics system, turning on recording and uploading of metrics.
121 // Should be called when starting up with metrics enabled, or when metrics 123 // Should be called when starting up with metrics enabled, or when metrics
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 void RecordCompletedSessionEnd(); 183 void RecordCompletedSessionEnd();
182 184
183 #if defined(OS_ANDROID) || defined(OS_IOS) 185 #if defined(OS_ANDROID) || defined(OS_IOS)
184 // Called when the application is going into background mode. 186 // Called when the application is going into background mode.
185 void OnAppEnterBackground(); 187 void OnAppEnterBackground();
186 188
187 // Called when the application is coming out of background mode. 189 // Called when the application is coming out of background mode.
188 void OnAppEnterForeground(); 190 void OnAppEnterForeground();
189 #else 191 #else
190 // Set the dirty flag, which will require a later call to LogCleanShutdown(). 192 // Set the dirty flag, which will require a later call to LogCleanShutdown().
191 static void LogNeedForCleanShutdown(); 193 static void LogNeedForCleanShutdown(PrefService* local_state);
192 #endif // defined(OS_ANDROID) || defined(OS_IOS) 194 #endif // defined(OS_ANDROID) || defined(OS_IOS)
193 195
194 static void SetExecutionPhase(ExecutionPhase execution_phase); 196 static void SetExecutionPhase(ExecutionPhase execution_phase,
197 PrefService* local_state);
195 198
196 // Saves in the preferences if the crash report registration was successful. 199 // Saves in the preferences if the crash report registration was successful.
197 // This count is eventually send via UMA logs. 200 // This count is eventually send via UMA logs.
198 void RecordBreakpadRegistration(bool success); 201 void RecordBreakpadRegistration(bool success);
199 202
200 // Saves in the preferences if the browser is running under a debugger. 203 // Saves in the preferences if the browser is running under a debugger.
201 // This count is eventually send via UMA logs. 204 // This count is eventually send via UMA logs.
202 void RecordBreakpadHasDebugger(bool has_debugger); 205 void RecordBreakpadHasDebugger(bool has_debugger);
203 206
204 bool recording_active() const; 207 bool recording_active() const;
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
412 // low entropy source and whether metrics reporting is enabled. Weak pointer. 415 // low entropy source and whether metrics reporting is enabled. Weak pointer.
413 metrics::MetricsStateManager* const state_manager_; 416 metrics::MetricsStateManager* const state_manager_;
414 417
415 // Used to interact with the embedder. Weak pointer; must outlive |this| 418 // Used to interact with the embedder. Weak pointer; must outlive |this|
416 // instance. 419 // instance.
417 metrics::MetricsServiceClient* const client_; 420 metrics::MetricsServiceClient* const client_;
418 421
419 // Registered metrics providers. 422 // Registered metrics providers.
420 ScopedVector<metrics::MetricsProvider> metrics_providers_; 423 ScopedVector<metrics::MetricsProvider> metrics_providers_;
421 424
425 PrefService* local_state_;
426
422 base::ActionCallback action_callback_; 427 base::ActionCallback action_callback_;
423 428
424 // Indicate whether recording and reporting are currently happening. 429 // Indicate whether recording and reporting are currently happening.
425 // These should not be set directly, but by calling SetRecording and 430 // These should not be set directly, but by calling SetRecording and
426 // SetReporting. 431 // SetReporting.
427 bool recording_active_; 432 bool recording_active_;
428 bool reporting_active_; 433 bool reporting_active_;
429 434
430 // Indicate whether test mode is enabled, where the initial log should never 435 // Indicate whether test mode is enabled, where the initial log should never
431 // be cut, and logs are neither persisted nor uploaded. 436 // be cut, and logs are neither persisted nor uploaded.
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
515 FRIEND_TEST_ALL_PREFIXES(MetricsServiceTest, IsPluginProcess); 520 FRIEND_TEST_ALL_PREFIXES(MetricsServiceTest, IsPluginProcess);
516 FRIEND_TEST_ALL_PREFIXES(MetricsServiceTest, MetricsServiceObserver); 521 FRIEND_TEST_ALL_PREFIXES(MetricsServiceTest, MetricsServiceObserver);
517 FRIEND_TEST_ALL_PREFIXES(MetricsServiceTest, 522 FRIEND_TEST_ALL_PREFIXES(MetricsServiceTest,
518 PermutedEntropyCacheClearedWhenLowEntropyReset); 523 PermutedEntropyCacheClearedWhenLowEntropyReset);
519 FRIEND_TEST_ALL_PREFIXES(MetricsServiceTest, RegisterSyntheticTrial); 524 FRIEND_TEST_ALL_PREFIXES(MetricsServiceTest, RegisterSyntheticTrial);
520 525
521 DISALLOW_COPY_AND_ASSIGN(MetricsService); 526 DISALLOW_COPY_AND_ASSIGN(MetricsService);
522 }; 527 };
523 528
524 #endif // CHROME_BROWSER_METRICS_METRICS_SERVICE_H_ 529 #endif // CHROME_BROWSER_METRICS_METRICS_SERVICE_H_
OLDNEW
« no previous file with comments | « chrome/browser/metrics/metrics_log_unittest.cc ('k') | chrome/browser/metrics/metrics_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698