Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1372)

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/customtabs/ResourcePrefetchPredictor.java

Issue 2498983005: predictors: Expose the initialization call to Android. (Closed)
Patch Set: Address comments. Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/android/java/src/org/chromium/chrome/browser/customtabs/ResourcePrefetchPredictor.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/customtabs/ResourcePrefetchPredictor.java b/chrome/android/java/src/org/chromium/chrome/browser/customtabs/ResourcePrefetchPredictor.java
index 332e9f8cf8255e22f60a2dab2ce672b6c3685278..215af894e2fd386dd3f7bcc65d67672994044568 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/customtabs/ResourcePrefetchPredictor.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/customtabs/ResourcePrefetchPredictor.java
@@ -16,6 +16,8 @@ import org.chromium.chrome.browser.profiles.Profile;
*/
@JNINamespace("predictors")
class ResourcePrefetchPredictor {
+ private static boolean sInitializationStarted;
+
private final Profile mProfile;
/**
@@ -26,6 +28,15 @@ class ResourcePrefetchPredictor {
}
/**
+ * Starts the asynchronous initialization of the prefetch predictor.
+ */
+ public boolean startInitialization() {
+ ThreadUtils.assertOnUiThread();
+ sInitializationStarted = true;
+ return nativeStartInitialization(mProfile);
+ }
+
+ /**
* Starts a prefetch for a URL.
*
* @param url The URL to start the prefetch for.
@@ -33,6 +44,9 @@ class ResourcePrefetchPredictor {
*/
public boolean startPrefetching(String url) {
ThreadUtils.assertOnUiThread();
+ if (!sInitializationStarted) {
+ throw new RuntimeException("startInitialization() not called.");
+ }
return nativeStartPrefetching(mProfile, url);
}
@@ -47,6 +61,7 @@ class ResourcePrefetchPredictor {
return nativeStopPrefetching(mProfile, url);
}
+ private static native boolean nativeStartInitialization(Profile profile);
private static native boolean nativeStartPrefetching(Profile profile, String url);
private static native boolean nativeStopPrefetching(Profile profile, String url);
}

Powered by Google App Engine
This is Rietveld 408576698