OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/gcm_driver_android.h" | 5 #include "components/gcm_driver/gcm_driver_android.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include "base/android/context_utils.h" | 10 #include "base/android/context_utils.h" |
(...skipping 20 matching lines...) Expand all Loading... |
31 recorder_(this) { | 31 recorder_(this) { |
32 JNIEnv* env = AttachCurrentThread(); | 32 JNIEnv* env = AttachCurrentThread(); |
33 java_ref_.Reset( | 33 java_ref_.Reset( |
34 Java_GCMDriver_create(env, | 34 Java_GCMDriver_create(env, |
35 reinterpret_cast<intptr_t>(this), | 35 reinterpret_cast<intptr_t>(this), |
36 base::android::GetApplicationContext())); | 36 base::android::GetApplicationContext())); |
37 } | 37 } |
38 | 38 |
39 GCMDriverAndroid::~GCMDriverAndroid() { | 39 GCMDriverAndroid::~GCMDriverAndroid() { |
40 JNIEnv* env = AttachCurrentThread(); | 40 JNIEnv* env = AttachCurrentThread(); |
41 Java_GCMDriver_destroy(env, java_ref_.obj()); | 41 Java_GCMDriver_destroy(env, java_ref_); |
42 } | 42 } |
43 | 43 |
44 void GCMDriverAndroid::OnRegisterFinished( | 44 void GCMDriverAndroid::OnRegisterFinished( |
45 JNIEnv* env, | 45 JNIEnv* env, |
46 const JavaParamRef<jobject>& obj, | 46 const JavaParamRef<jobject>& obj, |
47 const JavaParamRef<jstring>& j_app_id, | 47 const JavaParamRef<jstring>& j_app_id, |
48 const JavaParamRef<jstring>& j_registration_id, | 48 const JavaParamRef<jstring>& j_registration_id, |
49 jboolean success) { | 49 jboolean success) { |
50 std::string app_id = ConvertJavaStringToUTF8(env, j_app_id); | 50 std::string app_id = ConvertJavaStringToUTF8(env, j_app_id); |
51 std::string registration_id = ConvertJavaStringToUTF8(env, j_registration_id); | 51 std::string registration_id = ConvertJavaStringToUTF8(env, j_registration_id); |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
226 return GCMClient::SUCCESS; | 226 return GCMClient::SUCCESS; |
227 } | 227 } |
228 | 228 |
229 void GCMDriverAndroid::RegisterImpl( | 229 void GCMDriverAndroid::RegisterImpl( |
230 const std::string& app_id, const std::vector<std::string>& sender_ids) { | 230 const std::string& app_id, const std::vector<std::string>& sender_ids) { |
231 DCHECK_EQ(1u, sender_ids.size()); | 231 DCHECK_EQ(1u, sender_ids.size()); |
232 JNIEnv* env = AttachCurrentThread(); | 232 JNIEnv* env = AttachCurrentThread(); |
233 | 233 |
234 recorder_.RecordRegistrationSent(app_id); | 234 recorder_.RecordRegistrationSent(app_id); |
235 | 235 |
236 Java_GCMDriver_register(env, java_ref_.obj(), | 236 Java_GCMDriver_register(env, java_ref_, ConvertUTF8ToJavaString(env, app_id), |
237 ConvertUTF8ToJavaString(env, app_id).obj(), | 237 ConvertUTF8ToJavaString(env, sender_ids[0])); |
238 ConvertUTF8ToJavaString(env, sender_ids[0]).obj()); | |
239 } | 238 } |
240 | 239 |
241 void GCMDriverAndroid::UnregisterImpl(const std::string& app_id) { | 240 void GCMDriverAndroid::UnregisterImpl(const std::string& app_id) { |
242 NOTREACHED(); | 241 NOTREACHED(); |
243 } | 242 } |
244 | 243 |
245 void GCMDriverAndroid::UnregisterWithSenderIdImpl( | 244 void GCMDriverAndroid::UnregisterWithSenderIdImpl( |
246 const std::string& app_id, | 245 const std::string& app_id, |
247 const std::string& sender_id) { | 246 const std::string& sender_id) { |
248 JNIEnv* env = AttachCurrentThread(); | 247 JNIEnv* env = AttachCurrentThread(); |
249 | 248 |
250 recorder_.RecordUnregistrationSent(app_id); | 249 recorder_.RecordUnregistrationSent(app_id); |
251 | 250 |
252 Java_GCMDriver_unregister(env, java_ref_.obj(), | 251 Java_GCMDriver_unregister(env, java_ref_, |
253 ConvertUTF8ToJavaString(env, app_id).obj(), | 252 ConvertUTF8ToJavaString(env, app_id), |
254 ConvertUTF8ToJavaString(env, sender_id).obj()); | 253 ConvertUTF8ToJavaString(env, sender_id)); |
255 } | 254 } |
256 | 255 |
257 void GCMDriverAndroid::SendImpl(const std::string& app_id, | 256 void GCMDriverAndroid::SendImpl(const std::string& app_id, |
258 const std::string& receiver_id, | 257 const std::string& receiver_id, |
259 const OutgoingMessage& message) { | 258 const OutgoingMessage& message) { |
260 NOTIMPLEMENTED(); | 259 NOTIMPLEMENTED(); |
261 } | 260 } |
262 | 261 |
263 void GCMDriverAndroid::RecordDecryptionFailure( | 262 void GCMDriverAndroid::RecordDecryptionFailure( |
264 const std::string& app_id, | 263 const std::string& app_id, |
265 GCMEncryptionProvider::DecryptionResult result) { | 264 GCMEncryptionProvider::DecryptionResult result) { |
266 recorder_.RecordDecryptionFailure(app_id, result); | 265 recorder_.RecordDecryptionFailure(app_id, result); |
267 } | 266 } |
268 | 267 |
269 } // namespace gcm | 268 } // namespace gcm |
OLD | NEW |