Chromium Code Reviews| Index: chrome/browser/invalidation/invalidation_service_factory_android.cc |
| diff --git a/chrome/browser/invalidation/invalidation_service_factory_android.cc b/chrome/browser/invalidation/invalidation_service_factory_android.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..4f6b55cd98c7cd7181945c1897b07b5c080be878 |
| --- /dev/null |
| +++ b/chrome/browser/invalidation/invalidation_service_factory_android.cc |
| @@ -0,0 +1,53 @@ |
| +// Copyright 2014 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "chrome/browser/invalidation/invalidation_service_factory_android.h" |
| + |
| +#include "base/android/jni_android.h" |
| +#include "chrome/browser/invalidation/profile_invalidation_provider_factory.h" |
| +#include "chrome/browser/profiles/profile.h" |
| +#include "chrome/browser/profiles/profile_android.h" |
| +#include "components/invalidation/invalidation_service_android.h" |
| +#include "components/invalidation/profile_invalidation_provider.h" |
| +#include "jni/InvalidationServiceFactory_jni.h" |
| + |
| +using base::android::ScopedJavaLocalRef; |
| + |
| +namespace invalidation { |
| + |
| +jobject InvalidationServiceFactoryAndroid::GetForProfile(JNIEnv* env, |
| + jclass clazz, |
| + jobject j_profile) { |
| + Profile* profile = ProfileAndroid::FromProfileAndroid(j_profile); |
| + invalidation::ProfileInvalidationProvider* provider = |
| + ProfileInvalidationProviderFactory::GetForProfile(profile); |
|
nyquist
2014/09/04 09:01:55
Can this in any way return NULL? Or is this always
maxbogue
2014/09/05 16:42:45
Looks like it can only be NULL if your platform do
|
| + InvalidationServiceAndroid* service_android = |
| + static_cast<InvalidationServiceAndroid*>( |
| + provider->GetInvalidationService()); |
| + return service_android->java_ref_.obj(); |
| +} |
| + |
| +jobject InvalidationServiceFactoryAndroid::GetForTest(JNIEnv* env, |
| + jclass clazz, |
| + jobject j_context) { |
| + InvalidationServiceAndroid* service_android = |
| + new InvalidationServiceAndroid(j_context); |
| + return service_android->java_ref_.obj(); |
| +} |
| + |
| +jobject GetForProfile(JNIEnv* env, jclass clazz, jobject j_profile) { |
|
nyquist
2014/09/04 09:01:56
If you want to do community work, feel free to add
maxbogue
2014/09/05 16:42:45
Acknowledged.
|
| + return InvalidationServiceFactoryAndroid::GetForProfile( |
| + env, clazz, j_profile); |
| +} |
| + |
| +jobject GetForTest(JNIEnv* env, jclass clazz, jobject j_context) { |
| + return InvalidationServiceFactoryAndroid::GetForTest( |
| + env, clazz, j_context); |
| +} |
| + |
| +bool InvalidationServiceFactoryAndroid::Register(JNIEnv* env) { |
| + return RegisterNativesImpl(env); |
| +} |
| + |
| +} // namespace invalidation |