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

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

Issue 2611883002: Prepare to call GMS APIs from WebView (Closed)
Patch Set: explicit destructor for style checker 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 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>
9 #include <string>
10
11 #include "android_webview/browser/aw_metrics_service_client.h"
12 #include "base/lazy_instance.h"
13 #include "base/macros.h"
14 #include "components/metrics/enabled_state_provider.h" 8 #include "components/metrics/enabled_state_provider.h"
15 #include "components/metrics/metrics_service_client.h" 9 #include "components/metrics/metrics_service_client.h"
16 10
17 class PrefService; 11 class PrefService;
18 12
19 namespace base { 13 namespace base {
20 class FilePath; 14 class FilePath;
21 } 15 }
22 16
23 namespace metrics {
24 class MetricsStateManager;
25 }
26
27 namespace net { 17 namespace net {
28 class URLRequestContextGetter; 18 class URLRequestContextGetter;
29 } 19 }
30 20
31 namespace android_webview { 21 namespace android_webview {
32 22
33 // 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 // 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 // race conditions, and because MetricsService is single-threaded.
38 // Initialization is asynchronous; even after Initialize has returned, some
39 // methods may not be ready to use (see below).
40 class AwMetricsServiceClient : public metrics::MetricsServiceClient, 23 class AwMetricsServiceClient : public metrics::MetricsServiceClient,
41 public metrics::EnabledStateProvider { 24 public metrics::EnabledStateProvider {
42 friend struct base::DefaultLazyInstanceTraits<AwMetricsServiceClient>; 25 public:
26 static AwMetricsServiceClient* GetInstance();
27 virtual void Initialize(PrefService* pref_service,
28 net::URLRequestContextGetter* request_context,
29 const base::FilePath guid_file_path) = 0;
43 30
44 public: 31 protected:
45 // These may be called at any time.
46 static AwMetricsServiceClient* GetInstance();
47 void Initialize(PrefService* pref_service,
48 net::URLRequestContextGetter* request_context,
49 const base::FilePath guid_file_path);
50 void SetMetricsEnabled(bool enabled);
51
52 // metrics::EnabledStateProvider:
53 bool IsConsentGiven() override;
54
55 // These implement metrics::MetricsServiceClient. They must not be called
56 // until initialization has asynchronously finished.
57 metrics::MetricsService* GetMetricsService() override;
58 void SetMetricsClientId(const std::string& client_id) override;
59 int32_t GetProduct() override;
60 std::string GetApplicationLocale() override;
61 bool GetBrand(std::string* brand_code) override;
62 metrics::SystemProfileProto::Channel GetChannel() override;
63 std::string GetVersionString() override;
64 void InitializeSystemProfileMetrics(
65 const base::Closure& done_callback) override;
66 void CollectFinalMetricsForLog(const base::Closure& done_callback) override;
67 std::unique_ptr<metrics::MetricsLogUploader> CreateUploader(
68 const std::string& server_url,
69 const std::string& mime_type,
70 const base::Callback<void(int)>& on_upload_complete) override;
71 base::TimeDelta GetStandardUploadInterval() override;
72
73 private:
74 AwMetricsServiceClient(); 32 AwMetricsServiceClient();
75 ~AwMetricsServiceClient() override; 33 ~AwMetricsServiceClient() override;
76 34
77 void InitializeWithGUID(std::string* guid); 35 private:
78
79 bool is_initialized_;
80 bool is_enabled_;
81 PrefService* pref_service_;
82 net::URLRequestContextGetter* request_context_;
83 std::unique_ptr<metrics::MetricsStateManager> metrics_state_manager_;
84 std::unique_ptr<metrics::MetricsService> metrics_service_;
85
86 DISALLOW_COPY_AND_ASSIGN(AwMetricsServiceClient); 36 DISALLOW_COPY_AND_ASSIGN(AwMetricsServiceClient);
87 }; 37 };
88 38
89 } // namespace android_webview 39 } // namespace android_webview
90 40
91 #endif // ANDROID_WEBVIEW_BROWSER_AW_METRICS_SERVICE_CLIENT_IMPL_H_ 41 #endif // ANDROID_WEBVIEW_BROWSER_AW_METRICS_SERVICE_CLIENT_IMPL_H_
OLDNEW
« no previous file with comments | « android_webview/browser/aw_browser_context.cc ('k') | android_webview/browser/aw_metrics_service_client.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698