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

Side by Side Diff: android_webview/browser/aw_metrics_service_client.h

Issue 1958003003: Splitting the concept of UMA consent, and should UMA report. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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
« no previous file with comments | « no previous file | android_webview/browser/aw_metrics_service_client.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 ANDROID_WEBVIEW_BROWSER_AW_METRICS_SERVICE_CLIENT_IMPL_H_ 5 #ifndef ANDROID_WEBVIEW_BROWSER_AW_METRICS_SERVICE_CLIENT_IMPL_H_
6 #define ANDROID_WEBVIEW_BROWSER_AW_METRICS_SERVICE_CLIENT_IMPL_H_ 6 #define ANDROID_WEBVIEW_BROWSER_AW_METRICS_SERVICE_CLIENT_IMPL_H_
7 7
8 #include <memory> 8 #include <memory>
9 #include <string> 9 #include <string>
10 10
11 #include "android_webview/browser/aw_metrics_service_client.h" 11 #include "android_webview/browser/aw_metrics_service_client.h"
12 #include "base/lazy_instance.h" 12 #include "base/lazy_instance.h"
13 #include "base/macros.h" 13 #include "base/macros.h"
14 #include "components/metrics/enabled_state_provider.h"
14 #include "components/metrics/metrics_service_client.h" 15 #include "components/metrics/metrics_service_client.h"
15 16
16 class PrefService; 17 class PrefService;
17 18
18 namespace base { 19 namespace base {
19 class FilePath; 20 class FilePath;
20 } 21 }
21 22
22 namespace metrics { 23 namespace metrics {
23 struct ClientInfo; 24 struct ClientInfo;
24 class MetricsStateManager; 25 class MetricsStateManager;
25 } 26 }
26 27
27 namespace net { 28 namespace net {
28 class URLRequestContextGetter; 29 class URLRequestContextGetter;
29 } 30 }
30 31
31 namespace android_webview { 32 namespace android_webview {
32 33
33 // This singleton manages metrics for an app using any number of WebViews. The 34 // This singleton manages metrics for an app using any number of WebViews. The
34 // homonymous Java class is responsible for turning metrics on and off. This 35 // homonymous Java class is responsible for turning metrics on and off. This
35 // singleton must always be used on the same thread. (Currently the UI thread 36 // singleton must always be used on the same thread. (Currently the UI thread
36 // is enforced, but it could be any thread.) This is to prevent enable/disable 37 // is enforced, but it could be any thread.) This is to prevent enable/disable
37 // race conditions, and because MetricsService is single-threaded. 38 // race conditions, and because MetricsService is single-threaded.
38 // Initialization is asynchronous; even after Initialize has returned, some 39 // Initialization is asynchronous; even after Initialize has returned, some
39 // methods may not be ready to use (see below). 40 // methods may not be ready to use (see below).
40 class AwMetricsServiceClient : public metrics::MetricsServiceClient { 41 class AwMetricsServiceClient : public metrics::MetricsServiceClient,
42 public metrics::EnabledStateProvider {
41 friend struct base::DefaultLazyInstanceTraits<AwMetricsServiceClient>; 43 friend struct base::DefaultLazyInstanceTraits<AwMetricsServiceClient>;
42 44
43 public: 45 public:
44 // These may be called at any time. 46 // These may be called at any time.
45 static AwMetricsServiceClient* GetInstance(); 47 static AwMetricsServiceClient* GetInstance();
46 void Initialize(PrefService* pref_service, 48 void Initialize(PrefService* pref_service,
47 net::URLRequestContextGetter* request_context, 49 net::URLRequestContextGetter* request_context,
48 const base::FilePath guid_file_path); 50 const base::FilePath guid_file_path);
49 void SetMetricsEnabled(bool enabled); 51 void SetMetricsEnabled(bool enabled);
50 52
53 // metrics::EnabledStateProvider:
54 bool IsConsentGiven() override;
55
51 // These implement metrics::MetricsServiceClient. They must not be called 56 // These implement metrics::MetricsServiceClient. They must not be called
52 // until initialization has asynchronously finished. 57 // until initialization has asynchronously finished.
53 metrics::MetricsService* GetMetricsService() override; 58 metrics::MetricsService* GetMetricsService() override;
54 void SetMetricsClientId(const std::string& client_id) override; 59 void SetMetricsClientId(const std::string& client_id) override;
55 void OnRecordingDisabled() override; 60 void OnRecordingDisabled() override;
56 bool IsOffTheRecordSessionActive() override; 61 bool IsOffTheRecordSessionActive() override;
57 int32_t GetProduct() override; 62 int32_t GetProduct() override;
58 std::string GetApplicationLocale() override; 63 std::string GetApplicationLocale() override;
59 bool GetBrand(std::string* brand_code) override; 64 bool GetBrand(std::string* brand_code) override;
60 metrics::SystemProfileProto::Channel GetChannel() override; 65 metrics::SystemProfileProto::Channel GetChannel() override;
61 std::string GetVersionString() override; 66 std::string GetVersionString() override;
62 void OnLogUploadComplete() override; 67 void OnLogUploadComplete() override;
63 void InitializeSystemProfileMetrics( 68 void InitializeSystemProfileMetrics(
64 const base::Closure& done_callback) override; 69 const base::Closure& done_callback) override;
65 void CollectFinalMetricsForLog(const base::Closure& done_callback) override; 70 void CollectFinalMetricsForLog(const base::Closure& done_callback) override;
66 std::unique_ptr<metrics::MetricsLogUploader> CreateUploader( 71 std::unique_ptr<metrics::MetricsLogUploader> CreateUploader(
67 const base::Callback<void(int)>& on_upload_complete) override; 72 const base::Callback<void(int)>& on_upload_complete) override;
68 base::TimeDelta GetStandardUploadInterval() override; 73 base::TimeDelta GetStandardUploadInterval() override;
69 74
70 private: 75 private:
71 AwMetricsServiceClient(); 76 AwMetricsServiceClient();
72 ~AwMetricsServiceClient() override; 77 ~AwMetricsServiceClient() override;
73 78
74 void InitializeWithGUID(std::string* guid); 79 void InitializeWithGUID(std::string* guid);
75 80
76 // Callback for metrics::MetricsStateManager::Create
77 bool is_reporting_enabled();
78
79 bool is_initialized_; 81 bool is_initialized_;
80 bool is_enabled_; 82 bool is_enabled_;
81 PrefService* pref_service_; 83 PrefService* pref_service_;
82 net::URLRequestContextGetter* request_context_; 84 net::URLRequestContextGetter* request_context_;
83 std::unique_ptr<metrics::MetricsStateManager> metrics_state_manager_; 85 std::unique_ptr<metrics::MetricsStateManager> metrics_state_manager_;
84 std::unique_ptr<metrics::MetricsService> metrics_service_; 86 std::unique_ptr<metrics::MetricsService> metrics_service_;
85 87
86 DISALLOW_COPY_AND_ASSIGN(AwMetricsServiceClient); 88 DISALLOW_COPY_AND_ASSIGN(AwMetricsServiceClient);
87 }; 89 };
88 90
89 } // namespace android_webview 91 } // namespace android_webview
90 92
91 #endif // ANDROID_WEBVIEW_BROWSER_AW_METRICS_SERVICE_CLIENT_IMPL_H_ 93 #endif // ANDROID_WEBVIEW_BROWSER_AW_METRICS_SERVICE_CLIENT_IMPL_H_
OLDNEW
« no previous file with comments | « no previous file | android_webview/browser/aw_metrics_service_client.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698