| 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 package org.chromium.chrome.browser.net.qualityprovider; | 5 package org.chromium.chrome.browser.net.qualityprovider; |
| 6 | 6 |
| 7 import android.content.Context; | |
| 8 | |
| 9 import org.chromium.base.NonThreadSafe; | 7 import org.chromium.base.NonThreadSafe; |
| 10 import org.chromium.base.annotations.CalledByNative; | 8 import org.chromium.base.annotations.CalledByNative; |
| 11 import org.chromium.base.annotations.JNINamespace; | 9 import org.chromium.base.annotations.JNINamespace; |
| 12 import org.chromium.chrome.browser.AppHooks; | 10 import org.chromium.chrome.browser.AppHooks; |
| 13 | 11 |
| 14 /** | 12 /** |
| 15 * This class provides a base class implementation and may be overridden on oper
ating systems that | 13 * This class provides a base class implementation and may be overridden on oper
ating systems that |
| 16 * provide more useful APIs. All method calls from native code will happen on th
e thread where | 14 * provide more useful APIs. All method calls from native code will happen on th
e thread where |
| 17 * this object is constructed, but calls from subclasses (specifically, | 15 * this object is constructed, but calls from subclasses (specifically, |
| 18 * {@link #notifyExternalEstimateProviderAndroidUpdate()} can happen on other th
reads. | 16 * {@link #notifyExternalEstimateProviderAndroidUpdate()} can happen on other th
reads. |
| 19 */ | 17 */ |
| 20 @JNINamespace("chrome::android") | 18 @JNINamespace("chrome::android") |
| 21 public class ExternalEstimateProviderAndroid { | 19 public class ExternalEstimateProviderAndroid { |
| 22 /** | 20 /** |
| 23 * Value to return if a valid value is unavailable. | 21 * Value to return if a valid value is unavailable. |
| 24 */ | 22 */ |
| 25 protected static final int NO_VALUE = -1; | 23 protected static final int NO_VALUE = -1; |
| 26 private NonThreadSafe mThreadCheck = new NonThreadSafe(); | 24 private NonThreadSafe mThreadCheck = new NonThreadSafe(); |
| 27 private final Object mLock = new Object(); | 25 private final Object mLock = new Object(); |
| 28 | 26 |
| 29 private long mNativePtr; | 27 private long mNativePtr; |
| 30 | 28 |
| 31 @CalledByNative | 29 @CalledByNative |
| 32 private static ExternalEstimateProviderAndroid create(Context context, long
nativePtr) { | 30 private static ExternalEstimateProviderAndroid create(long nativePtr) { |
| 33 return AppHooks.get().createExternalEstimateProviderAndroid(nativePtr); | 31 return AppHooks.get().createExternalEstimateProviderAndroid(nativePtr); |
| 34 } | 32 } |
| 35 | 33 |
| 36 /** | 34 /** |
| 37 * Creates an instance of {@link ExternalEstimateProviderAndroid}. | 35 * Creates an instance of {@link ExternalEstimateProviderAndroid}. |
| 38 */ | 36 */ |
| 39 protected ExternalEstimateProviderAndroid(long nativePtr) { | 37 protected ExternalEstimateProviderAndroid(long nativePtr) { |
| 40 mNativePtr = nativePtr; | 38 mNativePtr = nativePtr; |
| 41 } | 39 } |
| 42 | 40 |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 | 103 |
| 106 // It's important to call this inside the critical section, to ensur
e the native object | 104 // It's important to call this inside the critical section, to ensur
e the native object |
| 107 // isn't destroyed on its origin thread in the meantime. | 105 // isn't destroyed on its origin thread in the meantime. |
| 108 nativeNotifyExternalEstimateProviderAndroidUpdate(mNativePtr); | 106 nativeNotifyExternalEstimateProviderAndroidUpdate(mNativePtr); |
| 109 } | 107 } |
| 110 } | 108 } |
| 111 | 109 |
| 112 private native void nativeNotifyExternalEstimateProviderAndroidUpdate( | 110 private native void nativeNotifyExternalEstimateProviderAndroidUpdate( |
| 113 long nativeExternalEstimateProviderAndroid); | 111 long nativeExternalEstimateProviderAndroid); |
| 114 } | 112 } |
| OLD | NEW |