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