| 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 #include "components/metrics/metrics_log_uploader.h" |
| 16 | 16 |
| 17 namespace metrics { | 17 namespace metrics { |
| 18 class MetricsStateManager; | 18 class MetricsStateManager; |
| 19 } | 19 } |
| 20 | 20 |
| 21 namespace android_webview { | 21 namespace android_webview { |
| 22 | 22 |
| 23 // 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 |
| 24 // 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, |
| 25 // 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 |
| 26 // conditions, and because MetricsService is single-threaded. Initialization is | 26 // conditions, and because MetricsService is single-threaded. Initialization is |
| 27 // asynchronous; even after Initialize has returned, some methods may not be | 27 // asynchronous; even after Initialize has returned, some methods may not be |
| 28 // ready to use (see below). | 28 // ready to use (see below). |
| 29 class AwMetricsServiceClientImpl : public AwMetricsServiceClient { | 29 class AwMetricsServiceClientImpl : public AwMetricsServiceClient { |
| 30 friend struct base::DefaultLazyInstanceTraits<AwMetricsServiceClientImpl>; | 30 friend struct base::LazyInstanceTraitsBase<AwMetricsServiceClientImpl>; |
| 31 | 31 |
| 32 public: | 32 public: |
| 33 void Initialize(PrefService* pref_service, | 33 void Initialize(PrefService* pref_service, |
| 34 net::URLRequestContextGetter* request_context, | 34 net::URLRequestContextGetter* request_context, |
| 35 const base::FilePath guid_file_path) override; | 35 const base::FilePath guid_file_path) override; |
| 36 | 36 |
| 37 // metrics::EnabledStateProvider implementation | 37 // metrics::EnabledStateProvider implementation |
| 38 bool IsConsentGiven() override; | 38 bool IsConsentGiven() override; |
| 39 | 39 |
| 40 // The below functions must not be called until initialization has | 40 // The below functions must not be called until initialization has |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 std::unique_ptr<metrics::MetricsService> metrics_service_; | 73 std::unique_ptr<metrics::MetricsService> metrics_service_; |
| 74 | 74 |
| 75 DISALLOW_COPY_AND_ASSIGN(AwMetricsServiceClientImpl); | 75 DISALLOW_COPY_AND_ASSIGN(AwMetricsServiceClientImpl); |
| 76 }; | 76 }; |
| 77 | 77 |
| 78 bool RegisterAwMetricsServiceClient(JNIEnv* env); | 78 bool RegisterAwMetricsServiceClient(JNIEnv* env); |
| 79 | 79 |
| 80 } // namespace android_webview | 80 } // namespace android_webview |
| 81 | 81 |
| 82 #endif // ANDROID_WEBVIEW_NATIVE_AW_METRICS_SERVICE_CLIENT_IMPL_ | 82 #endif // ANDROID_WEBVIEW_NATIVE_AW_METRICS_SERVICE_CLIENT_IMPL_ |
| OLD | NEW |