Chromium Code Reviews| OLD | NEW |
|---|---|
| (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); | |
|
Alexei Svitkine (slow)
2017/03/29 19:19:17
I agree about your point about this leaking implem
paulmiller
2017/03/29 19:52:38
Okay, I'll do that separately.
| |
| 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 | |
| OLD | NEW |