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" |
(...skipping 11 matching lines...) Expand all Loading... |
22 const JavaRef<jobject>& j_profile) { | 22 const JavaRef<jobject>& j_profile) { |
23 Profile* profile = ProfileAndroid::FromProfileAndroid(j_profile.obj()); | 23 Profile* profile = ProfileAndroid::FromProfileAndroid(j_profile.obj()); |
24 invalidation::ProfileInvalidationProvider* provider = | 24 invalidation::ProfileInvalidationProvider* provider = |
25 ProfileInvalidationProviderFactory::GetForProfile(profile); | 25 ProfileInvalidationProviderFactory::GetForProfile(profile); |
26 InvalidationServiceAndroid* service_android = | 26 InvalidationServiceAndroid* service_android = |
27 static_cast<InvalidationServiceAndroid*>( | 27 static_cast<InvalidationServiceAndroid*>( |
28 provider->GetInvalidationService()); | 28 provider->GetInvalidationService()); |
29 return ScopedJavaLocalRef<jobject>(service_android->java_ref_); | 29 return ScopedJavaLocalRef<jobject>(service_android->java_ref_); |
30 } | 30 } |
31 | 31 |
32 ScopedJavaLocalRef<jobject> InvalidationServiceFactoryAndroid::GetForTest() { | 32 ScopedJavaLocalRef<jobject> InvalidationServiceFactoryAndroid::GetForTest( |
| 33 const JavaRef<jobject>& j_context) { |
33 InvalidationServiceAndroid* service_android = | 34 InvalidationServiceAndroid* service_android = |
34 new InvalidationServiceAndroid(); | 35 new InvalidationServiceAndroid(j_context); |
35 return ScopedJavaLocalRef<jobject>(service_android->java_ref_); | 36 return ScopedJavaLocalRef<jobject>(service_android->java_ref_); |
36 } | 37 } |
37 | 38 |
38 ScopedJavaLocalRef<jobject> GetForProfile( | 39 ScopedJavaLocalRef<jobject> GetForProfile( |
39 JNIEnv* env, | 40 JNIEnv* env, |
40 const JavaParamRef<jclass>& clazz, | 41 const JavaParamRef<jclass>& clazz, |
41 const JavaParamRef<jobject>& j_profile) { | 42 const JavaParamRef<jobject>& j_profile) { |
42 return InvalidationServiceFactoryAndroid::GetForProfile(j_profile); | 43 return InvalidationServiceFactoryAndroid::GetForProfile(j_profile); |
43 } | 44 } |
44 | 45 |
45 ScopedJavaLocalRef<jobject> GetForTest(JNIEnv* env, | 46 ScopedJavaLocalRef<jobject> GetForTest(JNIEnv* env, |
46 const JavaParamRef<jclass>& clazz) { | 47 const JavaParamRef<jclass>& clazz, |
47 return InvalidationServiceFactoryAndroid::GetForTest(); | 48 const JavaParamRef<jobject>& j_context) { |
| 49 return InvalidationServiceFactoryAndroid::GetForTest(j_context); |
48 } | 50 } |
49 | 51 |
50 bool InvalidationServiceFactoryAndroid::Register(JNIEnv* env) { | 52 bool InvalidationServiceFactoryAndroid::Register(JNIEnv* env) { |
51 return RegisterNativesImpl(env); | 53 return RegisterNativesImpl(env); |
52 } | 54 } |
53 | 55 |
54 } // namespace invalidation | 56 } // namespace invalidation |
OLD | NEW |