| 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" | |
| 11 #include "base/android/jni_android.h" | 10 #include "base/android/jni_android.h" |
| 12 #include "base/android/jni_array.h" | 11 #include "base/android/jni_array.h" |
| 13 #include "base/android/jni_string.h" | 12 #include "base/android/jni_string.h" |
| 14 #include "base/compiler_specific.h" | 13 #include "base/compiler_specific.h" |
| 15 #include "base/logging.h" | 14 #include "base/logging.h" |
| 16 #include "base/threading/thread_task_runner_handle.h" | 15 #include "base/threading/thread_task_runner_handle.h" |
| 17 #include "jni/GCMDriver_jni.h" | 16 #include "jni/GCMDriver_jni.h" |
| 18 | 17 |
| 19 using base::android::AppendJavaStringArrayToStringVector; | 18 using base::android::AppendJavaStringArrayToStringVector; |
| 20 using base::android::AttachCurrentThread; | 19 using base::android::AttachCurrentThread; |
| 21 using base::android::ConvertJavaStringToUTF8; | 20 using base::android::ConvertJavaStringToUTF8; |
| 22 using base::android::ConvertUTF8ToJavaString; | 21 using base::android::ConvertUTF8ToJavaString; |
| 23 using base::android::JavaByteArrayToByteVector; | 22 using base::android::JavaByteArrayToByteVector; |
| 24 using base::android::JavaParamRef; | 23 using base::android::JavaParamRef; |
| 25 | 24 |
| 26 namespace gcm { | 25 namespace gcm { |
| 27 | 26 |
| 28 GCMDriverAndroid::GCMDriverAndroid( | 27 GCMDriverAndroid::GCMDriverAndroid( |
| 29 const base::FilePath& store_path, | 28 const base::FilePath& store_path, |
| 30 const scoped_refptr<base::SequencedTaskRunner>& blocking_task_runner) | 29 const scoped_refptr<base::SequencedTaskRunner>& blocking_task_runner) |
| 31 : GCMDriver(store_path, blocking_task_runner), | 30 : GCMDriver(store_path, blocking_task_runner), |
| 32 recorder_(this) { | 31 recorder_(this) { |
| 33 JNIEnv* env = AttachCurrentThread(); | 32 JNIEnv* env = AttachCurrentThread(); |
| 34 java_ref_.Reset( | 33 java_ref_.Reset(Java_GCMDriver_create(env, reinterpret_cast<intptr_t>(this))); |
| 35 Java_GCMDriver_create(env, | |
| 36 reinterpret_cast<intptr_t>(this), | |
| 37 base::android::GetApplicationContext())); | |
| 38 } | 34 } |
| 39 | 35 |
| 40 GCMDriverAndroid::~GCMDriverAndroid() { | 36 GCMDriverAndroid::~GCMDriverAndroid() { |
| 41 JNIEnv* env = AttachCurrentThread(); | 37 JNIEnv* env = AttachCurrentThread(); |
| 42 Java_GCMDriver_destroy(env, java_ref_); | 38 Java_GCMDriver_destroy(env, java_ref_); |
| 43 } | 39 } |
| 44 | 40 |
| 45 void GCMDriverAndroid::OnRegisterFinished( | 41 void GCMDriverAndroid::OnRegisterFinished( |
| 46 JNIEnv* env, | 42 JNIEnv* env, |
| 47 const JavaParamRef<jobject>& obj, | 43 const JavaParamRef<jobject>& obj, |
| (...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 271 NOTIMPLEMENTED(); | 267 NOTIMPLEMENTED(); |
| 272 } | 268 } |
| 273 | 269 |
| 274 void GCMDriverAndroid::RecordDecryptionFailure( | 270 void GCMDriverAndroid::RecordDecryptionFailure( |
| 275 const std::string& app_id, | 271 const std::string& app_id, |
| 276 GCMEncryptionProvider::DecryptionResult result) { | 272 GCMEncryptionProvider::DecryptionResult result) { |
| 277 recorder_.RecordDecryptionFailure(app_id, result); | 273 recorder_.RecordDecryptionFailure(app_id, result); |
| 278 } | 274 } |
| 279 | 275 |
| 280 } // namespace gcm | 276 } // namespace gcm |
| OLD | NEW |