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

Unified Diff: android_webview/native/aw_metrics_log_uploader.cc

Issue 2778203003: WebView: Create UMA uploader (Closed)
Patch Set: unimplemnet RegisterAwMetricsLogUploader Created 3 years, 9 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/native/aw_metrics_log_uploader.cc
diff --git a/android_webview/native/aw_metrics_log_uploader.cc b/android_webview/native/aw_metrics_log_uploader.cc
new file mode 100644
index 0000000000000000000000000000000000000000..fa74c7d5b70ad686eb02a8209e48aaa3cbe777d1
--- /dev/null
+++ b/android_webview/native/aw_metrics_log_uploader.cc
@@ -0,0 +1,41 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "android_webview/native/aw_metrics_log_uploader.h"
+
+#include "android_webview/jni/AwMetricsLogUploader_jni.h"
+#include "base/android/jni_array.h"
+#include "third_party/zlib/google/compression_utils.h"
+
+using base::android::ScopedJavaLocalRef;
+using base::android::ToJavaByteArray;
+
+namespace android_webview {
+
+AwMetricsLogUploader::AwMetricsLogUploader(
+ const base::Callback<void(int)>& on_upload_complete)
+ : on_upload_complete_(on_upload_complete) {}
+
+AwMetricsLogUploader::~AwMetricsLogUploader() {}
+
+void AwMetricsLogUploader::UploadLog(const std::string& compressed_log_data,
+ const std::string& log_hash) {
+ // WebView uses the platform logging mechanism instead of the normal UMA
+ // server. The platform mechanism does its own compression, so undo the
+ // previous compression.
+ std::string log_data;
+ compression::GzipUncompress(compressed_log_data, &log_data);
+
+ JNIEnv* env = base::android::AttachCurrentThread();
+ ScopedJavaLocalRef<jbyteArray> java_data = ToJavaByteArray(
+ env, reinterpret_cast<const uint8_t*>(log_data.data()), log_data.size());
+ Java_AwMetricsLogUploader_uploadLog(env, java_data);
+
+ // The platform mechanism doesn't provide a response code or any way to handle
+ // failures, so we have nothing to pass to on_upload_complete. Just pass 200
+ // (HTTP OK) and pretend everything is peachy.
+ on_upload_complete_.Run(200);
+}
+
+} // namespace android_webview
« 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