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

Unified Diff: chrome/browser/android/net/network_quality_provider.cc

Issue 1235373006: Upstream changes for NetworkQualityProvider (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Removed context Created 5 years, 5 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: chrome/browser/android/net/network_quality_provider.cc
diff --git a/chrome/browser/android/net/network_quality_provider.cc b/chrome/browser/android/net/network_quality_provider.cc
new file mode 100644
index 0000000000000000000000000000000000000000..6e2ef351819c16e45f939a25a7a0f7f024d26ac2
--- /dev/null
+++ b/chrome/browser/android/net/network_quality_provider.cc
@@ -0,0 +1,52 @@
+// Copyright 2015 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.
bengr 2015/07/21 00:06:48 Add a blank line.
tbansal1 2015/07/21 16:18:25 Done.
+#include "chrome/browser/android/net/network_quality_provider.h"
+
+#include "jni/NetworkQualityProviderHelper_jni.h"
+
+NetworkQualityProvider::NetworkQualityProvider() {
+ JNIEnv* env = base::android::AttachCurrentThread();
+ j_network_quality_provider_.Reset(Java_NetworkQualityProviderHelper_create(
+ env, base::android::GetApplicationContext()));
+}
+
+NetworkQualityProvider::~NetworkQualityProvider() {
+ DCHECK(thread_checker_.CalledOnValidThread());
+}
+
+bool NetworkQualityProvider::IsEstimateAvailable() {
+ DCHECK(thread_checker_.CalledOnValidThread());
+ JNIEnv* env = base::android::AttachCurrentThread();
+ return Java_NetworkQualityProviderHelper_isEstimateAvailable(env);
+}
+
+base::TimeDelta NetworkQualityProvider::GetRTT() {
+ DCHECK(thread_checker_.CalledOnValidThread());
+ JNIEnv* env = base::android::AttachCurrentThread();
+ return base::TimeDelta::FromMilliseconds(
+ Java_NetworkQualityProviderHelper_getRTTMilliseconds(env));
+}
+
+int NetworkQualityProvider::GetDownstreamThroughputKbps() {
+ DCHECK(thread_checker_.CalledOnValidThread());
+ JNIEnv* env = base::android::AttachCurrentThread();
+ return Java_NetworkQualityProviderHelper_getDownstreamThroughputKbps(env);
+}
+
+int NetworkQualityProvider::GetUpstreamThroughputKbps() {
+ DCHECK(thread_checker_.CalledOnValidThread());
+ JNIEnv* env = base::android::AttachCurrentThread();
+ return Java_NetworkQualityProviderHelper_getUpstreamThroughputKbps(env);
+}
+
+base::TimeDelta NetworkQualityProvider::GetTimeSinceLastUpdate() {
+ DCHECK(thread_checker_.CalledOnValidThread());
+ JNIEnv* env = base::android::AttachCurrentThread();
+ return base::TimeDelta::FromSeconds(
+ Java_NetworkQualityProviderHelper_getTimeSinceLastUpdateSeconds(env));
+}
+
+bool RegisterNetworkQualityProvider(JNIEnv* env) {
+ return RegisterNativesImpl(env);
+}

Powered by Google App Engine
This is Rietveld 408576698