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

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

Issue 2567263003: Basic UkmService implementation (Closed)
Patch Set: Rebase Created 3 years, 11 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 #ifndef CHROME_BROWSER_METRICS_CHROME_METRICS_SERVICE_CLIENT_H_ 5 #ifndef CHROME_BROWSER_METRICS_CHROME_METRICS_SERVICE_CLIENT_H_
6 #define CHROME_BROWSER_METRICS_CHROME_METRICS_SERVICE_CLIENT_H_ 6 #define CHROME_BROWSER_METRICS_CHROME_METRICS_SERVICE_CLIENT_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <deque> 10 #include <deque>
11 #include <memory> 11 #include <memory>
12 #include <queue> 12 #include <queue>
13 #include <string> 13 #include <string>
14 14
15 #include "base/callback.h" 15 #include "base/callback.h"
16 #include "base/macros.h" 16 #include "base/macros.h"
17 #include "base/memory/weak_ptr.h" 17 #include "base/memory/weak_ptr.h"
18 #include "base/threading/thread_checker.h" 18 #include "base/threading/thread_checker.h"
19 #include "build/build_config.h" 19 #include "build/build_config.h"
20 #include "chrome/browser/metrics/metrics_memory_details.h" 20 #include "chrome/browser/metrics/metrics_memory_details.h"
21 #include "components/metrics/metrics_service_client.h" 21 #include "components/metrics/metrics_service_client.h"
22 #include "components/metrics/profiler/tracking_synchronizer_observer.h" 22 #include "components/metrics/profiler/tracking_synchronizer_observer.h"
23 #include "components/metrics/proto/system_profile.pb.h" 23 #include "components/metrics/proto/system_profile.pb.h"
24 #include "components/omnibox/browser/omnibox_event_global_tracker.h" 24 #include "components/omnibox/browser/omnibox_event_global_tracker.h"
25 #include "components/ukm/observers/history_delete_observer.h"
25 #include "content/public/browser/notification_observer.h" 26 #include "content/public/browser/notification_observer.h"
26 #include "content/public/browser/notification_registrar.h" 27 #include "content/public/browser/notification_registrar.h"
27 #include "ppapi/features/features.h" 28 #include "ppapi/features/features.h"
28 29
29 class AntiVirusMetricsProvider; 30 class AntiVirusMetricsProvider;
30 class ChromeOSMetricsProvider; 31 class ChromeOSMetricsProvider;
31 class GoogleUpdateMetricsProviderWin; 32 class GoogleUpdateMetricsProviderWin;
32 class PluginMetricsProvider; 33 class PluginMetricsProvider;
34 class Profile;
33 class PrefRegistrySimple; 35 class PrefRegistrySimple;
34 36
35 namespace browser_watcher { 37 namespace browser_watcher {
36 class WatcherMetricsProviderWin; 38 class WatcherMetricsProviderWin;
37 } // namespace browser_watcher 39 } // namespace browser_watcher
38 40
39 namespace metrics { 41 namespace metrics {
40 class DriveMetricsProvider; 42 class DriveMetricsProvider;
41 class MetricsService; 43 class MetricsService;
42 class MetricsStateManager; 44 class MetricsStateManager;
43 class ProfilerMetricsProvider; 45 class ProfilerMetricsProvider;
44 } // namespace metrics 46 } // namespace metrics
45 47
46 // ChromeMetricsServiceClient provides an implementation of MetricsServiceClient 48 // ChromeMetricsServiceClient provides an implementation of MetricsServiceClient
47 // that depends on chrome/. 49 // that depends on chrome/.
48 class ChromeMetricsServiceClient 50 class ChromeMetricsServiceClient : public metrics::MetricsServiceClient,
49 : public metrics::MetricsServiceClient, 51 public metrics::TrackingSynchronizerObserver,
50 public metrics::TrackingSynchronizerObserver, 52 public content::NotificationObserver,
51 public content::NotificationObserver { 53 public ukm::HistoryDeleteObserver {
52 public: 54 public:
53 ~ChromeMetricsServiceClient() override; 55 ~ChromeMetricsServiceClient() override;
54 56
55 // Factory function. 57 // Factory function.
56 static std::unique_ptr<ChromeMetricsServiceClient> Create( 58 static std::unique_ptr<ChromeMetricsServiceClient> Create(
57 metrics::MetricsStateManager* state_manager); 59 metrics::MetricsStateManager* state_manager);
58 60
59 // Registers local state prefs used by this class. 61 // Registers local state prefs used by this class.
60 static void RegisterPrefs(PrefRegistrySimple* registry); 62 static void RegisterPrefs(PrefRegistrySimple* registry);
61 63
62 // metrics::MetricsServiceClient: 64 // metrics::MetricsServiceClient:
63 metrics::MetricsService* GetMetricsService() override; 65 metrics::MetricsService* GetMetricsService() override;
66 ukm::UkmService* GetUkmService() override;
64 void SetMetricsClientId(const std::string& client_id) override; 67 void SetMetricsClientId(const std::string& client_id) override;
65 int32_t GetProduct() override; 68 int32_t GetProduct() override;
66 std::string GetApplicationLocale() override; 69 std::string GetApplicationLocale() override;
67 bool GetBrand(std::string* brand_code) override; 70 bool GetBrand(std::string* brand_code) override;
68 metrics::SystemProfileProto::Channel GetChannel() override; 71 metrics::SystemProfileProto::Channel GetChannel() override;
69 std::string GetVersionString() override; 72 std::string GetVersionString() override;
70 void OnEnvironmentUpdate(std::string* serialized_environment) override; 73 void OnEnvironmentUpdate(std::string* serialized_environment) override;
71 void OnLogCleanShutdown() override; 74 void OnLogCleanShutdown() override;
72 void InitializeSystemProfileMetrics( 75 void InitializeSystemProfileMetrics(
73 const base::Closure& done_callback) override; 76 const base::Closure& done_callback) override;
74 void CollectFinalMetricsForLog(const base::Closure& done_callback) override; 77 void CollectFinalMetricsForLog(const base::Closure& done_callback) override;
75 std::unique_ptr<metrics::MetricsLogUploader> CreateUploader( 78 std::unique_ptr<metrics::MetricsLogUploader> CreateUploader(
76 const std::string& server_url, 79 const std::string& server_url,
77 const std::string& mime_type, 80 const std::string& mime_type,
78 const base::Callback<void(int)>& on_upload_complete) override; 81 const base::Callback<void(int)>& on_upload_complete) override;
79 base::TimeDelta GetStandardUploadInterval() override; 82 base::TimeDelta GetStandardUploadInterval() override;
80 base::string16 GetRegistryBackupKey() override; 83 base::string16 GetRegistryBackupKey() override;
81 void OnPluginLoadingError(const base::FilePath& plugin_path) override; 84 void OnPluginLoadingError(const base::FilePath& plugin_path) override;
82 bool IsReportingPolicyManaged() override; 85 bool IsReportingPolicyManaged() override;
83 metrics::EnableMetricsDefault GetMetricsReportingDefaultState() override; 86 metrics::EnableMetricsDefault GetMetricsReportingDefaultState() override;
84 bool IsUMACellularUploadLogicEnabled() override; 87 bool IsUMACellularUploadLogicEnabled() override;
85 88
89 // ukm::HistoryDeleteObserver
90 void OnHistoryDeleted() override;
91
86 // Persistent browser metrics need to be persisted somewhere. This constant 92 // Persistent browser metrics need to be persisted somewhere. This constant
87 // provides a known string to be used for both the allocator's internal name 93 // provides a known string to be used for both the allocator's internal name
88 // and for a file on disk (relative to chrome::DIR_USER_DATA) to which they 94 // and for a file on disk (relative to chrome::DIR_USER_DATA) to which they
89 // can be saved. 95 // can be saved.
90 static const char kBrowserMetricsName[]; 96 static const char kBrowserMetricsName[];
91 97
92 private: 98 private:
93 explicit ChromeMetricsServiceClient( 99 explicit ChromeMetricsServiceClient(
94 metrics::MetricsStateManager* state_manager); 100 metrics::MetricsStateManager* state_manager);
95 101
(...skipping 26 matching lines...) Expand all
122 128
123 // Records metrics about the switches present on the command line. 129 // Records metrics about the switches present on the command line.
124 void RecordCommandLineMetrics(); 130 void RecordCommandLineMetrics();
125 131
126 // Registers |this| as an observer for notifications which indicate that a 132 // Registers |this| as an observer for notifications which indicate that a
127 // user is performing work. This is useful to allow some features to sleep, 133 // user is performing work. This is useful to allow some features to sleep,
128 // until the machine becomes active, such as precluding UMA uploads unless 134 // until the machine becomes active, such as precluding UMA uploads unless
129 // there was recent activity. 135 // there was recent activity.
130 void RegisterForNotifications(); 136 void RegisterForNotifications();
131 137
138 // Call to listen for history deletions by the selected profile.
139 void RegisterForHistoryDeletions(Profile* profile);
140
132 // content::NotificationObserver: 141 // content::NotificationObserver:
133 void Observe(int type, 142 void Observe(int type,
134 const content::NotificationSource& source, 143 const content::NotificationSource& source,
135 const content::NotificationDetails& details) override; 144 const content::NotificationDetails& details) override;
136 145
137 // Called when a URL is opened from the Omnibox. 146 // Called when a URL is opened from the Omnibox.
138 void OnURLOpenedFromOmnibox(OmniboxLog* log); 147 void OnURLOpenedFromOmnibox(OmniboxLog* log);
139 148
140 #if defined(OS_WIN) 149 #if defined(OS_WIN)
141 // Counts (and removes) the browser crash dump attempt signals left behind by 150 // Counts (and removes) the browser crash dump attempt signals left behind by
142 // any previous browser processes which generated a crash dump. 151 // any previous browser processes which generated a crash dump.
143 void CountBrowserCrashDumpAttempts(); 152 void CountBrowserCrashDumpAttempts();
144 #endif // OS_WIN 153 #endif // OS_WIN
145 154
146 base::ThreadChecker thread_checker_; 155 base::ThreadChecker thread_checker_;
147 156
148 // Weak pointer to the MetricsStateManager. 157 // Weak pointer to the MetricsStateManager.
149 metrics::MetricsStateManager* metrics_state_manager_; 158 metrics::MetricsStateManager* metrics_state_manager_;
150 159
151 // The MetricsService that |this| is a client of. 160 // The MetricsService that |this| is a client of.
152 std::unique_ptr<metrics::MetricsService> metrics_service_; 161 std::unique_ptr<metrics::MetricsService> metrics_service_;
153 162
163 // The UkmService that |this| is a client of.
164 std::unique_ptr<ukm::UkmService> ukm_service_;
165
154 content::NotificationRegistrar registrar_; 166 content::NotificationRegistrar registrar_;
155 167
156 #if defined(OS_CHROMEOS) 168 #if defined(OS_CHROMEOS)
157 // On ChromeOS, holds a weak pointer to the ChromeOSMetricsProvider instance 169 // On ChromeOS, holds a weak pointer to the ChromeOSMetricsProvider instance
158 // that has been registered with MetricsService. On other platforms, is NULL. 170 // that has been registered with MetricsService. On other platforms, is NULL.
159 ChromeOSMetricsProvider* chromeos_metrics_provider_; 171 ChromeOSMetricsProvider* chromeos_metrics_provider_;
160 #endif 172 #endif
161 173
162 // A queue of tasks for initial metrics gathering. These may be asynchronous 174 // A queue of tasks for initial metrics gathering. These may be asynchronous
163 // or synchronous. 175 // or synchronous.
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 // Whether this client has already uploaded profiler data during this session. 231 // Whether this client has already uploaded profiler data during this session.
220 // Profiler data is uploaded at most once per session. 232 // Profiler data is uploaded at most once per session.
221 bool has_uploaded_profiler_data_; 233 bool has_uploaded_profiler_data_;
222 234
223 base::WeakPtrFactory<ChromeMetricsServiceClient> weak_ptr_factory_; 235 base::WeakPtrFactory<ChromeMetricsServiceClient> weak_ptr_factory_;
224 236
225 DISALLOW_COPY_AND_ASSIGN(ChromeMetricsServiceClient); 237 DISALLOW_COPY_AND_ASSIGN(ChromeMetricsServiceClient);
226 }; 238 };
227 239
228 #endif // CHROME_BROWSER_METRICS_CHROME_METRICS_SERVICE_CLIENT_H_ 240 #endif // CHROME_BROWSER_METRICS_CHROME_METRICS_SERVICE_CLIENT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698