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

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

Issue 2548013002: Remove redundant field initialization in Java code. (Closed)
Patch Set: rebase Created 4 years 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.annotation.SuppressLint; 7 import android.annotation.SuppressLint;
8 import android.content.Context; 8 import android.content.Context;
9 import android.content.SharedPreferences; 9 import android.content.SharedPreferences;
10 import android.os.AsyncTask; 10 import android.os.AsyncTask;
(...skipping 28 matching lines...) Expand all
39 private static final float MAX_SCORE = 10; 39 private static final float MAX_SCORE = 10;
40 // TODO(lizeb): Control this value using Finch. 40 // TODO(lizeb): Control this value using Finch.
41 private static final long BAN_DURATION_MS = TimeUnit.DAYS.toMillis(7); 41 private static final long BAN_DURATION_MS = TimeUnit.DAYS.toMillis(7);
42 private static final long FORGET_AFTER_MS = TimeUnit.DAYS.toMillis(14); 42 private static final long FORGET_AFTER_MS = TimeUnit.DAYS.toMillis(14);
43 private static final float ALPHA = MAX_SCORE / BAN_DURATION_MS; 43 private static final float ALPHA = MAX_SCORE / BAN_DURATION_MS;
44 private static final String PREFERENCES_NAME = "customtabs_client_bans"; 44 private static final String PREFERENCES_NAME = "customtabs_client_bans";
45 private static final String SCORE = "score_"; 45 private static final String SCORE = "score_";
46 private static final String LAST_REQUEST = "last_request_"; 46 private static final String LAST_REQUEST = "last_request_";
47 private static final String BANNED_UNTIL = "banned_until_"; 47 private static final String BANNED_UNTIL = "banned_until_";
48 48
49 private static SparseArray<RequestThrottler> sUidToThrottler = null; 49 private static SparseArray<RequestThrottler> sUidToThrottler;
50 50
51 private final SharedPreferences mSharedPreferences; 51 private final SharedPreferences mSharedPreferences;
52 private final int mUid; 52 private final int mUid;
53 private float mScore; 53 private float mScore;
54 private long mLastPrerenderRequestMs; 54 private long mLastPrerenderRequestMs;
55 private long mBannedUntilMs; 55 private long mBannedUntilMs;
56 private String mUrl = null; 56 private String mUrl;
57 57
58 /** 58 /**
59 * Updates the prediction stats and returns whether prediction is allowed. 59 * Updates the prediction stats and returns whether prediction is allowed.
60 * 60 *
61 * The policy is: 61 * The policy is:
62 * 1. If the client does not wait more than mDelayMs, decline the request. 62 * 1. If the client does not wait more than mDelayMs, decline the request.
63 * 2. If the client waits for more than mDelayMs but less than 2*mDelayMs, a ccept the request 63 * 2. If the client waits for more than mDelayMs but less than 2*mDelayMs, a ccept the request
64 * and double mDelayMs. 64 * and double mDelayMs.
65 * 3. If the client waits for more than 2*mDelayMs, accept the request and r eset mDelayMs. 65 * 3. If the client waits for more than 2*mDelayMs, accept the request and r eset mDelayMs.
66 * 66 *
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 editor.apply(); 232 editor.apply();
233 } 233 }
234 234
235 @VisibleForTesting 235 @VisibleForTesting
236 static void purgeAllEntriesForTesting(Context context) { 236 static void purgeAllEntriesForTesting(Context context) {
237 SharedPreferences sharedPreferences = context.getSharedPreferences(PREFE RENCES_NAME, 0); 237 SharedPreferences sharedPreferences = context.getSharedPreferences(PREFE RENCES_NAME, 0);
238 sharedPreferences.edit().clear().apply(); 238 sharedPreferences.edit().clear().apply();
239 if (sUidToThrottler != null) sUidToThrottler.clear(); 239 if (sUidToThrottler != null) sUidToThrottler.clear();
240 } 240 }
241 } 241 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698