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 #include "components/gcm_driver/instance_id/instance_id_android.h" | 5 #include "components/gcm_driver/instance_id/instance_id_android.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include "base/android/context_utils.h" | 9 #include "base/android/context_utils.h" |
10 #include "base/android/jni_android.h" | 10 #include "base/android/jni_android.h" |
(...skipping 12 matching lines...) Expand all Loading... |
23 using base::android::ConvertUTF8ToJavaString; | 23 using base::android::ConvertUTF8ToJavaString; |
24 | 24 |
25 namespace instance_id { | 25 namespace instance_id { |
26 | 26 |
27 // static | 27 // static |
28 bool InstanceIDAndroid::RegisterJni(JNIEnv* env) { | 28 bool InstanceIDAndroid::RegisterJni(JNIEnv* env) { |
29 return RegisterNativesImpl(env); | 29 return RegisterNativesImpl(env); |
30 } | 30 } |
31 | 31 |
32 // static | 32 // static |
| 33 void InstanceIDAndroid::SetBlockOnAsyncTasksForTesting(bool block) { |
| 34 JNIEnv* env = AttachCurrentThread(); |
| 35 Java_InstanceIDBridge_setBlockOnAsyncTasksForTesting(env, block); |
| 36 } |
| 37 |
| 38 // static |
33 scoped_ptr<InstanceID> InstanceID::Create(const std::string& app_id, | 39 scoped_ptr<InstanceID> InstanceID::Create(const std::string& app_id, |
34 gcm::InstanceIDHandler* unused) { | 40 gcm::InstanceIDHandler* unused) { |
35 return make_scoped_ptr(new InstanceIDAndroid(app_id)); | 41 return make_scoped_ptr(new InstanceIDAndroid(app_id)); |
36 } | 42 } |
37 | 43 |
38 InstanceIDAndroid::InstanceIDAndroid(const std::string& app_id) | 44 InstanceIDAndroid::InstanceIDAndroid(const std::string& app_id) |
39 : InstanceID(app_id) { | 45 : InstanceID(app_id) { |
40 DCHECK(thread_checker_.CalledOnValidThread()); | 46 DCHECK(thread_checker_.CalledOnValidThread()); |
41 | 47 |
42 DCHECK(!app_id.empty()) << "Empty app_id is not supported"; | 48 DCHECK(!app_id.empty()) << "Empty app_id is not supported"; |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
169 jboolean success) { | 175 jboolean success) { |
170 DCHECK(thread_checker_.CalledOnValidThread()); | 176 DCHECK(thread_checker_.CalledOnValidThread()); |
171 | 177 |
172 DeleteIDCallback* callback = delete_id_callbacks_.Lookup(request_id); | 178 DeleteIDCallback* callback = delete_id_callbacks_.Lookup(request_id); |
173 DCHECK(callback); | 179 DCHECK(callback); |
174 callback->Run(success ? InstanceID::SUCCESS : InstanceID::UNKNOWN_ERROR); | 180 callback->Run(success ? InstanceID::SUCCESS : InstanceID::UNKNOWN_ERROR); |
175 delete_id_callbacks_.Remove(request_id); | 181 delete_id_callbacks_.Remove(request_id); |
176 } | 182 } |
177 | 183 |
178 } // namespace instance_id | 184 } // namespace instance_id |
OLD | NEW |