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 #include "android_webview/native/aw_metrics_service_client_impl.h" | 5 #include "android_webview/native/aw_metrics_service_client_impl.h" |
6 | 6 |
7 #include "android_webview/common/aw_version_info_values.h" | 7 #include "android_webview/common/aw_version_info_values.h" |
8 #include "android_webview/jni/AwMetricsServiceClient_jni.h" | 8 #include "android_webview/jni/AwMetricsServiceClient_jni.h" |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/files/file_util.h" | 10 #include "base/files/file_util.h" |
11 #include "base/guid.h" | 11 #include "base/guid.h" |
12 #include "base/i18n/rtl.h" | 12 #include "base/i18n/rtl.h" |
13 #include "base/threading/sequenced_worker_pool.h" | 13 #include "base/threading/sequenced_worker_pool.h" |
14 #include "components/metrics/call_stack_profile_metrics_provider.h" | 14 #include "components/metrics/call_stack_profile_metrics_provider.h" |
15 #include "components/metrics/enabled_state_provider.h" | 15 #include "components/metrics/enabled_state_provider.h" |
16 #include "components/metrics/gpu/gpu_metrics_provider.h" | 16 #include "components/metrics/gpu/gpu_metrics_provider.h" |
| 17 #include "components/metrics/metrics_log_uploader.h" |
17 #include "components/metrics/metrics_pref_names.h" | 18 #include "components/metrics/metrics_pref_names.h" |
18 #include "components/metrics/metrics_service.h" | 19 #include "components/metrics/metrics_service.h" |
19 #include "components/metrics/metrics_state_manager.h" | 20 #include "components/metrics/metrics_state_manager.h" |
20 #include "components/metrics/net/net_metrics_log_uploader.h" | 21 #include "components/metrics/net/net_metrics_log_uploader.h" |
21 #include "components/metrics/profiler/profiler_metrics_provider.h" | 22 #include "components/metrics/profiler/profiler_metrics_provider.h" |
22 #include "components/metrics/ui/screen_info_metrics_provider.h" | 23 #include "components/metrics/ui/screen_info_metrics_provider.h" |
23 #include "components/metrics/url_constants.h" | 24 #include "components/metrics/url_constants.h" |
24 #include "components/prefs/pref_service.h" | 25 #include "components/prefs/pref_service.h" |
25 #include "content/public/browser/browser_thread.h" | 26 #include "content/public/browser/browser_thread.h" |
26 | 27 |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
197 | 198 |
198 void AwMetricsServiceClientImpl::CollectFinalMetricsForLog( | 199 void AwMetricsServiceClientImpl::CollectFinalMetricsForLog( |
199 const base::Closure& done_callback) { | 200 const base::Closure& done_callback) { |
200 done_callback.Run(); | 201 done_callback.Run(); |
201 } | 202 } |
202 | 203 |
203 std::unique_ptr<metrics::MetricsLogUploader> | 204 std::unique_ptr<metrics::MetricsLogUploader> |
204 AwMetricsServiceClientImpl::CreateUploader( | 205 AwMetricsServiceClientImpl::CreateUploader( |
205 const std::string& server_url, | 206 const std::string& server_url, |
206 const std::string& mime_type, | 207 const std::string& mime_type, |
| 208 metrics::MetricsLogUploader::MetricServiceType service_type, |
207 const base::Callback<void(int)>& on_upload_complete) { | 209 const base::Callback<void(int)>& on_upload_complete) { |
208 return std::unique_ptr<::metrics::MetricsLogUploader>( | 210 return std::unique_ptr<::metrics::MetricsLogUploader>( |
209 new metrics::NetMetricsLogUploader( | 211 new metrics::NetMetricsLogUploader(request_context_, server_url, |
210 request_context_, server_url, mime_type, on_upload_complete)); | 212 mime_type, service_type, |
| 213 on_upload_complete)); |
211 } | 214 } |
212 | 215 |
213 base::TimeDelta AwMetricsServiceClientImpl::GetStandardUploadInterval() { | 216 base::TimeDelta AwMetricsServiceClientImpl::GetStandardUploadInterval() { |
214 return base::TimeDelta::FromMinutes(kUploadIntervalMinutes); | 217 return base::TimeDelta::FromMinutes(kUploadIntervalMinutes); |
215 } | 218 } |
216 | 219 |
217 AwMetricsServiceClientImpl::AwMetricsServiceClientImpl() | 220 AwMetricsServiceClientImpl::AwMetricsServiceClientImpl() |
218 : is_enabled_(false), | 221 : is_enabled_(false), |
219 pref_service_(nullptr), | 222 pref_service_(nullptr), |
220 request_context_(nullptr) {} | 223 request_context_(nullptr) {} |
221 | 224 |
222 AwMetricsServiceClientImpl::~AwMetricsServiceClientImpl() {} | 225 AwMetricsServiceClientImpl::~AwMetricsServiceClientImpl() {} |
223 | 226 |
224 // static | 227 // static |
225 void SetMetricsEnabled( | 228 void SetMetricsEnabled( |
226 JNIEnv* env, | 229 JNIEnv* env, |
227 const base::android::JavaParamRef<jclass>& jcaller, | 230 const base::android::JavaParamRef<jclass>& jcaller, |
228 jboolean enabled) { | 231 jboolean enabled) { |
229 g_lazy_instance_.Pointer()->SetMetricsEnabled(enabled); | 232 g_lazy_instance_.Pointer()->SetMetricsEnabled(enabled); |
230 } | 233 } |
231 | 234 |
232 bool RegisterAwMetricsServiceClient(JNIEnv* env) { | 235 bool RegisterAwMetricsServiceClient(JNIEnv* env) { |
233 return RegisterNativesImpl(env); | 236 return RegisterNativesImpl(env); |
234 } | 237 } |
235 | 238 |
236 } // namespace android_webview | 239 } // namespace android_webview |
OLD | NEW |