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

Side by Side Diff: chrome/android/java/src/org/chromium/chrome/browser/customtabs/ClientManager.java

Issue 1767243002: Update prerender policy for custom tabs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: mmenke@'s comments Created 4 years, 9 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 unified diff | Download patch
OLDNEW
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.customtabs; 5 package org.chromium.chrome.browser.customtabs;
6 6
7 import android.content.ComponentName; 7 import android.content.ComponentName;
8 import android.content.Context; 8 import android.content.Context;
9 import android.content.Intent; 9 import android.content.Intent;
10 import android.content.ServiceConnection; 10 import android.content.ServiceConnection;
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 @VisibleForTesting static final int SESSION_WARMUP_COUNT = 5; 47 @VisibleForTesting static final int SESSION_WARMUP_COUNT = 5;
48 48
49 /** Per-session values. */ 49 /** Per-session values. */
50 private static class SessionParams { 50 private static class SessionParams {
51 public final int uid; 51 public final int uid;
52 public final String packageName; 52 public final String packageName;
53 public final ICustomTabsCallback callback; 53 public final ICustomTabsCallback callback;
54 public final IBinder.DeathRecipient deathRecipient; 54 public final IBinder.DeathRecipient deathRecipient;
55 public boolean mIgnoreFragments; 55 public boolean mIgnoreFragments;
56 private boolean mShouldHideDomain; 56 private boolean mShouldHideDomain;
57 private boolean mShouldPrerenderOnCellular;
57 private ServiceConnection mKeepAliveConnection; 58 private ServiceConnection mKeepAliveConnection;
58 private String mPredictedUrl; 59 private String mPredictedUrl;
59 private long mLastMayLaunchUrlTimestamp; 60 private long mLastMayLaunchUrlTimestamp;
60 61
61 public SessionParams(Context context, int uid, ICustomTabsCallback callb ack, 62 public SessionParams(Context context, int uid, ICustomTabsCallback callb ack,
62 IBinder.DeathRecipient deathRecipient) { 63 IBinder.DeathRecipient deathRecipient) {
63 this.uid = uid; 64 this.uid = uid;
64 packageName = getPackageName(context, uid); 65 packageName = getPackageName(context, uid);
65 this.callback = callback; 66 this.callback = callback;
66 this.deathRecipient = deathRecipient; 67 this.deathRecipient = deathRecipient;
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 * @return Whether the fragment should be ignored for prerender matching. 264 * @return Whether the fragment should be ignored for prerender matching.
264 */ 265 */
265 public synchronized boolean getIgnoreFragmentsForSession(IBinder session) { 266 public synchronized boolean getIgnoreFragmentsForSession(IBinder session) {
266 SessionParams params = mSessionParams.get(session); 267 SessionParams params = mSessionParams.get(session);
267 return params == null ? false : params.mIgnoreFragments; 268 return params == null ? false : params.mIgnoreFragments;
268 } 269 }
269 270
270 /** Sets whether the fragment should be ignored for prerender matching. */ 271 /** Sets whether the fragment should be ignored for prerender matching. */
271 public synchronized void setIgnoreFragmentsForSession(IBinder session, boole an value) { 272 public synchronized void setIgnoreFragmentsForSession(IBinder session, boole an value) {
272 SessionParams params = mSessionParams.get(session); 273 SessionParams params = mSessionParams.get(session);
273 params.mIgnoreFragments = value; 274 if (params != null) params.mIgnoreFragments = value;
275 }
276
277 /**
278 * @return Whether prerender should be turned on for cellular networks for g iven session.
279 */
280 public synchronized boolean shouldPrerenderOnCellularForSession(IBinder sess ion) {
281 SessionParams params = mSessionParams.get(session);
282 return params != null ? params.mShouldPrerenderOnCellular : false;
283 }
284
285 /**
286 * Sets whether prerender should be turned on for mobile networks for given session.
287 */
288 public synchronized void setPrerenderCellularForSession(IBinder session, boo lean prerender) {
289 SessionParams params = mSessionParams.get(session);
290 if (params != null) params.mShouldPrerenderOnCellular = prerender;
274 } 291 }
275 292
276 /** Tries to bind to a client to keep it alive, and returns true for success . */ 293 /** Tries to bind to a client to keep it alive, and returns true for success . */
277 public synchronized boolean keepAliveForSession(IBinder session, Intent inte nt) { 294 public synchronized boolean keepAliveForSession(IBinder session, Intent inte nt) {
278 // When an application is bound to a service, its priority is raised to 295 // When an application is bound to a service, its priority is raised to
279 // be at least equal to the application's one. This binds to a dummy 296 // be at least equal to the application's one. This binds to a dummy
280 // service (no calls to this service are made). 297 // service (no calls to this service are made).
281 if (intent == null || intent.getComponent() == null) return false; 298 if (intent == null || intent.getComponent() == null) return false;
282 SessionParams params = mSessionParams.get(session); 299 SessionParams params = mSessionParams.get(session);
283 if (params == null) return false; 300 if (params == null) return false;
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
342 359
343 private synchronized void cleanupSession(IBinder session) { 360 private synchronized void cleanupSession(IBinder session) {
344 SessionParams params = mSessionParams.get(session); 361 SessionParams params = mSessionParams.get(session);
345 if (params == null) return; 362 if (params == null) return;
346 mSessionParams.remove(session); 363 mSessionParams.remove(session);
347 mUidHasCalledWarmup.delete(params.uid); 364 mUidHasCalledWarmup.delete(params.uid);
348 IBinder binder = params.callback.asBinder(); 365 IBinder binder = params.callback.asBinder();
349 binder.unlinkToDeath(params.deathRecipient, 0); 366 binder.unlinkToDeath(params.deathRecipient, 0);
350 } 367 }
351 } 368 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698