| 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 #ifndef CHROME_BROWSER_ANDROID_NET_EXTERNAL_ESTIMATE_PROVIDER_ANDROID_H_ | 5 #ifndef CHROME_BROWSER_ANDROID_NET_EXTERNAL_ESTIMATE_PROVIDER_ANDROID_H_ |
| 6 #define CHROME_BROWSER_ANDROID_NET_EXTERNAL_ESTIMATE_PROVIDER_ANDROID_H_ | 6 #define CHROME_BROWSER_ANDROID_NET_EXTERNAL_ESTIMATE_PROVIDER_ANDROID_H_ |
| 7 | 7 |
| 8 #include <jni.h> | 8 #include <jni.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 | 10 |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 | 55 |
| 56 // net::ExternalEstimateProvider implementation. | 56 // net::ExternalEstimateProvider implementation. |
| 57 void SetUpdatedEstimateDelegate( | 57 void SetUpdatedEstimateDelegate( |
| 58 net::ExternalEstimateProvider::UpdatedEstimateDelegate* delegate) | 58 net::ExternalEstimateProvider::UpdatedEstimateDelegate* delegate) |
| 59 override; | 59 override; |
| 60 | 60 |
| 61 // Called by Java when the external estimate provider has an updated value. | 61 // Called by Java when the external estimate provider has an updated value. |
| 62 // This may be called on a thread different from |task_runner_|. | 62 // This may be called on a thread different from |task_runner_|. |
| 63 void NotifyExternalEstimateProviderAndroidUpdate(JNIEnv* env, jobject obj); | 63 void NotifyExternalEstimateProviderAndroidUpdate(JNIEnv* env, jobject obj); |
| 64 | 64 |
| 65 // net::ExternalEstimateProvider implementation. |
| 66 void RequestUpdate() const override; |
| 67 |
| 65 protected: | 68 protected: |
| 66 // Notifies the delegate that a new update to external estimate is available. | 69 // Notifies the delegate that a new update to external estimate is available. |
| 67 // Protected for testing. | 70 // Protected for testing. |
| 68 void NotifyUpdatedEstimateAvailable() const; | 71 void NotifyUpdatedEstimateAvailable() const; |
| 69 | 72 |
| 70 private: | 73 private: |
| 71 // Places a requests to the provider to update the network quality. Returns | |
| 72 // true if the request was placed successfully. | |
| 73 void RequestUpdate() const; | |
| 74 | |
| 75 // Value returned if valid value is unavailable. | 74 // Value returned if valid value is unavailable. |
| 76 int32_t no_value_ = -1; | 75 int32_t no_value_ = -1; |
| 77 | 76 |
| 78 base::android::ScopedJavaGlobalRef<jobject> j_external_estimate_provider_; | 77 base::android::ScopedJavaGlobalRef<jobject> j_external_estimate_provider_; |
| 79 | 78 |
| 80 // Task runner that accesses ExternalEstimateProviderAndroid members. | 79 // Task runner that accesses ExternalEstimateProviderAndroid members. |
| 81 scoped_refptr<base::TaskRunner> task_runner_; | 80 scoped_refptr<base::TaskRunner> task_runner_; |
| 82 | 81 |
| 83 // Notified every time there is an update available from the network quality | 82 // Notified every time there is an update available from the network quality |
| 84 // provider. | 83 // provider. |
| 85 // TODO(tbansal): Add the function that is called by Java side when an update | 84 // TODO(tbansal): Add the function that is called by Java side when an update |
| 86 // is available. | 85 // is available. |
| 87 net::ExternalEstimateProvider::UpdatedEstimateDelegate* delegate_; | 86 net::ExternalEstimateProvider::UpdatedEstimateDelegate* delegate_; |
| 88 | 87 |
| 89 base::ThreadChecker thread_checker_; | 88 base::ThreadChecker thread_checker_; |
| 90 | 89 |
| 91 // Used for posting tasks. | 90 // Used for posting tasks. |
| 92 base::WeakPtrFactory<ExternalEstimateProviderAndroid> weak_factory_; | 91 base::WeakPtrFactory<ExternalEstimateProviderAndroid> weak_factory_; |
| 93 | 92 |
| 94 DISALLOW_COPY_AND_ASSIGN(ExternalEstimateProviderAndroid); | 93 DISALLOW_COPY_AND_ASSIGN(ExternalEstimateProviderAndroid); |
| 95 }; | 94 }; |
| 96 | 95 |
| 97 bool RegisterExternalEstimateProviderAndroid(JNIEnv* env); | 96 bool RegisterExternalEstimateProviderAndroid(JNIEnv* env); |
| 98 | 97 |
| 99 } // namespace android | 98 } // namespace android |
| 100 } // namespace chrome | 99 } // namespace chrome |
| 101 | 100 |
| 102 #endif // CHROME_BROWSER_ANDROID_NET_EXTERNAL_ESTIMATE_PROVIDER_ANDROID_H_ | 101 #endif // CHROME_BROWSER_ANDROID_NET_EXTERNAL_ESTIMATE_PROVIDER_ANDROID_H_ |
| OLD | NEW |