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

Side by Side Diff: blimp/engine/app/blimp_metrics_service_client.cc

Issue 2629743003: Remove all blimp engine code (Closed)
Patch Set: Use consistent comment style in //chrome 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "blimp/engine/app/blimp_metrics_service_client.h"
6
7 #include "base/bind.h"
8 #include "base/i18n/rtl.h"
9 #include "base/lazy_instance.h"
10 #include "base/memory/ptr_util.h"
11 #include "base/memory/ref_counted.h"
12 #include "blimp/engine/app/blimp_stability_metrics_provider.h"
13 #include "components/metrics/call_stack_profile_metrics_provider.h"
14 #include "components/metrics/gpu/gpu_metrics_provider.h"
15 #include "components/metrics/metrics_service.h"
16 #include "components/metrics/metrics_service_client.h"
17 #include "components/metrics/metrics_state_manager.h"
18 #include "components/metrics/net/net_metrics_log_uploader.h"
19 #include "components/metrics/profiler/profiler_metrics_provider.h"
20 #include "components/metrics/ui/screen_info_metrics_provider.h"
21 #include "components/metrics/url_constants.h"
22 #include "components/prefs/pref_service.h"
23 #include "components/version_info/version_info.h"
24 #include "content/public/browser/browser_thread.h"
25 #include "net/url_request/url_request_context_getter.h"
26
27 namespace blimp {
28 namespace engine {
29 namespace {
30
31 // How often after initial logging metrics results should be uploaded to the
32 // metrics service.
33 const int kStandardUploadIntervalMinutes = 30;
34
35 // Store/LoadClientInfo allows Windows Chrome to back up ClientInfo.
36 // Both are no-ops for Blimp.
37 // These callbacks are required by MetricsStateManager::Create.
38 void StoreClientInfo(const metrics::ClientInfo& client_info) {}
39
40 std::unique_ptr<metrics::ClientInfo> LoadClientInfo() {
41 return nullptr;
42 }
43
44 } // namespace
45
46 BlimpMetricsServiceClient::BlimpMetricsServiceClient(
47 PrefService* pref_service,
48 scoped_refptr<net::URLRequestContextGetter> request_context_getter) {
49 request_context_getter_ = request_context_getter;
50
51 metrics_state_manager_ = metrics::MetricsStateManager::Create(
52 pref_service, this, base::Bind(&StoreClientInfo),
53 base::Bind(&LoadClientInfo));
54
55 // Metrics state manager created while other class instances exist.
56 // Sign of multiple initializations.
57 DCHECK(metrics_state_manager_);
58
59 metrics_service_.reset(new metrics::MetricsService(
60 metrics_state_manager_.get(), this, pref_service));
61 metrics_service_->RegisterMetricsProvider(
62 base::WrapUnique<metrics::MetricsProvider>(
63 new BlimpStabilityMetricsProvider(pref_service)));
64 metrics_service_->RegisterMetricsProvider(
65 base::WrapUnique<metrics::MetricsProvider>(
66 new metrics::NetworkMetricsProvider(
67 content::BrowserThread::GetBlockingPool())));
68 metrics_service_->RegisterMetricsProvider(
69 base::WrapUnique<metrics::MetricsProvider>(
70 new metrics::GPUMetricsProvider));
71 metrics_service_->RegisterMetricsProvider(
72 base::WrapUnique<metrics::MetricsProvider>(
73 new metrics::ScreenInfoMetricsProvider));
74 metrics_service_->RegisterMetricsProvider(
75 base::WrapUnique<metrics::MetricsProvider>(
76 new metrics::ProfilerMetricsProvider()));
77 metrics_service_->RegisterMetricsProvider(
78 base::WrapUnique<metrics::MetricsProvider>(
79 new metrics::CallStackProfileMetricsProvider));
80 metrics_service_->InitializeMetricsRecordingState();
81 if (IsReportingEnabled())
82 metrics_service_->Start();
83 }
84
85 BlimpMetricsServiceClient::~BlimpMetricsServiceClient() {}
86
87 metrics::MetricsService* BlimpMetricsServiceClient::GetMetricsService() {
88 return metrics_service_.get();
89 }
90
91 // In Chrome, UMA and Breakpad are enabled/disabled together by the same
92 // checkbox and they share the same client ID (a.k.a. GUID).
93 // This is not required by Blimp, so this is a no-op.
94 void BlimpMetricsServiceClient::SetMetricsClientId(
95 const std::string& client_id) {}
96
97 int32_t BlimpMetricsServiceClient::GetProduct() {
98 // Indicates product family (e.g. Chrome v Android Webview), not reported
99 // platform (e.g. Chrome_Linux, Chrome_Mac).
100 return metrics::ChromeUserMetricsExtension::CHROME;
101 }
102
103 std::string BlimpMetricsServiceClient::GetApplicationLocale() {
104 return base::i18n::GetConfiguredLocale();
105 }
106
107 bool BlimpMetricsServiceClient::GetBrand(std::string* brand_code) {
108 // Blimp doesn't use brand codes.
109 return false;
110 }
111
112 metrics::SystemProfileProto::Channel BlimpMetricsServiceClient::GetChannel() {
113 // Blimp engine does not have channel info yet, however metrics data with
114 // CHANNEL_UNKNOWN is filtered in metrics visualization tools since the value
115 // typically implies a non-official build.
116 // Using CHANNEL_CANARY as a work around until channel is set here.
117 return metrics::SystemProfileProto::CHANNEL_CANARY;
118 }
119
120 std::string BlimpMetricsServiceClient::GetVersionString() {
121 return version_info::GetVersionNumber();
122 }
123
124 void BlimpMetricsServiceClient::InitializeSystemProfileMetrics(
125 const base::Closure& done_callback) {
126 // Blimp requires no additional work to InitializeSystemProfileMetrics
127 // and should proceed to the next call in the chain.
128 done_callback.Run();
129 }
130
131 void BlimpMetricsServiceClient::CollectFinalMetricsForLog(
132 const base::Closure& done_callback) {
133 // Blimp requires no additional work to CollectFinalMetricsForLog
134 // and should proceed to the next call in the chain
135 done_callback.Run();
136 }
137
138 std::unique_ptr<metrics::MetricsLogUploader>
139 BlimpMetricsServiceClient::CreateUploader(
140 const std::string& server_url,
141 const std::string& mime_type,
142 const base::Callback<void(int)>& on_upload_complete) {
143 return base::WrapUnique<metrics::MetricsLogUploader>(
144 new metrics::NetMetricsLogUploader(
145 request_context_getter_.get(), server_url,
146 mime_type, on_upload_complete));
147 }
148
149 base::TimeDelta BlimpMetricsServiceClient::GetStandardUploadInterval() {
150 return base::TimeDelta::FromMinutes(kStandardUploadIntervalMinutes);
151 }
152
153 metrics::EnableMetricsDefault
154 BlimpMetricsServiceClient::GetMetricsReportingDefaultState() {
155 return metrics::EnableMetricsDefault::OPT_IN;
156 }
157
158 bool BlimpMetricsServiceClient::IsConsentGiven() {
159 return true;
160 }
161
162 } // namespace engine
163 } // namespace blimp
OLDNEW
« no previous file with comments | « blimp/engine/app/blimp_metrics_service_client.h ('k') | blimp/engine/app/blimp_metrics_service_client_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698