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

Unified Diff: components/cronet/android/cronet_url_request_adapter.cc

Issue 2360813003: [Cronet] Pass metrics information from C++ BidirectionalStream to Java (Closed)
Patch Set: Rebased Created 4 years, 2 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: components/cronet/android/cronet_url_request_adapter.cc
diff --git a/components/cronet/android/cronet_url_request_adapter.cc b/components/cronet/android/cronet_url_request_adapter.cc
index 75362cde1e468b071d890d58324fb6d554b3a485..7072793b179f761f27f3f272ba179c9b84093b04 100644
--- a/components/cronet/android/cronet_url_request_adapter.cc
+++ b/components/cronet/android/cronet_url_request_adapter.cc
@@ -13,6 +13,7 @@
#include "base/logging.h"
#include "components/cronet/android/cronet_url_request_context_adapter.h"
#include "components/cronet/android/io_buffer_with_byte_buffer.h"
+#include "components/cronet/android/metrics_util.h"
#include "components/cronet/android/url_request_error.h"
#include "jni/CronetUrlRequest_jni.h"
#include "net/base/load_flags.h"
@@ -36,18 +37,6 @@ namespace cronet {
namespace {
-// Converts timing metrics stored as TimeTicks into the format expected by the
-// Java layer: ms since Unix epoch, or -1 for null
-int64_t ConvertTime(const base::TimeTicks& ticks,
- const base::TimeTicks& start_ticks,
- const base::Time& start_time) {
- if (ticks.is_null() || start_ticks.is_null()) {
- return -1;
- }
- DCHECK(!start_time.is_null());
- return (start_time + (ticks - start_ticks)).ToJavaTime();
-}
-
// Returns the string representation of the HostPortPair of the proxy server
// that was used to fetch the response.
std::string GetProxy(const net::HttpResponseInfo& info) {
@@ -421,20 +410,28 @@ void CronetURLRequestAdapter::MaybeReportMetrics(JNIEnv* env) const {
base::Time start_time = metrics.request_start_time;
base::TimeTicks start_ticks = metrics.request_start;
Java_CronetUrlRequest_onMetricsCollected(
- env, owner_.obj(), ConvertTime(start_ticks, start_ticks, start_time),
- ConvertTime(metrics.connect_timing.dns_start, start_ticks, start_time),
- ConvertTime(metrics.connect_timing.dns_end, start_ticks, start_time),
- ConvertTime(metrics.connect_timing.connect_start, start_ticks,
- start_time),
- ConvertTime(metrics.connect_timing.connect_end, start_ticks, start_time),
- ConvertTime(metrics.connect_timing.ssl_start, start_ticks, start_time),
- ConvertTime(metrics.connect_timing.ssl_end, start_ticks, start_time),
- ConvertTime(metrics.send_start, start_ticks, start_time),
- ConvertTime(metrics.send_end, start_ticks, start_time),
- ConvertTime(metrics.push_start, start_ticks, start_time),
- ConvertTime(metrics.push_end, start_ticks, start_time),
- ConvertTime(metrics.receive_headers_end, start_ticks, start_time),
- ConvertTime(base::TimeTicks::Now(), start_ticks, start_time),
+ env, owner_.obj(),
+ metrics_util::ConvertTime(start_ticks, start_ticks, start_time),
+ metrics_util::ConvertTime(metrics.connect_timing.dns_start, start_ticks,
+ start_time),
+ metrics_util::ConvertTime(metrics.connect_timing.dns_end, start_ticks,
+ start_time),
+ metrics_util::ConvertTime(metrics.connect_timing.connect_start,
+ start_ticks, start_time),
+ metrics_util::ConvertTime(metrics.connect_timing.connect_end, start_ticks,
+ start_time),
+ metrics_util::ConvertTime(metrics.connect_timing.ssl_start, start_ticks,
+ start_time),
+ metrics_util::ConvertTime(metrics.connect_timing.ssl_end, start_ticks,
+ start_time),
+ metrics_util::ConvertTime(metrics.send_start, start_ticks, start_time),
+ metrics_util::ConvertTime(metrics.send_end, start_ticks, start_time),
+ metrics_util::ConvertTime(metrics.push_start, start_ticks, start_time),
+ metrics_util::ConvertTime(metrics.push_end, start_ticks, start_time),
+ metrics_util::ConvertTime(metrics.receive_headers_end, start_ticks,
+ start_time),
+ metrics_util::ConvertTime(base::TimeTicks::Now(), start_ticks,
+ start_time),
metrics.socket_reused, url_request_->GetTotalSentBytes(),
url_request_->GetTotalReceivedBytes());
}

Powered by Google App Engine
This is Rietveld 408576698