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.os.AsyncTask; | 8 import android.os.AsyncTask; |
9 import android.os.Bundle; | 9 import android.os.Bundle; |
10 | 10 |
(...skipping 11 matching lines...) Expand all Loading... |
22 */ | 22 */ |
23 @JNINamespace("instance_id") | 23 @JNINamespace("instance_id") |
24 public class InstanceIDBridge { | 24 public class InstanceIDBridge { |
25 private final Context mContext; | 25 private final Context mContext; |
26 private final String mSubtype; | 26 private final String mSubtype; |
27 private long mNativeInstanceIDAndroid; | 27 private long mNativeInstanceIDAndroid; |
28 /** | 28 /** |
29 * Underlying InstanceID. May be shared by multiple InstanceIDBridges. Must
be initialized on | 29 * Underlying InstanceID. May be shared by multiple InstanceIDBridges. Must
be initialized on |
30 * a background thread. | 30 * a background thread. |
31 */ | 31 */ |
32 private InstanceID mInstanceID = null; | 32 private InstanceID mInstanceID; |
33 | 33 |
34 private static boolean sBlockOnAsyncTasksForTesting = false; | 34 private static boolean sBlockOnAsyncTasksForTesting; |
35 | 35 |
36 private InstanceIDBridge( | 36 private InstanceIDBridge( |
37 long nativeInstanceIDAndroid, Context context, String subtype) { | 37 long nativeInstanceIDAndroid, Context context, String subtype) { |
38 mContext = context.getApplicationContext(); // Storing activity context
would leak activity. | 38 mContext = context.getApplicationContext(); // Storing activity context
would leak activity. |
39 mSubtype = subtype; | 39 mSubtype = subtype; |
40 mNativeInstanceIDAndroid = nativeInstanceIDAndroid; | 40 mNativeInstanceIDAndroid = nativeInstanceIDAndroid; |
41 } | 41 } |
42 | 42 |
43 /** | 43 /** |
44 * Returns a wrapped {@link InstanceIDWithSubtype}. Multiple InstanceIDBridg
e instances may | 44 * Returns a wrapped {@link InstanceIDWithSubtype}. Multiple InstanceIDBridg
e instances may |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
217 // Synchronously block the UI thread until doInBackground re
turns result. | 217 // Synchronously block the UI thread until doInBackground re
turns result. |
218 result = task.get(); | 218 result = task.get(); |
219 } catch (InterruptedException | ExecutionException e) { | 219 } catch (InterruptedException | ExecutionException e) { |
220 throw new IllegalStateException(e); // Shouldn't happen in t
ests. | 220 throw new IllegalStateException(e); // Shouldn't happen in t
ests. |
221 } | 221 } |
222 sendResultToNative(result); | 222 sendResultToNative(result); |
223 } | 223 } |
224 } | 224 } |
225 } | 225 } |
226 } | 226 } |
OLD | NEW |