| 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/bind.h" | 13 #include "base/bind.h" |
| 14 #include "base/location.h" | 14 #include "base/location.h" |
| 15 #include "base/logging.h" | 15 #include "base/logging.h" |
| 16 #include "base/memory/scoped_ptr.h" | 16 #include "base/memory/scoped_ptr.h" |
| 17 #include "base/thread_task_runner_handle.h" | 17 #include "base/thread_task_runner_handle.h" |
| 18 #include "base/time/time.h" | 18 #include "base/time/time.h" |
| 19 #include "jni/InstanceIDBridge_jni.h" | 19 #include "jni/InstanceIDBridge_jni.h" |
| 20 | 20 |
| 21 using base::android::AttachCurrentThread; | 21 using base::android::AttachCurrentThread; |
| 22 using base::android::ConvertJavaStringToUTF8; | 22 using base::android::ConvertJavaStringToUTF8; |
| 23 using base::android::ConvertUTF8ToJavaString; | 23 using base::android::ConvertUTF8ToJavaString; |
| 24 | 24 |
| 25 namespace instance_id { | 25 namespace instance_id { |
| 26 | 26 |
| 27 InstanceIDAndroid::ScopedBlockOnAsyncTasksForTesting:: |
| 28 ScopedBlockOnAsyncTasksForTesting() { |
| 29 JNIEnv* env = AttachCurrentThread(); |
| 30 previous_value_ = |
| 31 Java_InstanceIDBridge_setBlockOnAsyncTasksForTesting(env, true); |
| 32 } |
| 33 |
| 34 InstanceIDAndroid::ScopedBlockOnAsyncTasksForTesting:: |
| 35 ~ScopedBlockOnAsyncTasksForTesting() { |
| 36 JNIEnv* env = AttachCurrentThread(); |
| 37 Java_InstanceIDBridge_setBlockOnAsyncTasksForTesting(env, previous_value_); |
| 38 } |
| 39 |
| 27 // static | 40 // static |
| 28 bool InstanceIDAndroid::RegisterJni(JNIEnv* env) { | 41 bool InstanceIDAndroid::RegisterJni(JNIEnv* env) { |
| 29 return RegisterNativesImpl(env); | 42 return RegisterNativesImpl(env); |
| 30 } | 43 } |
| 31 | 44 |
| 32 // static | 45 // static |
| 33 scoped_ptr<InstanceID> InstanceID::Create(const std::string& app_id, | 46 scoped_ptr<InstanceID> InstanceID::Create(const std::string& app_id, |
| 34 gcm::InstanceIDHandler* unused) { | 47 gcm::InstanceIDHandler* unused) { |
| 35 return make_scoped_ptr(new InstanceIDAndroid(app_id)); | 48 return make_scoped_ptr(new InstanceIDAndroid(app_id)); |
| 36 } | 49 } |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 169 jboolean success) { | 182 jboolean success) { |
| 170 DCHECK(thread_checker_.CalledOnValidThread()); | 183 DCHECK(thread_checker_.CalledOnValidThread()); |
| 171 | 184 |
| 172 DeleteIDCallback* callback = delete_id_callbacks_.Lookup(request_id); | 185 DeleteIDCallback* callback = delete_id_callbacks_.Lookup(request_id); |
| 173 DCHECK(callback); | 186 DCHECK(callback); |
| 174 callback->Run(success ? InstanceID::SUCCESS : InstanceID::UNKNOWN_ERROR); | 187 callback->Run(success ? InstanceID::SUCCESS : InstanceID::UNKNOWN_ERROR); |
| 175 delete_id_callbacks_.Remove(request_id); | 188 delete_id_callbacks_.Remove(request_id); |
| 176 } | 189 } |
| 177 | 190 |
| 178 } // namespace instance_id | 191 } // namespace instance_id |
| OLD | NEW |