| 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 <memory> | 9 #include <memory> |
| 10 | 10 |
| 11 #include "base/android/context_utils.h" | |
| 12 #include "base/android/jni_android.h" | 11 #include "base/android/jni_android.h" |
| 13 #include "base/android/jni_array.h" | 12 #include "base/android/jni_array.h" |
| 14 #include "base/android/jni_string.h" | 13 #include "base/android/jni_string.h" |
| 15 #include "base/bind.h" | 14 #include "base/bind.h" |
| 16 #include "base/location.h" | 15 #include "base/location.h" |
| 17 #include "base/logging.h" | 16 #include "base/logging.h" |
| 18 #include "base/memory/ptr_util.h" | 17 #include "base/memory/ptr_util.h" |
| 19 #include "base/threading/thread_task_runner_handle.h" | 18 #include "base/threading/thread_task_runner_handle.h" |
| 20 #include "base/time/time.h" | 19 #include "base/time/time.h" |
| 21 #include "jni/InstanceIDBridge_jni.h" | 20 #include "jni/InstanceIDBridge_jni.h" |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 | 57 |
| 59 DCHECK(!app_id.empty()) << "Empty app_id is not supported"; | 58 DCHECK(!app_id.empty()) << "Empty app_id is not supported"; |
| 60 // The |app_id| is stored in GCM's category field by the desktop InstanceID | 59 // The |app_id| is stored in GCM's category field by the desktop InstanceID |
| 61 // implementation, but because the category is reserved for the app's package | 60 // implementation, but because the category is reserved for the app's package |
| 62 // name on Android the subtype field is used instead. | 61 // name on Android the subtype field is used instead. |
| 63 std::string subtype = app_id; | 62 std::string subtype = app_id; |
| 64 | 63 |
| 65 JNIEnv* env = AttachCurrentThread(); | 64 JNIEnv* env = AttachCurrentThread(); |
| 66 java_ref_.Reset( | 65 java_ref_.Reset( |
| 67 Java_InstanceIDBridge_create(env, reinterpret_cast<intptr_t>(this), | 66 Java_InstanceIDBridge_create(env, reinterpret_cast<intptr_t>(this), |
| 68 base::android::GetApplicationContext(), | |
| 69 ConvertUTF8ToJavaString(env, subtype))); | 67 ConvertUTF8ToJavaString(env, subtype))); |
| 70 } | 68 } |
| 71 | 69 |
| 72 InstanceIDAndroid::~InstanceIDAndroid() { | 70 InstanceIDAndroid::~InstanceIDAndroid() { |
| 73 DCHECK(thread_checker_.CalledOnValidThread()); | 71 DCHECK(thread_checker_.CalledOnValidThread()); |
| 74 | 72 |
| 75 JNIEnv* env = AttachCurrentThread(); | 73 JNIEnv* env = AttachCurrentThread(); |
| 76 Java_InstanceIDBridge_destroy(env, java_ref_); | 74 Java_InstanceIDBridge_destroy(env, java_ref_); |
| 77 } | 75 } |
| 78 | 76 |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 225 jboolean success) { | 223 jboolean success) { |
| 226 DCHECK(thread_checker_.CalledOnValidThread()); | 224 DCHECK(thread_checker_.CalledOnValidThread()); |
| 227 | 225 |
| 228 DeleteIDCallback* callback = delete_id_callbacks_.Lookup(request_id); | 226 DeleteIDCallback* callback = delete_id_callbacks_.Lookup(request_id); |
| 229 DCHECK(callback); | 227 DCHECK(callback); |
| 230 callback->Run(success ? InstanceID::SUCCESS : InstanceID::UNKNOWN_ERROR); | 228 callback->Run(success ? InstanceID::SUCCESS : InstanceID::UNKNOWN_ERROR); |
| 231 delete_id_callbacks_.Remove(request_id); | 229 delete_id_callbacks_.Remove(request_id); |
| 232 } | 230 } |
| 233 | 231 |
| 234 } // namespace instance_id | 232 } // namespace instance_id |
| OLD | NEW |