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

Side by Side Diff: ios/chrome/browser/metrics/ios_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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 IOS_CHROME_BROWSER_METRICS_IOS_CHROME_METRICS_SERVICE_CLIENT_H_ 5 #ifndef IOS_CHROME_BROWSER_METRICS_IOS_CHROME_METRICS_SERVICE_CLIENT_H_
6 #define IOS_CHROME_BROWSER_METRICS_IOS_CHROME_METRICS_SERVICE_CLIENT_H_ 6 #define IOS_CHROME_BROWSER_METRICS_IOS_CHROME_METRICS_SERVICE_CLIENT_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <memory> 10 #include <memory>
11 #include <set>
11 #include <string> 12 #include <string>
12 13
13 #include "base/callback.h" 14 #include "base/callback.h"
14 #include "base/macros.h" 15 #include "base/macros.h"
15 #include "base/memory/weak_ptr.h" 16 #include "base/memory/weak_ptr.h"
16 #include "base/threading/thread_checker.h" 17 #include "base/threading/thread_checker.h"
17 #include "components/metrics/metrics_service_client.h" 18 #include "components/metrics/metrics_service_client.h"
18 #include "components/metrics/profiler/tracking_synchronizer_observer.h" 19 #include "components/metrics/profiler/tracking_synchronizer_observer.h"
19 #include "components/omnibox/browser/omnibox_event_global_tracker.h" 20 #include "components/omnibox/browser/omnibox_event_global_tracker.h"
21 #include "components/ukm/observers/history_delete_observer.h"
20 #include "ios/web/public/web_state/global_web_state_observer.h" 22 #include "ios/web/public/web_state/global_web_state_observer.h"
21 23
22 class IOSChromeStabilityMetricsProvider; 24 class IOSChromeStabilityMetricsProvider;
23 class PrefRegistrySimple; 25 class PrefRegistrySimple;
24 26
27 namespace ios {
28 class ChromeBrowserState;
29 }
30
25 namespace metrics { 31 namespace metrics {
26 class DriveMetricsProvider; 32 class DriveMetricsProvider;
27 class MetricsService; 33 class MetricsService;
28 class MetricsStateManager; 34 class MetricsStateManager;
29 class ProfilerMetricsProvider; 35 class ProfilerMetricsProvider;
30 } // namespace metrics 36 } // namespace metrics
31 37
38 namespace ukm {
39 class UkmService;
40 }
41
32 // IOSChromeMetricsServiceClient provides an implementation of 42 // IOSChromeMetricsServiceClient provides an implementation of
33 // MetricsServiceClient that depends on //ios/chrome/. 43 // MetricsServiceClient that depends on //ios/chrome/.
34 class IOSChromeMetricsServiceClient 44 class IOSChromeMetricsServiceClient
35 : public metrics::MetricsServiceClient, 45 : public metrics::MetricsServiceClient,
36 public metrics::TrackingSynchronizerObserver, 46 public metrics::TrackingSynchronizerObserver,
47 public ukm::HistoryDeleteObserver,
37 public web::GlobalWebStateObserver { 48 public web::GlobalWebStateObserver {
38 public: 49 public:
39 ~IOSChromeMetricsServiceClient() override; 50 ~IOSChromeMetricsServiceClient() override;
40 51
41 // Factory function. 52 // Factory function.
42 static std::unique_ptr<IOSChromeMetricsServiceClient> Create( 53 static std::unique_ptr<IOSChromeMetricsServiceClient> Create(
43 metrics::MetricsStateManager* state_manager); 54 metrics::MetricsStateManager* state_manager);
44 55
45 // Registers local state prefs used by this class. 56 // Registers local state prefs used by this class.
46 static void RegisterPrefs(PrefRegistrySimple* registry); 57 static void RegisterPrefs(PrefRegistrySimple* registry);
47 58
48 // metrics::MetricsServiceClient: 59 // metrics::MetricsServiceClient:
49 metrics::MetricsService* GetMetricsService() override; 60 metrics::MetricsService* GetMetricsService() override;
61 ukm::UkmService* GetUkmService() override;
50 void SetMetricsClientId(const std::string& client_id) override; 62 void SetMetricsClientId(const std::string& client_id) override;
51 int32_t GetProduct() override; 63 int32_t GetProduct() override;
52 std::string GetApplicationLocale() override; 64 std::string GetApplicationLocale() override;
53 bool GetBrand(std::string* brand_code) override; 65 bool GetBrand(std::string* brand_code) override;
54 metrics::SystemProfileProto::Channel GetChannel() override; 66 metrics::SystemProfileProto::Channel GetChannel() override;
55 std::string GetVersionString() override; 67 std::string GetVersionString() override;
56 void InitializeSystemProfileMetrics( 68 void InitializeSystemProfileMetrics(
57 const base::Closure& done_callback) override; 69 const base::Closure& done_callback) override;
58 void CollectFinalMetricsForLog(const base::Closure& done_callback) override; 70 void CollectFinalMetricsForLog(const base::Closure& done_callback) override;
59 std::unique_ptr<metrics::MetricsLogUploader> CreateUploader( 71 std::unique_ptr<metrics::MetricsLogUploader> CreateUploader(
60 const std::string& server_url, 72 const std::string& server_url,
61 const std::string& mime_type, 73 const std::string& mime_type,
62 const base::Callback<void(int)>& on_upload_complete) override; 74 const base::Callback<void(int)>& on_upload_complete) override;
63 base::TimeDelta GetStandardUploadInterval() override; 75 base::TimeDelta GetStandardUploadInterval() override;
64 base::string16 GetRegistryBackupKey() override; 76 base::string16 GetRegistryBackupKey() override;
65 void OnRendererProcessCrash() override; 77 void OnRendererProcessCrash() override;
66 78
79 // ukm::HistoryDeleteObserver
80 void OnHistoryDeleted() override;
81
67 // web::GlobalWebStateObserver: 82 // web::GlobalWebStateObserver:
68 void WebStateDidStartLoading(web::WebState* web_state) override; 83 void WebStateDidStartLoading(web::WebState* web_state) override;
69 void WebStateDidStopLoading(web::WebState* web_state) override; 84 void WebStateDidStopLoading(web::WebState* web_state) override;
70 85
71 metrics::EnableMetricsDefault GetMetricsReportingDefaultState() override; 86 metrics::EnableMetricsDefault GetMetricsReportingDefaultState() override;
72 87
73 private: 88 private:
74 explicit IOSChromeMetricsServiceClient( 89 explicit IOSChromeMetricsServiceClient(
75 metrics::MetricsStateManager* state_manager); 90 metrics::MetricsStateManager* state_manager);
76 91
(...skipping 19 matching lines...) Expand all
96 // Callbacks for various stages of final log info collection. Do not call 111 // Callbacks for various stages of final log info collection. Do not call
97 // these directly. 112 // these directly.
98 void CollectFinalHistograms(); 113 void CollectFinalHistograms();
99 114
100 // Registers |this| as an observer for notifications which indicate that a 115 // Registers |this| as an observer for notifications which indicate that a
101 // user is performing work. This is useful to allow some features to sleep, 116 // user is performing work. This is useful to allow some features to sleep,
102 // until the machine becomes active, such as precluding UMA uploads unless 117 // until the machine becomes active, such as precluding UMA uploads unless
103 // there was recent activity. 118 // there was recent activity.
104 void RegisterForNotifications(); 119 void RegisterForNotifications();
105 120
121 // Register to observe history delete events on a browser state.
122 void RegisterForHistoryDeletions(ios::ChromeBrowserState* browser_state);
123
106 // Called when a tab is parented. 124 // Called when a tab is parented.
107 void OnTabParented(web::WebState* web_state); 125 void OnTabParented(web::WebState* web_state);
108 126
109 // Called when a URL is opened from the Omnibox. 127 // Called when a URL is opened from the Omnibox.
110 void OnURLOpenedFromOmnibox(OmniboxLog* log); 128 void OnURLOpenedFromOmnibox(OmniboxLog* log);
111 129
112 base::ThreadChecker thread_checker_; 130 base::ThreadChecker thread_checker_;
113 131
114 // Weak pointer to the MetricsStateManager. 132 // Weak pointer to the MetricsStateManager.
115 metrics::MetricsStateManager* metrics_state_manager_; 133 metrics::MetricsStateManager* metrics_state_manager_;
116 134
117 // The MetricsService that |this| is a client of. 135 // The MetricsService that |this| is a client of.
118 std::unique_ptr<metrics::MetricsService> metrics_service_; 136 std::unique_ptr<metrics::MetricsService> metrics_service_;
119 137
138 // The UkmService that |this| is a client of.
139 std::unique_ptr<ukm::UkmService> ukm_service_;
140
120 // The IOSChromeStabilityMetricsProvider instance that was registered with 141 // The IOSChromeStabilityMetricsProvider instance that was registered with
121 // MetricsService. Has the same lifetime as |metrics_service_|. 142 // MetricsService. Has the same lifetime as |metrics_service_|.
122 IOSChromeStabilityMetricsProvider* stability_metrics_provider_; 143 IOSChromeStabilityMetricsProvider* stability_metrics_provider_;
123 144
124 // Saved callback received from CollectFinalMetricsForLog(). 145 // Saved callback received from CollectFinalMetricsForLog().
125 base::Closure collect_final_metrics_done_callback_; 146 base::Closure collect_final_metrics_done_callback_;
126 147
127 // The ProfilerMetricsProvider instance that was registered with 148 // The ProfilerMetricsProvider instance that was registered with
128 // MetricsService. Has the same lifetime as |metrics_service_|. 149 // MetricsService. Has the same lifetime as |metrics_service_|.
129 metrics::ProfilerMetricsProvider* profiler_metrics_provider_; 150 metrics::ProfilerMetricsProvider* profiler_metrics_provider_;
(...skipping 20 matching lines...) Expand all
150 // Whether this client has already uploaded profiler data during this session. 171 // Whether this client has already uploaded profiler data during this session.
151 // Profiler data is uploaded at most once per session. 172 // Profiler data is uploaded at most once per session.
152 bool has_uploaded_profiler_data_; 173 bool has_uploaded_profiler_data_;
153 174
154 base::WeakPtrFactory<IOSChromeMetricsServiceClient> weak_ptr_factory_; 175 base::WeakPtrFactory<IOSChromeMetricsServiceClient> weak_ptr_factory_;
155 176
156 DISALLOW_COPY_AND_ASSIGN(IOSChromeMetricsServiceClient); 177 DISALLOW_COPY_AND_ASSIGN(IOSChromeMetricsServiceClient);
157 }; 178 };
158 179
159 #endif // IOS_CHROME_BROWSER_METRICS_IOS_CHROME_METRICS_SERVICE_CLIENT_H_ 180 #endif // IOS_CHROME_BROWSER_METRICS_IOS_CHROME_METRICS_SERVICE_CLIENT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698