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

Side by Side Diff: components/gcm_driver/instance_id/android/javatests/src/org/chromium/components/gcm_driver/instance_id/FakeInstanceIDWithSubtype.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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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.components.gcm_driver.instance_id; 5 package org.chromium.components.gcm_driver.instance_id;
6 6
7 import android.content.Context; 7 import android.content.Context;
8 import android.os.Bundle; 8 import android.os.Bundle;
9 import android.os.Looper; 9 import android.os.Looper;
10 import android.util.Pair; 10 import android.util.Pair;
11 11
12 import com.google.android.gms.iid.InstanceID; 12 import com.google.android.gms.iid.InstanceID;
13 13
14 import org.chromium.base.annotations.CalledByNative; 14 import org.chromium.base.annotations.CalledByNative;
15 import org.chromium.base.annotations.JNINamespace; 15 import org.chromium.base.annotations.JNINamespace;
16 16
17 import java.io.IOException; 17 import java.io.IOException;
18 18
19 import java.util.HashMap; 19 import java.util.HashMap;
20 import java.util.Map; 20 import java.util.Map;
21 import java.util.Random; 21 import java.util.Random;
22 22
23 /** 23 /**
24 * Fake for InstanceIDWithSubtype. Doesn't hit the network or filesystem (so ins tance IDs don't 24 * Fake for InstanceIDWithSubtype. Doesn't hit the network or filesystem (so ins tance IDs don't
25 * survive restarts, and sending messages to tokens via the GCM server won't wor k). 25 * survive restarts, and sending messages to tokens via the GCM server won't wor k).
26 */ 26 */
27 @JNINamespace("instance_id") 27 @JNINamespace("instance_id")
28 public class FakeInstanceIDWithSubtype extends InstanceIDWithSubtype { 28 public class FakeInstanceIDWithSubtype extends InstanceIDWithSubtype {
29 private String mId = null; 29 private String mId;
30 private long mCreationTime = 0; 30 private long mCreationTime;
31 31
32 /** Map from (subtype + ',' + authorizedEntity + ',' + scope) to token. */ 32 /** Map from (subtype + ',' + authorizedEntity + ',' + scope) to token. */
33 private Map<String, String> mTokens = new HashMap<>(); 33 private Map<String, String> mTokens = new HashMap<>();
34 34
35 /** 35 /**
36 * Enable this in all InstanceID tests to use this fake instead of hitting t he network/disk. 36 * Enable this in all InstanceID tests to use this fake instead of hitting t he network/disk.
37 * @return The previous value. 37 * @return The previous value.
38 */ 38 */
39 @CalledByNative 39 @CalledByNative
40 public static boolean clearDataAndSetEnabled(boolean enable) { 40 public static boolean clearDataAndSetEnabled(boolean enable) {
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz- _"; 175 "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz- _";
176 Random random = new Random(); 176 Random random = new Random();
177 StringBuilder sb = new StringBuilder(encodedLength); 177 StringBuilder sb = new StringBuilder(encodedLength);
178 for (int i = 0; i < encodedLength; i++) { 178 for (int i = 0; i < encodedLength; i++) {
179 int index = random.nextInt(base64urlAlphabet.length()); 179 int index = random.nextInt(base64urlAlphabet.length());
180 sb.append(base64urlAlphabet.charAt(index)); 180 sb.append(base64urlAlphabet.charAt(index));
181 } 181 }
182 return sb.toString(); 182 return sb.toString();
183 } 183 }
184 } 184 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698