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

Unified Diff: android_webview/native/aw_metrics_service_client_impl.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 side-by-side diff with in-line comments
Download patch
Index: android_webview/native/aw_metrics_service_client_impl.h
diff --git a/android_webview/browser/aw_metrics_service_client.h b/android_webview/native/aw_metrics_service_client_impl.h
similarity index 53%
copy from android_webview/browser/aw_metrics_service_client.h
copy to android_webview/native/aw_metrics_service_client_impl.h
index 3bfc512367cea25c5c00fe1eafcf940b51ece561..75242add5c18fb1bafbfebfc46c9a00bc184e8e3 100644
--- a/android_webview/browser/aw_metrics_service_client.h
+++ b/android_webview/native/aw_metrics_service_client_impl.h
@@ -1,59 +1,47 @@
-// Copyright 2015 The Chromium Authors. All rights reserved.
+// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef ANDROID_WEBVIEW_BROWSER_AW_METRICS_SERVICE_CLIENT_IMPL_H_
-#define ANDROID_WEBVIEW_BROWSER_AW_METRICS_SERVICE_CLIENT_IMPL_H_
+#ifndef ANDROID_WEBVIEW_NATIVE_AW_METRICS_SERVICE_CLIENT_IMPL_
+#define ANDROID_WEBVIEW_NATIVE_AW_METRICS_SERVICE_CLIENT_IMPL_
-#include <memory>
+#include "android_webview/browser/aw_metrics_service_client.h"
+
+#include <jni.h>
#include <string>
-#include "android_webview/browser/aw_metrics_service_client.h"
#include "base/lazy_instance.h"
#include "base/macros.h"
-#include "components/metrics/enabled_state_provider.h"
-#include "components/metrics/metrics_service_client.h"
-
-class PrefService;
-
-namespace base {
-class FilePath;
-}
namespace metrics {
class MetricsStateManager;
}
-namespace net {
-class URLRequestContextGetter;
-}
-
namespace android_webview {
-// This singleton manages metrics for an app using any number of WebViews. The
-// homonymous Java class is responsible for turning metrics on and off. This
-// singleton must always be used on the same thread. (Currently the UI thread
-// is enforced, but it could be any thread.) This is to prevent enable/disable
-// race conditions, and because MetricsService is single-threaded.
-// Initialization is asynchronous; even after Initialize has returned, some
-// methods may not be ready to use (see below).
-class AwMetricsServiceClient : public metrics::MetricsServiceClient,
- public metrics::EnabledStateProvider {
- friend struct base::DefaultLazyInstanceTraits<AwMetricsServiceClient>;
+// This singleton manages metrics for an app using any number of WebViews. It
+// must always be used on the same thread. (Currently the UI thread is enforced,
+// but it could be any thread.) This is to prevent enable/disable race
+// conditions, and because MetricsService is single-threaded. Initialization is
+// asynchronous; even after Initialize has returned, some methods may not be
+// ready to use (see below).
+class AwMetricsServiceClientImpl : public AwMetricsServiceClient {
+ friend struct base::DefaultLazyInstanceTraits<AwMetricsServiceClientImpl>;
public:
- // These may be called at any time.
- static AwMetricsServiceClient* GetInstance();
void Initialize(PrefService* pref_service,
net::URLRequestContextGetter* request_context,
- const base::FilePath guid_file_path);
- void SetMetricsEnabled(bool enabled);
+ const base::FilePath guid_file_path) override;
- // metrics::EnabledStateProvider:
+ // metrics::EnabledStateProvider implementation
bool IsConsentGiven() override;
- // These implement metrics::MetricsServiceClient. They must not be called
- // until initialization has asynchronously finished.
+ // The below functions must not be called until initialization has
+ // asynchronously finished.
+
+ void SetMetricsEnabled(bool enabled);
+
+ // metrics::MetricsServiceClient implementation
metrics::MetricsService* GetMetricsService() override;
void SetMetricsClientId(const std::string& client_id) override;
int32_t GetProduct() override;
@@ -71,21 +59,22 @@ class AwMetricsServiceClient : public metrics::MetricsServiceClient,
base::TimeDelta GetStandardUploadInterval() override;
private:
- AwMetricsServiceClient();
- ~AwMetricsServiceClient() override;
+ AwMetricsServiceClientImpl();
+ ~AwMetricsServiceClientImpl() override;
void InitializeWithGUID(std::string* guid);
- bool is_initialized_;
bool is_enabled_;
PrefService* pref_service_;
net::URLRequestContextGetter* request_context_;
std::unique_ptr<metrics::MetricsStateManager> metrics_state_manager_;
std::unique_ptr<metrics::MetricsService> metrics_service_;
- DISALLOW_COPY_AND_ASSIGN(AwMetricsServiceClient);
+ DISALLOW_COPY_AND_ASSIGN(AwMetricsServiceClientImpl);
};
+bool RegisterAwMetricsServiceClient(JNIEnv* env);
+
} // namespace android_webview
-#endif // ANDROID_WEBVIEW_BROWSER_AW_METRICS_SERVICE_CLIENT_IMPL_H_
+#endif // ANDROID_WEBVIEW_NATIVE_AW_METRICS_SWITCH_
« no previous file with comments | « android_webview/native/android_webview_jni_registrar.cc ('k') | android_webview/native/aw_metrics_service_client_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698