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" | |
10 #include "base/location.h" | 9 #include "base/location.h" |
11 #include "base/single_thread_task_runner.h" | 10 #include "base/single_thread_task_runner.h" |
12 #include "content/public/browser/browser_thread.h" | 11 #include "content/public/browser/browser_thread.h" |
13 #include "jni/ExternalEstimateProviderAndroid_jni.h" | 12 #include "jni/ExternalEstimateProviderAndroid_jni.h" |
14 | 13 |
15 using base::android::JavaParamRef; | 14 using base::android::JavaParamRef; |
16 | 15 |
17 namespace chrome { | 16 namespace chrome { |
18 namespace android { | 17 namespace android { |
19 | 18 |
20 ExternalEstimateProviderAndroid::ExternalEstimateProviderAndroid() | 19 ExternalEstimateProviderAndroid::ExternalEstimateProviderAndroid() |
21 : task_runner_(nullptr), | 20 : task_runner_(nullptr), |
22 delegate_(nullptr), | 21 delegate_(nullptr), |
23 weak_factory_(this) { | 22 weak_factory_(this) { |
24 if (base::ThreadTaskRunnerHandle::IsSet()) | 23 if (base::ThreadTaskRunnerHandle::IsSet()) |
25 task_runner_ = base::ThreadTaskRunnerHandle::Get(); | 24 task_runner_ = base::ThreadTaskRunnerHandle::Get(); |
26 JNIEnv* env = base::android::AttachCurrentThread(); | 25 JNIEnv* env = base::android::AttachCurrentThread(); |
27 j_external_estimate_provider_.Reset( | 26 j_external_estimate_provider_.Reset( |
28 Java_ExternalEstimateProviderAndroid_create( | 27 Java_ExternalEstimateProviderAndroid_create( |
29 env, base::android::GetApplicationContext(), | 28 env, reinterpret_cast<intptr_t>(this))); |
30 reinterpret_cast<intptr_t>(this))); | |
31 DCHECK(!j_external_estimate_provider_.is_null()); | 29 DCHECK(!j_external_estimate_provider_.is_null()); |
32 no_value_ = Java_ExternalEstimateProviderAndroid_getNoValue(env); | 30 no_value_ = Java_ExternalEstimateProviderAndroid_getNoValue(env); |
33 } | 31 } |
34 | 32 |
35 ExternalEstimateProviderAndroid::~ExternalEstimateProviderAndroid() { | 33 ExternalEstimateProviderAndroid::~ExternalEstimateProviderAndroid() { |
36 DCHECK(thread_checker_.CalledOnValidThread()); | 34 DCHECK(thread_checker_.CalledOnValidThread()); |
37 Java_ExternalEstimateProviderAndroid_destroy( | 35 Java_ExternalEstimateProviderAndroid_destroy( |
38 base::android::AttachCurrentThread(), j_external_estimate_provider_); | 36 base::android::AttachCurrentThread(), j_external_estimate_provider_); |
39 } | 37 } |
40 | 38 |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
144 upstream_throughput_kbps); | 142 upstream_throughput_kbps); |
145 } | 143 } |
146 } | 144 } |
147 | 145 |
148 bool RegisterExternalEstimateProviderAndroid(JNIEnv* env) { | 146 bool RegisterExternalEstimateProviderAndroid(JNIEnv* env) { |
149 return RegisterNativesImpl(env); | 147 return RegisterNativesImpl(env); |
150 } | 148 } |
151 | 149 |
152 } // namespace android | 150 } // namespace android |
153 } // namespace chrome | 151 } // namespace chrome |
OLD | NEW |