summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjohnme@chromium.org <johnme@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-05-15 23:14:05 +0000
committerjohnme@chromium.org <johnme@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-05-15 23:14:05 +0000
commitd8e44d2003c444c0f79ccc4246291aaecc51b4f9 (patch)
treee11e9bb153d9eb4c10f17d3233df94c54d40dd7b
parent5c013d57cdb697c21f1a3372cfc75a24f1e13539 (diff)
downloadchromium_src-d8e44d2003c444c0f79ccc4246291aaecc51b4f9.zip
chromium_src-d8e44d2003c444c0f79ccc4246291aaecc51b4f9.tar.gz
chromium_src-d8e44d2003c444c0f79ccc4246291aaecc51b4f9.tar.bz2
Hook components/gcm_driver up to JNI Generator
(modelled on https://codereview.chromium.org/183893029) This will be used when implementing GCMDriverAndroid. BUG=350384 Review URL: https://codereview.chromium.org/285203005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@270843 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/android/chrome_jni_registrar.cc2
-rw-r--r--chrome/chrome.gyp1
-rw-r--r--components/gcm_driver.gypi40
-rw-r--r--components/gcm_driver/DEPS1
-rw-r--r--components/gcm_driver/android/component_jni_registrar.cc29
-rw-r--r--components/gcm_driver/android/component_jni_registrar.h21
-rw-r--r--components/gcm_driver/android/java/src/org/chromium/components/gcm_driver/GCMDriver.java22
-rw-r--r--components/gcm_driver/gcm_driver_android.cc23
-rw-r--r--components/gcm_driver/gcm_driver_android.h20
9 files changed, 159 insertions, 0 deletions
diff --git a/chrome/browser/android/chrome_jni_registrar.cc b/chrome/browser/android/chrome_jni_registrar.cc
index e0c17fc..9f3a30e 100644
--- a/chrome/browser/android/chrome_jni_registrar.cc
+++ b/chrome/browser/android/chrome_jni_registrar.cc
@@ -67,6 +67,7 @@
#include "chrome/browser/ui/android/website_settings_popup_android.h"
#include "components/autofill/core/browser/android/component_jni_registrar.h"
#include "components/dom_distiller/android/component_jni_registrar.h"
+#include "components/gcm_driver/android/component_jni_registrar.h"
#include "components/navigation_interception/component_jni_registrar.h"
#include "components/web_contents_delegate_android/component_jni_registrar.h"
@@ -82,6 +83,7 @@ namespace android {
static base::android::RegistrationMethod kChromeRegisteredMethods[] = {
// Register JNI for components we depend on.
{ "DomDistiller", dom_distiller::android::RegisterDomDistiller },
+ { "GCMDriver", gcm::android::RegisterGCMDriverJni },
{ "NavigationInterception",
navigation_interception::RegisterNavigationInterceptionJni },
{ "WebContentsDelegateAndroid",
diff --git a/chrome/chrome.gyp b/chrome/chrome.gyp
index b68fa71..19609cc 100644
--- a/chrome/chrome.gyp
+++ b/chrome/chrome.gyp
@@ -734,6 +734,7 @@
'../base/base.gyp:base',
'../components/components.gyp:autofill_java',
'../components/components.gyp:dom_distiller_core_java',
+ '../components/components.gyp:gcm_driver_java',
'../components/components.gyp:navigation_interception_java',
'../components/components.gyp:sessions',
'../components/components.gyp:web_contents_delegate_android_java',
diff --git a/components/gcm_driver.gypi b/components/gcm_driver.gypi
index 489a710..4d42b6a 100644
--- a/components/gcm_driver.gypi
+++ b/components/gcm_driver.gypi
@@ -16,14 +16,54 @@
'..',
],
'sources': [
+ 'gcm_driver/android/component_jni_registrar.cc',
+ 'gcm_driver/android/component_jni_registrar.h',
'gcm_driver/default_gcm_app_handler.cc',
'gcm_driver/default_gcm_app_handler.h',
'gcm_driver/gcm_app_handler.h',
'gcm_driver/gcm_client_factory.cc',
'gcm_driver/gcm_client_factory.h',
+ 'gcm_driver/gcm_driver_android.cc',
+ 'gcm_driver/gcm_driver_android.h',
'gcm_driver/system_encryptor.cc',
'gcm_driver/system_encryptor.h',
],
+ 'conditions': [
+ ['OS == "android"', {
+ 'dependencies': [
+ 'gcm_driver_jni_headers',
+ ],
+ }],
+ ],
},
],
+ 'conditions': [
+ ['OS == "android"', {
+ 'targets': [
+ {
+ 'target_name': 'gcm_driver_java',
+ 'type': 'none',
+ 'dependencies': [
+ '../base/base.gyp:base',
+ ],
+ 'variables': {
+ 'java_in_dir': 'gcm_driver/android/java',
+ },
+ 'includes': [ '../build/java.gypi' ],
+ },
+ {
+ 'target_name': 'gcm_driver_jni_headers',
+ 'type': 'none',
+ 'sources': [
+ 'gcm_driver/android/java/src/org/chromium/components/gcm_driver/GCMDriver.java',
+ ],
+ 'variables': {
+ 'jni_gen_package': 'components/gcm_driver',
+ },
+ 'includes': [ '../build/jni_generator.gypi' ],
+ },
+ ],
+ },
+ ],
+ ],
}
diff --git a/components/gcm_driver/DEPS b/components/gcm_driver/DEPS
index b69f312..b8c50da 100644
--- a/components/gcm_driver/DEPS
+++ b/components/gcm_driver/DEPS
@@ -1,4 +1,5 @@
include_rules = [
"+components/os_crypt",
"+google_apis/gcm",
+ "+jni",
]
diff --git a/components/gcm_driver/android/component_jni_registrar.cc b/components/gcm_driver/android/component_jni_registrar.cc
new file mode 100644
index 0000000..e26336a
--- /dev/null
+++ b/components/gcm_driver/android/component_jni_registrar.cc
@@ -0,0 +1,29 @@
+// 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 "components/gcm_driver/android/component_jni_registrar.h"
+
+#include "base/android/jni_android.h"
+#include "base/android/jni_registrar.h"
+#include "base/basictypes.h"
+#include "components/gcm_driver/gcm_driver_android.h"
+
+namespace gcm {
+
+namespace android {
+
+static base::android::RegistrationMethod kGCMDriverRegisteredMethods[] = {
+ {"GCMDriver", gcm::GCMDriverAndroid::RegisterBindings},
+};
+
+bool RegisterGCMDriverJni(JNIEnv* env) {
+ return base::android::RegisterNativeMethods(
+ env,
+ kGCMDriverRegisteredMethods,
+ arraysize(kGCMDriverRegisteredMethods));
+}
+
+} // namespace android
+
+} // namespace gcm
diff --git a/components/gcm_driver/android/component_jni_registrar.h b/components/gcm_driver/android/component_jni_registrar.h
new file mode 100644
index 0000000..b2a67c4
--- /dev/null
+++ b/components/gcm_driver/android/component_jni_registrar.h
@@ -0,0 +1,21 @@
+// 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.
+
+#ifndef COMPONENTS_GCM_DRIVER_ANDROID_COMPONENT_JNI_REGISTRAR_H_
+#define COMPONENTS_GCM_DRIVER_ANDROID_COMPONENT_JNI_REGISTRAR_H_
+
+#include <jni.h>
+
+namespace gcm {
+
+namespace android {
+
+// Register all JNI bindings necessary for the gcm_driver component.
+bool RegisterGCMDriverJni(JNIEnv* env);
+
+} // namespace android
+
+} // namespace gcm
+
+#endif // COMPONENTS_GCM_DRIVER_ANDROID_COMPONENT_JNI_REGISTRAR_H_
diff --git a/components/gcm_driver/android/java/src/org/chromium/components/gcm_driver/GCMDriver.java b/components/gcm_driver/android/java/src/org/chromium/components/gcm_driver/GCMDriver.java
new file mode 100644
index 0000000..13b9752
--- /dev/null
+++ b/components/gcm_driver/android/java/src/org/chromium/components/gcm_driver/GCMDriver.java
@@ -0,0 +1,22 @@
+// 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.
+
+package org.chromium.components.gcm_driver;
+
+import org.chromium.base.CalledByNative;
+import org.chromium.base.JNINamespace;
+
+/**
+ * This will provide an implementation of GCMDriver using the Java GCM APIs.
+ */
+@JNINamespace("gcm")
+public final class GCMDriver {
+ /*
+ * JNI Generator complains if there are no methods exposed to JNI.
+ * TODO(johnme): Replace this with something useful.
+ */
+ @CalledByNative
+ private static void doNothing() {
+ }
+} \ No newline at end of file
diff --git a/components/gcm_driver/gcm_driver_android.cc b/components/gcm_driver/gcm_driver_android.cc
new file mode 100644
index 0000000..e7ae955
--- /dev/null
+++ b/components/gcm_driver/gcm_driver_android.cc
@@ -0,0 +1,23 @@
+// 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 "components/gcm_driver/gcm_driver_android.h"
+
+#include "base/compiler_specific.h"
+
+namespace gcm {
+static void Java_GCMDriver_doNothing(JNIEnv* env) ALLOW_UNUSED;
+} // namespace gcm
+
+// Must come after the ALLOW_UNUSED declaration.
+#include "jni/GCMDriver_jni.h"
+
+namespace gcm {
+
+// static
+bool GCMDriverAndroid::RegisterBindings(JNIEnv* env) {
+ return RegisterNativesImpl(env);
+}
+
+} // namespace gcm \ No newline at end of file
diff --git a/components/gcm_driver/gcm_driver_android.h b/components/gcm_driver/gcm_driver_android.h
new file mode 100644
index 0000000..653a4f2
--- /dev/null
+++ b/components/gcm_driver/gcm_driver_android.h
@@ -0,0 +1,20 @@
+// 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.
+
+#ifndef COMPONENTS_GCM_DRIVER_GCM_DRIVER_ANDROID_H
+#define COMPONENTS_GCM_DRIVER_GCM_DRIVER_ANDROID_H
+
+#include <jni.h>
+
+namespace gcm {
+
+class GCMDriverAndroid {
+ public:
+ // Register JNI methods
+ static bool RegisterBindings(JNIEnv* env);
+};
+
+} // namespace gcm
+
+#endif // COMPONENTS_GCM_DRIVER_GCM_DRIVER_ANDROID_H \ No newline at end of file