OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/android/net/external_estimate_provider_android.h" | 5 #include "chrome/browser/android/net/external_estimate_provider_android.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include "base/android/context_utils.h" | 9 #include "base/android/context_utils.h" |
10 #include "base/location.h" | 10 #include "base/location.h" |
11 #include "base/message_loop/message_loop.h" | |
12 #include "base/single_thread_task_runner.h" | 11 #include "base/single_thread_task_runner.h" |
13 #include "content/public/browser/browser_thread.h" | 12 #include "content/public/browser/browser_thread.h" |
14 #include "jni/ExternalEstimateProviderAndroid_jni.h" | 13 #include "jni/ExternalEstimateProviderAndroid_jni.h" |
15 | 14 |
16 namespace chrome { | 15 namespace chrome { |
17 namespace android { | 16 namespace android { |
18 | 17 |
19 ExternalEstimateProviderAndroid::ExternalEstimateProviderAndroid() | 18 ExternalEstimateProviderAndroid::ExternalEstimateProviderAndroid() |
20 : task_runner_(nullptr), | 19 : task_runner_(nullptr), |
21 delegate_(nullptr), | 20 delegate_(nullptr), |
22 weak_factory_(this) { | 21 weak_factory_(this) { |
23 if (base::MessageLoop::current()) | 22 if (base::ThreadTaskRunnerHandle::IsSet()) |
24 task_runner_ = base::ThreadTaskRunnerHandle::Get(); | 23 task_runner_ = base::ThreadTaskRunnerHandle::Get(); |
25 JNIEnv* env = base::android::AttachCurrentThread(); | 24 JNIEnv* env = base::android::AttachCurrentThread(); |
26 j_external_estimate_provider_.Reset( | 25 j_external_estimate_provider_.Reset( |
27 Java_ExternalEstimateProviderAndroid_create( | 26 Java_ExternalEstimateProviderAndroid_create( |
28 env, base::android::GetApplicationContext(), | 27 env, base::android::GetApplicationContext(), |
29 reinterpret_cast<intptr_t>(this))); | 28 reinterpret_cast<intptr_t>(this))); |
30 DCHECK(!j_external_estimate_provider_.is_null()); | 29 DCHECK(!j_external_estimate_provider_.is_null()); |
31 no_value_ = Java_ExternalEstimateProviderAndroid_getNoValue(env); | 30 no_value_ = Java_ExternalEstimateProviderAndroid_getNoValue(env); |
32 } | 31 } |
33 | 32 |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
144 upstream_throughput_kbps); | 143 upstream_throughput_kbps); |
145 } | 144 } |
146 } | 145 } |
147 | 146 |
148 bool RegisterExternalEstimateProviderAndroid(JNIEnv* env) { | 147 bool RegisterExternalEstimateProviderAndroid(JNIEnv* env) { |
149 return RegisterNativesImpl(env); | 148 return RegisterNativesImpl(env); |
150 } | 149 } |
151 | 150 |
152 } // namespace android | 151 } // namespace android |
153 } // namespace chrome | 152 } // namespace chrome |
OLD | NEW |