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

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

Issue 10830241: Inform GetEntropySource of whether or not metrics reporting will be enabled. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Added browsertest Created 8 years, 4 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
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 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 namespace webkit { 64 namespace webkit {
65 struct WebPluginInfo; 65 struct WebPluginInfo;
66 } 66 }
67 67
68 class MetricsService 68 class MetricsService
69 : public chrome_browser_metrics::TrackingSynchronizerObserver, 69 : public chrome_browser_metrics::TrackingSynchronizerObserver,
70 public content::NotificationObserver, 70 public content::NotificationObserver,
71 public net::URLFetcherDelegate, 71 public net::URLFetcherDelegate,
72 public MetricsServiceBase { 72 public MetricsServiceBase {
73 public: 73 public:
74 // Designates which entropy source was returned from this MetricsService.
75 // This is used for testing to validate that we return the correct source
76 // depending on the state of the service.
77 enum EntropySourceReturned {
78 LAST_ENTROPY_NONE,
79 LAST_ENTROPY_LOW,
80 LAST_ENTROPY_HIGH,
81 };
Ilya Sherman 2012/08/09 20:41:18 nit: Can we make this (and the corresponding gette
SteveT 2012/08/09 21:07:59 Sure can! Done.
82
74 MetricsService(); 83 MetricsService();
75 virtual ~MetricsService(); 84 virtual ~MetricsService();
76 85
77 // Start/stop the metrics recording and uploading machine. These should be 86 // Start/stop the metrics recording and uploading machine. These should be
78 // used on startup and when the user clicks the checkbox in the prefs. 87 // used on startup and when the user clicks the checkbox in the prefs.
79 // StartRecordingOnly starts the metrics recording but not reporting, for use 88 // StartRecordingOnly starts the metrics recording but not reporting, for use
80 // in tests only. 89 // in tests only.
81 void Start(); 90 void Start();
82 void StartRecordingOnly(); 91 void StartRecordingOnly();
83 void Stop(); 92 void Stop();
84 93
85 // Returns the client ID for this client, or the empty string if metrics 94 // Returns the client ID for this client, or the empty string if metrics
86 // recording is not currently running. 95 // recording is not currently running.
87 std::string GetClientId(); 96 std::string GetClientId();
88 97
89 // Returns the preferred entropy source used to seed persistent activities 98 // Returns the preferred entropy source used to seed persistent activities
90 // based on whether or not metrics reporting is permitted on this client. If 99 // based on whether or not metrics reporting will permitted on this client.
91 // it is permitted, this returns the client ID concatenated with the low 100 // The caller must determine if metrics reporting will be enabled for this
92 // entropy source. Otherwise, this just returns the low entropy source. 101 // client and pass that state in as |reporting_will_be_enabled|. If
93 std::string GetEntropySource(); 102 // |reporting_will_be_enabled| is true, this method returns the client ID
103 // concatenated with the low entropy source. Otherwise, this method just
104 // returns the low entropy source. Note that this reporting state can not be
105 // checked by reporting_active() because this method may need to be called
106 // before the MetricsService needs to be started.
107 std::string GetEntropySource(bool reporting_will_be_enabled);
108
109 // Returns the last entropy source that was returned by this service since
110 // start up, or NONE if neither was returned yet. This is exposed for testing
111 // only.
112 EntropySourceReturned entropy_source_returned() const {
113 return entropy_source_returned_;
114 }
94 115
95 // Force the client ID to be generated. This is useful in case it's needed 116 // Force the client ID to be generated. This is useful in case it's needed
96 // before recording. 117 // before recording.
97 void ForceClientIdCreation(); 118 void ForceClientIdCreation();
98 119
99 // At startup, prefs needs to be called with a list of all the pref names and 120 // At startup, prefs needs to be called with a list of all the pref names and
100 // types we'll be using. 121 // types we'll be using.
101 static void RegisterPrefs(PrefService* local_state); 122 static void RegisterPrefs(PrefService* local_state);
102 123
103 // Set up notifications which indicate that a user is performing work. This is 124 // Set up notifications which indicate that a user is performing work. This is
(...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after
455 476
456 // Indicates that an asynchronous reporting step is running. 477 // Indicates that an asynchronous reporting step is running.
457 // This is used only for debugging. 478 // This is used only for debugging.
458 bool waiting_for_asynchronous_reporting_step_; 479 bool waiting_for_asynchronous_reporting_step_;
459 480
460 #if defined(OS_CHROMEOS) 481 #if defined(OS_CHROMEOS)
461 // The external metric service is used to log ChromeOS UMA events. 482 // The external metric service is used to log ChromeOS UMA events.
462 scoped_refptr<chromeos::ExternalMetrics> external_metrics_; 483 scoped_refptr<chromeos::ExternalMetrics> external_metrics_;
463 #endif 484 #endif
464 485
486 // The last entropy source returned by this service, used for testing.
487 EntropySourceReturned entropy_source_returned_;
488
465 // Reduntant marker to check that we completed our shutdown, and set the 489 // Reduntant marker to check that we completed our shutdown, and set the
466 // exited-cleanly bit in the prefs. 490 // exited-cleanly bit in the prefs.
467 static ShutdownCleanliness clean_shutdown_status_; 491 static ShutdownCleanliness clean_shutdown_status_;
468 492
469 FRIEND_TEST_ALL_PREFIXES(MetricsServiceTest, ClientIdCorrectlyFormatted); 493 FRIEND_TEST_ALL_PREFIXES(MetricsServiceTest, ClientIdCorrectlyFormatted);
470 FRIEND_TEST_ALL_PREFIXES(MetricsServiceTest, IsPluginProcess); 494 FRIEND_TEST_ALL_PREFIXES(MetricsServiceTest, IsPluginProcess);
471 495
472 DISALLOW_COPY_AND_ASSIGN(MetricsService); 496 DISALLOW_COPY_AND_ASSIGN(MetricsService);
473 }; 497 };
474 498
475 // This class limits and documents access to the IsMetricsReportingEnabled() 499 // This class limits and documents access to the IsMetricsReportingEnabled()
476 // method. Since the method is private, each user has to be explicitly declared 500 // method. Since the method is private, each user has to be explicitly declared
477 // as a 'friend' below. 501 // as a 'friend' below.
478 class MetricsServiceHelper { 502 class MetricsServiceHelper {
479 private: 503 private:
480 friend bool prerender::IsOmniboxEnabled(Profile* profile); 504 friend bool prerender::IsOmniboxEnabled(Profile* profile);
481 friend class extensions::ExtensionDownloader; 505 friend class extensions::ExtensionDownloader;
482 506
483 // Returns true if prefs::kMetricsReportingEnabled is set. 507 // Returns true if prefs::kMetricsReportingEnabled is set.
484 static bool IsMetricsReportingEnabled(); 508 static bool IsMetricsReportingEnabled();
485 509
486 DISALLOW_IMPLICIT_CONSTRUCTORS(MetricsServiceHelper); 510 DISALLOW_IMPLICIT_CONSTRUCTORS(MetricsServiceHelper);
487 }; 511 };
488 512
489 #endif // CHROME_BROWSER_METRICS_METRICS_SERVICE_H_ 513 #endif // CHROME_BROWSER_METRICS_METRICS_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698