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

Side by Side Diff: android_webview/native/callback_jni_bridge.h

Issue 12313042: [android_webview] Add a generic callback JNI bridge. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 10 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 | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef ANDROID_WEBVIEW_NATIVE_JAVA_CALLBACK_BRIDGE_H_
6 #define ANDROID_WEBVIEW_NATIVE_JAVA_CALLBACK_BRIDGE_H_
7
8 #include "base/callback.h"
9 #include "base/android/jni_android.h"
10 #include "base/android/scoped_java_ref.h"
11
12 namespace android_webview {
13
14 class CallbackJNIBridge {
15 public:
16 // Creates a base::Callback the Run() method of which will delegate to the
17 // onReceiveValue method of the Java-side |value_callback| object.
18 //
19 // The returned callback will hold a global reference to the Java object, so
20 // this method should be used with short-lived callbacks only.
21 static base::Callback<void(int)> FromJavaValueCallbackInt(
22 JNIEnv* env,
23 base::android::ScopedJavaLocalRef<jobject> value_callback);
24
25 // Creates a Java object (an instance that implements the ValueCallback<Int>
26 // interface) the onReceiveValue method of which will delegate to the
27 // supplied |callback|.
28 // The callback's lifespan is tied to the Java object.
29 static base::android::ScopedJavaLocalRef<jobject> ToJavaValueCallbackInt(
30 JNIEnv* env,
31 const base::Callback<void(int)>& callback);
32
33 private:
34 DISALLOW_COPY_AND_ASSIGN(CallbackJNIBridge);
35 };
36
37 bool RegisterCallbackJNIBridge(JNIEnv* env);
38
39 } // namespace android_webview
40
41 #endif // ANDROID_WEBVIEW_NATIVE_JAVA_CALLBACK_BRIDGE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698