| 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 "chrome/browser/invalidation/invalidation_service_factory_android.h" | 5 #include "chrome/browser/invalidation/invalidation_service_factory_android.h" |
| 6 | 6 |
| 7 #include "base/android/jni_android.h" | 7 #include "base/android/jni_android.h" |
| 8 #include "chrome/browser/invalidation/profile_invalidation_provider_factory.h" | 8 #include "chrome/browser/invalidation/profile_invalidation_provider_factory.h" |
| 9 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
| 10 #include "chrome/browser/profiles/profile_android.h" | 10 #include "chrome/browser/profiles/profile_android.h" |
| 11 #include "components/invalidation/impl/invalidation_service_android.h" | 11 #include "components/invalidation/impl/invalidation_service_android.h" |
| 12 #include "components/invalidation/impl/profile_invalidation_provider.h" | 12 #include "components/invalidation/impl/profile_invalidation_provider.h" |
| 13 #include "jni/InvalidationServiceFactory_jni.h" | 13 #include "jni/InvalidationServiceFactory_jni.h" |
| 14 | 14 |
| 15 using base::android::ScopedJavaLocalRef; | 15 using base::android::ScopedJavaLocalRef; |
| 16 | 16 |
| 17 namespace invalidation { | 17 namespace invalidation { |
| 18 | 18 |
| 19 ScopedJavaLocalRef<jobject> InvalidationServiceFactoryAndroid::GetForProfile( | 19 jobject InvalidationServiceFactoryAndroid::GetForProfile(JNIEnv* env, |
| 20 JNIEnv* env, | 20 jclass clazz, |
| 21 jclass clazz, | 21 jobject j_profile) { |
| 22 jobject j_profile) { | |
| 23 Profile* profile = ProfileAndroid::FromProfileAndroid(j_profile); | 22 Profile* profile = ProfileAndroid::FromProfileAndroid(j_profile); |
| 24 invalidation::ProfileInvalidationProvider* provider = | 23 invalidation::ProfileInvalidationProvider* provider = |
| 25 ProfileInvalidationProviderFactory::GetForProfile(profile); | 24 ProfileInvalidationProviderFactory::GetForProfile(profile); |
| 26 InvalidationServiceAndroid* service_android = | 25 InvalidationServiceAndroid* service_android = |
| 27 static_cast<InvalidationServiceAndroid*>( | 26 static_cast<InvalidationServiceAndroid*>( |
| 28 provider->GetInvalidationService()); | 27 provider->GetInvalidationService()); |
| 29 return ScopedJavaLocalRef<jobject>(service_android->java_ref_); | 28 return service_android->java_ref_.obj(); |
| 30 } | 29 } |
| 31 | 30 |
| 32 ScopedJavaLocalRef<jobject> InvalidationServiceFactoryAndroid::GetForTest( | 31 jobject InvalidationServiceFactoryAndroid::GetForTest(JNIEnv* env, |
| 33 JNIEnv* env, | 32 jclass clazz, |
| 34 jclass clazz, | 33 jobject j_context) { |
| 35 jobject j_context) { | |
| 36 InvalidationServiceAndroid* service_android = | 34 InvalidationServiceAndroid* service_android = |
| 37 new InvalidationServiceAndroid(j_context); | 35 new InvalidationServiceAndroid(j_context); |
| 38 return ScopedJavaLocalRef<jobject>(service_android->java_ref_); | 36 return service_android->java_ref_.obj(); |
| 39 } | 37 } |
| 40 | 38 |
| 41 ScopedJavaLocalRef<jobject> GetForProfile(JNIEnv* env, | 39 jobject GetForProfile(JNIEnv* env, jclass clazz, jobject j_profile) { |
| 42 jclass clazz, | 40 return InvalidationServiceFactoryAndroid::GetForProfile( |
| 43 jobject j_profile) { | 41 env, clazz, j_profile); |
| 44 return InvalidationServiceFactoryAndroid::GetForProfile(env, clazz, | |
| 45 j_profile); | |
| 46 } | 42 } |
| 47 | 43 |
| 48 ScopedJavaLocalRef<jobject> GetForTest(JNIEnv* env, | 44 jobject GetForTest(JNIEnv* env, jclass clazz, jobject j_context) { |
| 49 jclass clazz, | 45 return InvalidationServiceFactoryAndroid::GetForTest( |
| 50 jobject j_context) { | 46 env, clazz, j_context); |
| 51 return InvalidationServiceFactoryAndroid::GetForTest(env, clazz, j_context); | |
| 52 } | 47 } |
| 53 | 48 |
| 54 bool InvalidationServiceFactoryAndroid::Register(JNIEnv* env) { | 49 bool InvalidationServiceFactoryAndroid::Register(JNIEnv* env) { |
| 55 return RegisterNativesImpl(env); | 50 return RegisterNativesImpl(env); |
| 56 } | 51 } |
| 57 | 52 |
| 58 } // namespace invalidation | 53 } // namespace invalidation |
| OLD | NEW |