| OLD | NEW |
| 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.text.TextUtils; | 8 import android.text.TextUtils; |
| 9 | 9 |
| 10 import com.google.android.gms.iid.InstanceID; | 10 import com.google.android.gms.iid.InstanceID; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 private final String mSubtype; | 24 private final String mSubtype; |
| 25 | 25 |
| 26 /** Cached instances. May be accessed from multiple threads; synchronize on
InstanceID.class. */ | 26 /** Cached instances. May be accessed from multiple threads; synchronize on
InstanceID.class. */ |
| 27 @VisibleForTesting | 27 @VisibleForTesting |
| 28 @SuppressFBWarnings("MS_MUTABLE_COLLECTION_PKGPROTECT") | 28 @SuppressFBWarnings("MS_MUTABLE_COLLECTION_PKGPROTECT") |
| 29 public static final Map<String, InstanceIDWithSubtype> sSubtypeInstances = n
ew HashMap<>(); | 29 public static final Map<String, InstanceIDWithSubtype> sSubtypeInstances = n
ew HashMap<>(); |
| 30 | 30 |
| 31 /** Fake subclasses can set this so getInstance creates instances of them. *
/ | 31 /** Fake subclasses can set this so getInstance creates instances of them. *
/ |
| 32 @VisibleForTesting | 32 @VisibleForTesting |
| 33 @SuppressFBWarnings("MS_SHOULD_BE_FINAL") | 33 @SuppressFBWarnings("MS_SHOULD_BE_FINAL") |
| 34 protected static FakeFactory sFakeFactoryForTesting = null; | 34 protected static FakeFactory sFakeFactoryForTesting; |
| 35 | 35 |
| 36 protected InstanceIDWithSubtype(Context context, String subtype) { | 36 protected InstanceIDWithSubtype(Context context, String subtype) { |
| 37 super(context, subtype, null /* options */); | 37 super(context, subtype, null /* options */); |
| 38 mSubtype = subtype; | 38 mSubtype = subtype; |
| 39 } | 39 } |
| 40 | 40 |
| 41 /** | 41 /** |
| 42 * Returns an instance of this class. Unlike {@link InstanceID#getInstance(C
ontext)}, it is not | 42 * Returns an instance of this class. Unlike {@link InstanceID#getInstance(C
ontext)}, it is not |
| 43 * a singleton, but instead a different instance will be returned for each {
@code subtype}. | 43 * a singleton, but instead a different instance will be returned for each {
@code subtype}. |
| 44 */ | 44 */ |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 public String getSubtype() { | 83 public String getSubtype() { |
| 84 return mSubtype; | 84 return mSubtype; |
| 85 } | 85 } |
| 86 | 86 |
| 87 /** Fake subclasses can set {@link #sFakeFactoryForTesting} to an implementa
tion of this. */ | 87 /** Fake subclasses can set {@link #sFakeFactoryForTesting} to an implementa
tion of this. */ |
| 88 @VisibleForTesting | 88 @VisibleForTesting |
| 89 public interface FakeFactory { | 89 public interface FakeFactory { |
| 90 public InstanceIDWithSubtype create(Context context, String subtype); | 90 public InstanceIDWithSubtype create(Context context, String subtype); |
| 91 } | 91 } |
| 92 } | 92 } |
| OLD | NEW |