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 |
(...skipping 20 matching lines...) Expand all Loading... |
31 previous_value_ = | 31 previous_value_ = |
32 Java_InstanceIDBridge_setBlockOnAsyncTasksForTesting(env, true); | 32 Java_InstanceIDBridge_setBlockOnAsyncTasksForTesting(env, true); |
33 } | 33 } |
34 | 34 |
35 InstanceIDAndroid::ScopedBlockOnAsyncTasksForTesting:: | 35 InstanceIDAndroid::ScopedBlockOnAsyncTasksForTesting:: |
36 ~ScopedBlockOnAsyncTasksForTesting() { | 36 ~ScopedBlockOnAsyncTasksForTesting() { |
37 JNIEnv* env = AttachCurrentThread(); | 37 JNIEnv* env = AttachCurrentThread(); |
38 Java_InstanceIDBridge_setBlockOnAsyncTasksForTesting(env, previous_value_); | 38 Java_InstanceIDBridge_setBlockOnAsyncTasksForTesting(env, previous_value_); |
39 } | 39 } |
40 | 40 |
41 // static | |
42 std::unique_ptr<InstanceID> InstanceID::CreateInternal( | |
43 const std::string& app_id, | |
44 gcm::GCMDriver* gcm_driver) { | |
45 return base::WrapUnique(new InstanceIDAndroid(app_id, gcm_driver)); | |
46 } | |
47 | |
48 InstanceIDAndroid::InstanceIDAndroid(const std::string& app_id, | 41 InstanceIDAndroid::InstanceIDAndroid(const std::string& app_id, |
49 gcm::GCMDriver* gcm_driver) | 42 gcm::GCMDriver* gcm_driver) |
50 : InstanceID(app_id, gcm_driver) { | 43 : InstanceID(app_id, gcm_driver) { |
51 DCHECK(thread_checker_.CalledOnValidThread()); | 44 DCHECK(thread_checker_.CalledOnValidThread()); |
52 | 45 |
53 DCHECK(!app_id.empty()) << "Empty app_id is not supported"; | 46 DCHECK(!app_id.empty()) << "Empty app_id is not supported"; |
54 // The |app_id| is stored in GCM's category field by the desktop InstanceID | 47 // The |app_id| is stored in GCM's category field by the desktop InstanceID |
55 // implementation, but because the category is reserved for the app's package | 48 // implementation, but because the category is reserved for the app's package |
56 // name on Android the subtype field is used instead. | 49 // name on Android the subtype field is used instead. |
57 std::string subtype = app_id; | 50 std::string subtype = app_id; |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
218 jboolean success) { | 211 jboolean success) { |
219 DCHECK(thread_checker_.CalledOnValidThread()); | 212 DCHECK(thread_checker_.CalledOnValidThread()); |
220 | 213 |
221 DeleteIDCallback* callback = delete_id_callbacks_.Lookup(request_id); | 214 DeleteIDCallback* callback = delete_id_callbacks_.Lookup(request_id); |
222 DCHECK(callback); | 215 DCHECK(callback); |
223 callback->Run(success ? InstanceID::SUCCESS : InstanceID::UNKNOWN_ERROR); | 216 callback->Run(success ? InstanceID::SUCCESS : InstanceID::UNKNOWN_ERROR); |
224 delete_id_callbacks_.Remove(request_id); | 217 delete_id_callbacks_.Remove(request_id); |
225 } | 218 } |
226 | 219 |
227 } // namespace instance_id | 220 } // namespace instance_id |
OLD | NEW |