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" |
11 #include "base/android/jni_array.h" | 11 #include "base/android/jni_array.h" |
12 #include "base/android/jni_string.h" | 12 #include "base/android/jni_string.h" |
13 #include "base/logging.h" | 13 #include "base/logging.h" |
14 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
15 #include "base/time/time.h" | 15 #include "base/time/time.h" |
16 #include "jni/InstanceIDWithSubtype_jni.h" | 16 #include "jni/InstanceIDWithSubtype_jni.h" |
17 | 17 |
18 using base::android::AttachCurrentThread; | 18 using base::android::AttachCurrentThread; |
19 using base::android::ConvertJavaStringToUTF8; | 19 using base::android::ConvertJavaStringToUTF8; |
20 using base::android::ConvertUTF8ToJavaString; | 20 using base::android::ConvertUTF8ToJavaString; |
21 | 21 |
22 namespace instance_id { | 22 namespace instance_id { |
23 | 23 |
24 // static | 24 // static |
25 bool InstanceIDAndroid::RegisterBindings(JNIEnv* env) { | 25 bool InstanceIDAndroid::RegisterBindings(JNIEnv* env) { |
26 return RegisterNativesImpl(env); | 26 return RegisterNativesImpl(env); |
27 } | 27 } |
28 | 28 |
29 // static | 29 // static |
| 30 void InstanceIDAndroid::ClearDataAndSetUseFakeForTesting(bool use_fake) { |
| 31 JNIEnv* env = AttachCurrentThread(); |
| 32 Java_InstanceIDWithSubtype_clearDataAndSetUseFakeForTesting(env, use_fake); |
| 33 } |
| 34 |
| 35 // static |
30 scoped_ptr<InstanceID> InstanceID::Create(const std::string& app_id, | 36 scoped_ptr<InstanceID> InstanceID::Create(const std::string& app_id, |
31 gcm::InstanceIDHandler* unused) { | 37 gcm::InstanceIDHandler* unused) { |
32 return make_scoped_ptr(new InstanceIDAndroid(app_id)); | 38 return make_scoped_ptr(new InstanceIDAndroid(app_id)); |
33 } | 39 } |
34 | 40 |
35 InstanceIDAndroid::InstanceIDAndroid(const std::string& app_id) | 41 InstanceIDAndroid::InstanceIDAndroid(const std::string& app_id) |
36 : InstanceID(app_id) { | 42 : InstanceID(app_id) { |
37 DCHECK(thread_checker_.CalledOnValidThread()); | 43 DCHECK(thread_checker_.CalledOnValidThread()); |
38 | 44 |
39 DCHECK(!app_id.empty()) << "Empty app_id is not supported"; | 45 DCHECK(!app_id.empty()) << "Empty app_id is not supported"; |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 jboolean success) { | 162 jboolean success) { |
157 DCHECK(thread_checker_.CalledOnValidThread()); | 163 DCHECK(thread_checker_.CalledOnValidThread()); |
158 | 164 |
159 DeleteIDCallback* callback = delete_id_callbacks_.Lookup(request_id); | 165 DeleteIDCallback* callback = delete_id_callbacks_.Lookup(request_id); |
160 DCHECK(callback); | 166 DCHECK(callback); |
161 callback->Run(success ? InstanceID::SUCCESS : InstanceID::UNKNOWN_ERROR); | 167 callback->Run(success ? InstanceID::SUCCESS : InstanceID::UNKNOWN_ERROR); |
162 delete_id_callbacks_.Remove(request_id); | 168 delete_id_callbacks_.Remove(request_id); |
163 } | 169 } |
164 | 170 |
165 } // namespace instance_id | 171 } // namespace instance_id |
OLD | NEW |