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

Side by Side 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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_BROWSER_AW_METRICS_SERVICE_CLIENT_IMPL_H_ 5 #ifndef ANDROID_WEBVIEW_BROWSER_AW_METRICS_SERVICE_CLIENT_IMPL_H_
6 #define ANDROID_WEBVIEW_BROWSER_AW_METRICS_SERVICE_CLIENT_IMPL_H_ 6 #define ANDROID_WEBVIEW_BROWSER_AW_METRICS_SERVICE_CLIENT_IMPL_H_
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 <string> 10 #include <string>
(...skipping 13 matching lines...) Expand all
24 struct ClientInfo; 24 struct ClientInfo;
25 class MetricsStateManager; 25 class MetricsStateManager;
26 } 26 }
27 27
28 namespace net { 28 namespace net {
29 class URLRequestContextGetter; 29 class URLRequestContextGetter;
30 } 30 }
31 31
32 namespace android_webview { 32 namespace android_webview {
33 33
34 // This singleton manages metrics for an app using any number of WebViews. 34 // This singleton manages metrics for an app using any number of WebViews. The
35 // Metrics is turned on and off by the homonymous Java class. It should only be 35 // homonymous Java class is responsible for turning metrics on and off. This
36 // used on the main thread. In particular, Initialize, Finalize, and 36 // singleton must always be used on the same thread. (Currently the UI thread
37 // SetMetricsEnabled must be called from the same thread, in order to prevent 37 // is enforced, but it could be any thread.) This is to prevent enable/disable
38 // enable/disable race conditions, and because MetricsService is 38 // race conditions, and because MetricsService is single-threaded.
39 // single-threaded. 39 // Initialization is asynchronous; even after Initialize has returned, some
40 // methods may not be ready to use (see below).
40 class AwMetricsServiceClient : public metrics::MetricsServiceClient { 41 class AwMetricsServiceClient : public metrics::MetricsServiceClient {
41 friend struct base::DefaultLazyInstanceTraits<AwMetricsServiceClient>; 42 friend struct base::DefaultLazyInstanceTraits<AwMetricsServiceClient>;
42 43
43 public: 44 public:
45 // These may be called at any time.
44 static AwMetricsServiceClient* GetInstance(); 46 static AwMetricsServiceClient* GetInstance();
45
46 void Initialize(PrefService* pref_service, 47 void Initialize(PrefService* pref_service,
47 net::URLRequestContextGetter* request_context, 48 net::URLRequestContextGetter* request_context,
48 const base::FilePath guid_file_path); 49 const base::FilePath guid_file_path);
49 void Finalize();
50 void SetMetricsEnabled(bool enabled); 50 void SetMetricsEnabled(bool enabled);
51 51
52 // metrics::MetricsServiceClient implementation 52 // These implement metrics::MetricsServiceClient. They must not be called
53 // until initialization has asynchronously finished.
53 metrics::MetricsService* GetMetricsService() override; 54 metrics::MetricsService* GetMetricsService() override;
54 void SetMetricsClientId(const std::string& client_id) override; 55 void SetMetricsClientId(const std::string& client_id) override;
55 void OnRecordingDisabled() override; 56 void OnRecordingDisabled() override;
56 bool IsOffTheRecordSessionActive() override; 57 bool IsOffTheRecordSessionActive() override;
57 int32_t GetProduct() override; 58 int32_t GetProduct() override;
58 std::string GetApplicationLocale() override; 59 std::string GetApplicationLocale() override;
59 bool GetBrand(std::string* brand_code) override; 60 bool GetBrand(std::string* brand_code) override;
60 metrics::SystemProfileProto::Channel GetChannel() override; 61 metrics::SystemProfileProto::Channel GetChannel() override;
61 std::string GetVersionString() override; 62 std::string GetVersionString() override;
62 void OnLogUploadComplete() override; 63 void OnLogUploadComplete() override;
(...skipping 19 matching lines...) Expand all
82 net::URLRequestContextGetter* request_context_; 83 net::URLRequestContextGetter* request_context_;
83 scoped_ptr<metrics::MetricsStateManager> metrics_state_manager_; 84 scoped_ptr<metrics::MetricsStateManager> metrics_state_manager_;
84 scoped_ptr<metrics::MetricsService> metrics_service_; 85 scoped_ptr<metrics::MetricsService> metrics_service_;
85 86
86 DISALLOW_COPY_AND_ASSIGN(AwMetricsServiceClient); 87 DISALLOW_COPY_AND_ASSIGN(AwMetricsServiceClient);
87 }; 88 };
88 89
89 } // namespace android_webview 90 } // namespace android_webview
90 91
91 #endif // ANDROID_WEBVIEW_BROWSER_AW_METRICS_SERVICE_CLIENT_IMPL_H_ 92 #endif // ANDROID_WEBVIEW_BROWSER_AW_METRICS_SERVICE_CLIENT_IMPL_H_
OLDNEW
« 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