OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 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 | 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_NATIVE_AW_METRICS_SERVICE_CLIENT_IMPL_ | 5 #ifndef ANDROID_WEBVIEW_NATIVE_AW_METRICS_SERVICE_CLIENT_IMPL_ |
6 #define ANDROID_WEBVIEW_NATIVE_AW_METRICS_SERVICE_CLIENT_IMPL_ | 6 #define ANDROID_WEBVIEW_NATIVE_AW_METRICS_SERVICE_CLIENT_IMPL_ |
7 | 7 |
8 #include "android_webview/browser/aw_metrics_service_client.h" | 8 #include "android_webview/browser/aw_metrics_service_client.h" |
9 | 9 |
10 #include <jni.h> | 10 #include <jni.h> |
11 #include <string> | 11 #include <string> |
12 | 12 |
13 #include "base/lazy_instance.h" | 13 #include "base/lazy_instance.h" |
14 #include "base/macros.h" | 14 #include "base/macros.h" |
| 15 #include "components/metrics/metrics_log_uploader.h" |
15 | 16 |
16 namespace metrics { | 17 namespace metrics { |
17 class MetricsStateManager; | 18 class MetricsStateManager; |
18 } | 19 } |
19 | 20 |
20 namespace android_webview { | 21 namespace android_webview { |
21 | 22 |
22 // This singleton manages metrics for an app using any number of WebViews. It | 23 // This singleton manages metrics for an app using any number of WebViews. It |
23 // must always be used on the same thread. (Currently the UI thread is enforced, | 24 // must always be used on the same thread. (Currently the UI thread is enforced, |
24 // but it could be any thread.) This is to prevent enable/disable race | 25 // but it could be any thread.) This is to prevent enable/disable race |
(...skipping 23 matching lines...) Expand all Loading... |
48 std::string GetApplicationLocale() override; | 49 std::string GetApplicationLocale() override; |
49 bool GetBrand(std::string* brand_code) override; | 50 bool GetBrand(std::string* brand_code) override; |
50 metrics::SystemProfileProto::Channel GetChannel() override; | 51 metrics::SystemProfileProto::Channel GetChannel() override; |
51 std::string GetVersionString() override; | 52 std::string GetVersionString() override; |
52 void InitializeSystemProfileMetrics( | 53 void InitializeSystemProfileMetrics( |
53 const base::Closure& done_callback) override; | 54 const base::Closure& done_callback) override; |
54 void CollectFinalMetricsForLog(const base::Closure& done_callback) override; | 55 void CollectFinalMetricsForLog(const base::Closure& done_callback) override; |
55 std::unique_ptr<metrics::MetricsLogUploader> CreateUploader( | 56 std::unique_ptr<metrics::MetricsLogUploader> CreateUploader( |
56 const std::string& server_url, | 57 const std::string& server_url, |
57 const std::string& mime_type, | 58 const std::string& mime_type, |
| 59 metrics::MetricsLogUploader::MetricServiceType service_type, |
58 const base::Callback<void(int)>& on_upload_complete) override; | 60 const base::Callback<void(int)>& on_upload_complete) override; |
59 base::TimeDelta GetStandardUploadInterval() override; | 61 base::TimeDelta GetStandardUploadInterval() override; |
60 | 62 |
61 private: | 63 private: |
62 AwMetricsServiceClientImpl(); | 64 AwMetricsServiceClientImpl(); |
63 ~AwMetricsServiceClientImpl() override; | 65 ~AwMetricsServiceClientImpl() override; |
64 | 66 |
65 void InitializeWithGUID(std::string* guid); | 67 void InitializeWithGUID(std::string* guid); |
66 | 68 |
67 bool is_enabled_; | 69 bool is_enabled_; |
68 PrefService* pref_service_; | 70 PrefService* pref_service_; |
69 net::URLRequestContextGetter* request_context_; | 71 net::URLRequestContextGetter* request_context_; |
70 std::unique_ptr<metrics::MetricsStateManager> metrics_state_manager_; | 72 std::unique_ptr<metrics::MetricsStateManager> metrics_state_manager_; |
71 std::unique_ptr<metrics::MetricsService> metrics_service_; | 73 std::unique_ptr<metrics::MetricsService> metrics_service_; |
72 | 74 |
73 DISALLOW_COPY_AND_ASSIGN(AwMetricsServiceClientImpl); | 75 DISALLOW_COPY_AND_ASSIGN(AwMetricsServiceClientImpl); |
74 }; | 76 }; |
75 | 77 |
76 bool RegisterAwMetricsServiceClient(JNIEnv* env); | 78 bool RegisterAwMetricsServiceClient(JNIEnv* env); |
77 | 79 |
78 } // namespace android_webview | 80 } // namespace android_webview |
79 | 81 |
80 #endif // ANDROID_WEBVIEW_NATIVE_AW_METRICS_SWITCH_ | 82 #endif // ANDROID_WEBVIEW_NATIVE_AW_METRICS_SWITCH_ |
OLD | NEW |