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