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

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

Issue 2377643002: predictors: Make the resource_prefetch_predictor accessible from Java. (Closed)
Patch Set: Address comments. Created 4 years, 2 months 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
« no previous file with comments | « no previous file | chrome/android/java_sources.gni » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
new file mode 100644
index 0000000000000000000000000000000000000000..332e9f8cf8255e22f60a2dab2ce672b6c3685278
--- /dev/null
+++ b/chrome/android/java/src/org/chromium/chrome/browser/customtabs/ResourcePrefetchPredictor.java
@@ -0,0 +1,52 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+package org.chromium.chrome.browser.customtabs;
+
+import org.chromium.base.ThreadUtils;
+import org.chromium.base.annotations.JNINamespace;
+import org.chromium.chrome.browser.profiles.Profile;
+
+/**
+ * Interface to the resource prefetch predictor.
+ *
+ * This allows to initiate and abort prefetches of likely subresources, based on
+ * the local browsing history.
+ */
+@JNINamespace("predictors")
+class ResourcePrefetchPredictor {
+ private final Profile mProfile;
+
+ /**
+ * @param profile The profile used to get the prefetch predictor.
+ */
+ public ResourcePrefetchPredictor(Profile profile) {
+ mProfile = profile;
+ }
+
+ /**
+ * Starts a prefetch for a URL.
+ *
+ * @param url The URL to start the prefetch for.
+ * @return false in case the ResourcePrefetchPredictor is not usable.
+ */
+ public boolean startPrefetching(String url) {
+ ThreadUtils.assertOnUiThread();
+ return nativeStartPrefetching(mProfile, url);
+ }
+
+ /**
+ * Stops a prefetch for a URL, if one is in progress.
+ *
+ * @param url The URL to stop the prefetch of.
+ * @return false in case the ResourcePrefetchPredictor is not usable.
+ */
+ public boolean stopPrefetching(String url) {
+ ThreadUtils.assertOnUiThread();
+ return nativeStopPrefetching(mProfile, url);
+ }
+
+ private static native boolean nativeStartPrefetching(Profile profile, String url);
+ private static native boolean nativeStopPrefetching(Profile profile, String url);
+}
« no previous file with comments | « no previous file | chrome/android/java_sources.gni » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698