OLD | NEW |
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 #ifndef COMPONENTS_GCM_DRIVER_INSTANCE_ID_INSTANCE_ID_ANDROID_H_ | 5 #ifndef COMPONENTS_GCM_DRIVER_INSTANCE_ID_INSTANCE_ID_ANDROID_H_ |
6 #define COMPONENTS_GCM_DRIVER_INSTANCE_ID_INSTANCE_ID_ANDROID_H_ | 6 #define COMPONENTS_GCM_DRIVER_INSTANCE_ID_INSTANCE_ID_ANDROID_H_ |
7 | 7 |
8 #include <jni.h> | 8 #include <jni.h> |
9 | 9 |
10 #include <map> | 10 #include <map> |
11 #include <string> | 11 #include <string> |
12 | 12 |
13 #include "base/android/scoped_java_ref.h" | 13 #include "base/android/scoped_java_ref.h" |
14 #include "base/callback.h" | 14 #include "base/callback.h" |
15 #include "base/compiler_specific.h" | 15 #include "base/compiler_specific.h" |
16 #include "base/id_map.h" | 16 #include "base/id_map.h" |
17 #include "base/macros.h" | 17 #include "base/macros.h" |
18 #include "base/threading/thread_checker.h" | 18 #include "base/threading/thread_checker.h" |
19 #include "base/time/time.h" | 19 #include "base/time/time.h" |
20 #include "components/gcm_driver/instance_id/instance_id.h" | 20 #include "components/gcm_driver/instance_id/instance_id.h" |
21 | 21 |
22 namespace instance_id { | 22 namespace instance_id { |
23 | 23 |
24 // InstanceID implementation for Android. | 24 // InstanceID implementation for Android. |
25 class InstanceIDAndroid : public InstanceID { | 25 class InstanceIDAndroid : public InstanceID { |
26 public: | 26 public: |
27 // Register JNI methods. | 27 // Register JNI methods. |
28 static bool RegisterJni(JNIEnv* env); | 28 static bool RegisterJni(JNIEnv* env); |
29 | 29 |
| 30 // Tests depending on InstanceID that run without a nested Java message loop |
| 31 // must enable this. Operations that would normally be asynchronous will |
| 32 // instead block the UI thread. Reset it to false when tearing down. |
| 33 static void SetBlockOnAsyncTasksForTesting(bool block); |
| 34 |
30 InstanceIDAndroid(const std::string& app_id); | 35 InstanceIDAndroid(const std::string& app_id); |
31 ~InstanceIDAndroid() override; | 36 ~InstanceIDAndroid() override; |
32 | 37 |
33 // InstanceID implementation: | 38 // InstanceID implementation: |
34 void GetID(const GetIDCallback& callback) override; | 39 void GetID(const GetIDCallback& callback) override; |
35 void GetCreationTime(const GetCreationTimeCallback& callback) override; | 40 void GetCreationTime(const GetCreationTimeCallback& callback) override; |
36 void GetToken(const std::string& audience, | 41 void GetToken(const std::string& audience, |
37 const std::string& scope, | 42 const std::string& scope, |
38 const std::map<std::string, std::string>& options, | 43 const std::map<std::string, std::string>& options, |
39 const GetTokenCallback& callback) override; | 44 const GetTokenCallback& callback) override; |
(...skipping 24 matching lines...) Expand all Loading... |
64 IDMap<DeleteIDCallback, IDMapOwnPointer> delete_id_callbacks_; | 69 IDMap<DeleteIDCallback, IDMapOwnPointer> delete_id_callbacks_; |
65 | 70 |
66 base::ThreadChecker thread_checker_; | 71 base::ThreadChecker thread_checker_; |
67 | 72 |
68 DISALLOW_COPY_AND_ASSIGN(InstanceIDAndroid); | 73 DISALLOW_COPY_AND_ASSIGN(InstanceIDAndroid); |
69 }; | 74 }; |
70 | 75 |
71 } // namespace instance_id | 76 } // namespace instance_id |
72 | 77 |
73 #endif // COMPONENTS_GCM_DRIVER_INSTANCE_ID_INSTANCE_ID_ANDROID_H_ | 78 #endif // COMPONENTS_GCM_DRIVER_INSTANCE_ID_INSTANCE_ID_ANDROID_H_ |
OLD | NEW |