Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(515)

Side by Side Diff: chrome/browser/invalidation/invalidation_service_factory_android.cc

Issue 2231923002: Make GetApplicationContext return a JavaRef. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Also fix not-currently-compiled unit test Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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::JavaParamRef; 15 using base::android::JavaParamRef;
16 using base::android::JavaRef;
16 using base::android::ScopedJavaLocalRef; 17 using base::android::ScopedJavaLocalRef;
17 18
18 namespace invalidation { 19 namespace invalidation {
19 20
20 ScopedJavaLocalRef<jobject> InvalidationServiceFactoryAndroid::GetForProfile( 21 ScopedJavaLocalRef<jobject> InvalidationServiceFactoryAndroid::GetForProfile(
21 JNIEnv* env, 22 const JavaRef<jobject>& j_profile) {
22 jclass clazz, 23 Profile* profile = ProfileAndroid::FromProfileAndroid(j_profile.obj());
23 jobject j_profile) {
24 Profile* profile = ProfileAndroid::FromProfileAndroid(j_profile);
25 invalidation::ProfileInvalidationProvider* provider = 24 invalidation::ProfileInvalidationProvider* provider =
26 ProfileInvalidationProviderFactory::GetForProfile(profile); 25 ProfileInvalidationProviderFactory::GetForProfile(profile);
27 InvalidationServiceAndroid* service_android = 26 InvalidationServiceAndroid* service_android =
28 static_cast<InvalidationServiceAndroid*>( 27 static_cast<InvalidationServiceAndroid*>(
29 provider->GetInvalidationService()); 28 provider->GetInvalidationService());
30 return ScopedJavaLocalRef<jobject>(service_android->java_ref_); 29 return ScopedJavaLocalRef<jobject>(service_android->java_ref_);
31 } 30 }
32 31
33 ScopedJavaLocalRef<jobject> InvalidationServiceFactoryAndroid::GetForTest( 32 ScopedJavaLocalRef<jobject> InvalidationServiceFactoryAndroid::GetForTest(
34 JNIEnv* env, 33 const JavaRef<jobject>& j_context) {
35 jclass clazz,
36 jobject j_context) {
37 InvalidationServiceAndroid* service_android = 34 InvalidationServiceAndroid* service_android =
38 new InvalidationServiceAndroid(j_context); 35 new InvalidationServiceAndroid(j_context);
39 return ScopedJavaLocalRef<jobject>(service_android->java_ref_); 36 return ScopedJavaLocalRef<jobject>(service_android->java_ref_);
40 } 37 }
41 38
42 ScopedJavaLocalRef<jobject> GetForProfile( 39 ScopedJavaLocalRef<jobject> GetForProfile(
43 JNIEnv* env, 40 JNIEnv* env,
44 const JavaParamRef<jclass>& clazz, 41 const JavaParamRef<jclass>& clazz,
45 const JavaParamRef<jobject>& j_profile) { 42 const JavaParamRef<jobject>& j_profile) {
46 return InvalidationServiceFactoryAndroid::GetForProfile(env, clazz, 43 return InvalidationServiceFactoryAndroid::GetForProfile(j_profile);
47 j_profile);
48 } 44 }
49 45
50 ScopedJavaLocalRef<jobject> GetForTest(JNIEnv* env, 46 ScopedJavaLocalRef<jobject> GetForTest(JNIEnv* env,
51 const JavaParamRef<jclass>& clazz, 47 const JavaParamRef<jclass>& clazz,
52 const JavaParamRef<jobject>& j_context) { 48 const JavaParamRef<jobject>& j_context) {
53 return InvalidationServiceFactoryAndroid::GetForTest(env, clazz, j_context); 49 return InvalidationServiceFactoryAndroid::GetForTest(j_context);
54 } 50 }
55 51
56 bool InvalidationServiceFactoryAndroid::Register(JNIEnv* env) { 52 bool InvalidationServiceFactoryAndroid::Register(JNIEnv* env) {
57 return RegisterNativesImpl(env); 53 return RegisterNativesImpl(env);
58 } 54 }
59 55
60 } // namespace invalidation 56 } // namespace invalidation
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698