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

Unified Diff: android_webview/browser/aw_metrics_service_client.h

Issue 1584483004: Fix race condition-y Finalize w/ extreme predjudice (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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/browser/aw_metrics_service_client.h
diff --git a/android_webview/browser/aw_metrics_service_client.h b/android_webview/browser/aw_metrics_service_client.h
index 613f8dc83a1a92dc24a42cdf80f138f9b0de33ce..6dd8f037edba4e9996c9a42b030d69330fe325ac 100644
--- a/android_webview/browser/aw_metrics_service_client.h
+++ b/android_webview/browser/aw_metrics_service_client.h
@@ -31,25 +31,26 @@ class URLRequestContextGetter;
namespace android_webview {
-// This singleton manages metrics for an app using any number of WebViews.
-// Metrics is turned on and off by the homonymous Java class. It should only be
-// used on the main thread. In particular, Initialize, Finalize, and
-// SetMetricsEnabled must be called from the same thread, in order to prevent
-// enable/disable race conditions, and because MetricsService is
-// single-threaded.
+// 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 {
friend struct base::DefaultLazyInstanceTraits<AwMetricsServiceClient>;
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 Finalize();
void SetMetricsEnabled(bool enabled);
- // metrics::MetricsServiceClient implementation
+ // These implement metrics::MetricsServiceClient. They must not be called
+ // until initialization has asynchronously finished.
metrics::MetricsService* GetMetricsService() override;
void SetMetricsClientId(const std::string& client_id) override;
void OnRecordingDisabled() override;
« no previous file with comments | « android_webview/browser/aw_browser_main_parts.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