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

Side by Side Diff: android_webview/native/aw_metrics_log_uploader.cc

Issue 2774503002: Track network stack error codes from UMA and UKM (Closed)
Patch Set: Rebase on Created 3 years, 8 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 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_log_uploader.h" 5 #include "android_webview/native/aw_metrics_log_uploader.h"
6 6
7 #include "android_webview/jni/AwMetricsLogUploader_jni.h" 7 #include "android_webview/jni/AwMetricsLogUploader_jni.h"
8 #include "base/android/jni_array.h" 8 #include "base/android/jni_array.h"
9 #include "components/metrics/log_decoder.h" 9 #include "components/metrics/log_decoder.h"
10 10
11 using base::android::ScopedJavaLocalRef; 11 using base::android::ScopedJavaLocalRef;
12 using base::android::ToJavaByteArray; 12 using base::android::ToJavaByteArray;
13 13
14 namespace android_webview { 14 namespace android_webview {
15 15
16 AwMetricsLogUploader::AwMetricsLogUploader( 16 AwMetricsLogUploader::AwMetricsLogUploader(
17 const base::Callback<void(int)>& on_upload_complete) 17 const metrics::MetricsLogUploader::UploadCallback& on_upload_complete)
18 : on_upload_complete_(on_upload_complete) {} 18 : on_upload_complete_(on_upload_complete) {}
19 19
20 AwMetricsLogUploader::~AwMetricsLogUploader() {} 20 AwMetricsLogUploader::~AwMetricsLogUploader() {}
21 21
22 void AwMetricsLogUploader::UploadLog(const std::string& compressed_log_data, 22 void AwMetricsLogUploader::UploadLog(const std::string& compressed_log_data,
23 const std::string& log_hash) { 23 const std::string& log_hash) {
24 // WebView uses the platform logging mechanism instead of the normal UMA 24 // WebView uses the platform logging mechanism instead of the normal UMA
25 // server. The platform mechanism does its own compression, so undo the 25 // server. The platform mechanism does its own compression, so undo the
26 // previous compression. 26 // previous compression.
27 std::string log_data; 27 std::string log_data;
28 if (!metrics::DecodeLogData(compressed_log_data, &log_data)) { 28 if (!metrics::DecodeLogData(compressed_log_data, &log_data)) {
29 // If the log is corrupt, pretend the server rejected it (HTTP Bad Request). 29 // If the log is corrupt, pretend the server rejected it (HTTP Bad Request).
30 on_upload_complete_.Run(400); 30 on_upload_complete_.Run(400, 0);
31 return; 31 return;
32 } 32 }
33 33
34 JNIEnv* env = base::android::AttachCurrentThread(); 34 JNIEnv* env = base::android::AttachCurrentThread();
35 ScopedJavaLocalRef<jbyteArray> java_data = ToJavaByteArray( 35 ScopedJavaLocalRef<jbyteArray> java_data = ToJavaByteArray(
36 env, reinterpret_cast<const uint8_t*>(log_data.data()), log_data.size()); 36 env, reinterpret_cast<const uint8_t*>(log_data.data()), log_data.size());
37 Java_AwMetricsLogUploader_uploadLog(env, java_data); 37 Java_AwMetricsLogUploader_uploadLog(env, java_data);
38 38
39 // The platform mechanism doesn't provide a response code or any way to handle 39 // The platform mechanism doesn't provide a response code or any way to handle
40 // failures, so we have nothing to pass to on_upload_complete. Just pass 200 40 // failures, so we have nothing to pass to on_upload_complete. Just pass 200
41 // (HTTP OK) and pretend everything is peachy. 41 // (HTTP OK) with error code 0 and pretend everything is peachy.
42 on_upload_complete_.Run(200); 42 on_upload_complete_.Run(200, 0);
43 } 43 }
44 44
45 } // namespace android_webview 45 } // namespace android_webview
OLDNEW
« no previous file with comments | « android_webview/native/aw_metrics_log_uploader.h ('k') | android_webview/native/aw_metrics_service_client_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698