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

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

Issue 2886283005: [WebView] Merge AwMetricsServiceClient and move few files to new place (Closed)
Patch Set: remove recursive include Created 3 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
OLDNEW
(Empty)
1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef ANDROID_WEBVIEW_BROWSER_AW_METRICS_SERVICE_CLIENT_IMPL_H_
6 #define ANDROID_WEBVIEW_BROWSER_AW_METRICS_SERVICE_CLIENT_IMPL_H_
7
8 #include <jni.h>
9 #include <memory>
10 #include <string>
11
12 #include "android_webview/browser/aw_metrics_service_client.h"
13 #include "base/lazy_instance.h"
14 #include "base/macros.h"
15 #include "components/metrics/metrics_log_uploader.h"
16
17 namespace metrics {
18 class MetricsStateManager;
19 }
20
21 namespace android_webview {
22
23 // This singleton manages metrics for an app using any number of WebViews. It
24 // must always be used on the same thread. (Currently the UI thread is enforced,
25 // but it could be any thread.) This is to prevent enable/disable race
26 // conditions, and because MetricsService is single-threaded. Initialization is
27 // asynchronous; even after Initialize has returned, some methods may not be
28 // ready to use (see below).
29 class AwMetricsServiceClientImpl : public AwMetricsServiceClient {
30 friend struct base::LazyInstanceTraitsBase<AwMetricsServiceClientImpl>;
31
32 public:
33 void Initialize(PrefService* pref_service,
34 net::URLRequestContextGetter* request_context,
35 const base::FilePath guid_file_path) override;
36
37 // metrics::EnabledStateProvider implementation
38 bool IsConsentGiven() override;
39
40 // The below functions must not be called until initialization has
41 // asynchronously finished.
42
43 void SetMetricsEnabled(bool enabled);
44
45 // metrics::MetricsServiceClient implementation
46 metrics::MetricsService* GetMetricsService() override;
47 void SetMetricsClientId(const std::string& client_id) override;
48 int32_t GetProduct() override;
49 std::string GetApplicationLocale() override;
50 bool GetBrand(std::string* brand_code) override;
51 metrics::SystemProfileProto::Channel GetChannel() override;
52 std::string GetVersionString() override;
53 void InitializeSystemProfileMetrics(
54 const base::Closure& done_callback) override;
55 void CollectFinalMetricsForLog(const base::Closure& done_callback) override;
56 std::unique_ptr<metrics::MetricsLogUploader> CreateUploader(
57 base::StringPiece server_url,
58 base::StringPiece mime_type,
59 metrics::MetricsLogUploader::MetricServiceType service_type,
60 const metrics::MetricsLogUploader::UploadCallback& on_upload_complete)
61 override;
62 base::TimeDelta GetStandardUploadInterval() override;
63
64 private:
65 AwMetricsServiceClientImpl();
66 ~AwMetricsServiceClientImpl() override;
67
68 void InitializeWithGUID(std::string* guid);
69
70 bool is_enabled_;
71 PrefService* pref_service_;
72 net::URLRequestContextGetter* request_context_;
73 std::unique_ptr<metrics::MetricsStateManager> metrics_state_manager_;
74 std::unique_ptr<metrics::MetricsService> metrics_service_;
75
76 DISALLOW_COPY_AND_ASSIGN(AwMetricsServiceClientImpl);
77 };
78
79 bool RegisterAwMetricsServiceClient(JNIEnv* env);
80
81 } // namespace android_webview
82
83 #endif // ANDROID_WEBVIEW_BROWSER_AW_METRICS_SERVICE_CLIENT_IMPL_H_
OLDNEW
« no previous file with comments | « android_webview/browser/aw_metrics_service_client.cc ('k') | android_webview/browser/aw_metrics_service_client_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698