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

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

Issue 2778203003: WebView: Create UMA uploader (Closed)
Patch Set: unimplemnet RegisterAwMetricsLogUploader 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "android_webview/native/aw_metrics_log_uploader.h"
6
7 #include "android_webview/jni/AwMetricsLogUploader_jni.h"
8 #include "base/android/jni_array.h"
9 #include "third_party/zlib/google/compression_utils.h"
10
11 using base::android::ScopedJavaLocalRef;
12 using base::android::ToJavaByteArray;
13
14 namespace android_webview {
15
16 AwMetricsLogUploader::AwMetricsLogUploader(
17 const base::Callback<void(int)>& on_upload_complete)
18 : on_upload_complete_(on_upload_complete) {}
19
20 AwMetricsLogUploader::~AwMetricsLogUploader() {}
21
22 void AwMetricsLogUploader::UploadLog(const std::string& compressed_log_data,
23 const std::string& log_hash) {
24 // WebView uses the platform logging mechanism instead of the normal UMA
25 // server. The platform mechanism does its own compression, so undo the
26 // previous compression.
27 std::string log_data;
28 compression::GzipUncompress(compressed_log_data, &log_data);
29
30 JNIEnv* env = base::android::AttachCurrentThread();
31 ScopedJavaLocalRef<jbyteArray> java_data = ToJavaByteArray(
32 env, reinterpret_cast<const uint8_t*>(log_data.data()), log_data.size());
33 Java_AwMetricsLogUploader_uploadLog(env, java_data);
34
35 // The platform mechanism doesn't provide a response code or any way to handle
36 // failures, so we have nothing to pass to on_upload_complete. Just pass 200
37 // (HTTP OK) and pretend everything is peachy.
38 on_upload_complete_.Run(200);
39 }
40
41 } // 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