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

Side by Side Diff: content/browser/renderer_host/java/gin_java_method_invocation_helper.h

Issue 323403007: [Android] Java Bridge with Gin: implement Java bound object (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased Created 6 years, 6 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
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 #ifndef CONTENT_BROWSER_RENDERER_HOST_JAVA_GIN_JAVA_METHOD_INVOCATION_HELPER_H_ 5 #ifndef CONTENT_BROWSER_RENDERER_HOST_JAVA_GIN_JAVA_METHOD_INVOCATION_HELPER_H_
6 #define CONTENT_BROWSER_RENDERER_HOST_JAVA_GIN_JAVA_METHOD_INVOCATION_HELPER_H_ 6 #define CONTENT_BROWSER_RENDERER_HOST_JAVA_GIN_JAVA_METHOD_INVOCATION_HELPER_H_
7 7
8 #include <map> 8 #include <map>
9 9
10 #include "base/android/jni_weak_ref.h" 10 #include "base/android/jni_weak_ref.h"
(...skipping 26 matching lines...) Expand all
37 DISALLOW_COPY_AND_ASSIGN(DispatcherDelegate); 37 DISALLOW_COPY_AND_ASSIGN(DispatcherDelegate);
38 }; 38 };
39 39
40 // ObjectDelegate is used in the background thread 40 // ObjectDelegate is used in the background thread
41 class ObjectDelegate { 41 class ObjectDelegate {
42 public: 42 public:
43 ObjectDelegate() {} 43 ObjectDelegate() {}
44 virtual ~ObjectDelegate() {} 44 virtual ~ObjectDelegate() {}
45 virtual base::android::ScopedJavaLocalRef<jobject> GetLocalRef( 45 virtual base::android::ScopedJavaLocalRef<jobject> GetLocalRef(
46 JNIEnv* env) = 0; 46 JNIEnv* env) = 0;
47 virtual base::android::ScopedJavaLocalRef<jclass> GetLocalClassRef(
48 JNIEnv* env) = 0;
47 virtual const JavaMethod* FindMethod(const std::string& method_name, 49 virtual const JavaMethod* FindMethod(const std::string& method_name,
48 size_t num_parameters) = 0; 50 size_t num_parameters) = 0;
49 virtual bool IsObjectGetClassMethod(const JavaMethod* method) = 0; 51 virtual bool IsObjectGetClassMethod(const JavaMethod* method) = 0;
50 virtual const base::android::JavaRef<jclass>& GetSafeAnnotationClass() = 0; 52 virtual const base::android::JavaRef<jclass>& GetSafeAnnotationClass() = 0;
51 53
52 private: 54 private:
53 DISALLOW_COPY_AND_ASSIGN(ObjectDelegate); 55 DISALLOW_COPY_AND_ASSIGN(ObjectDelegate);
54 }; 56 };
55 57
56 GinJavaMethodInvocationHelper(scoped_ptr<ObjectDelegate> object, 58 GinJavaMethodInvocationHelper(scoped_ptr<ObjectDelegate> object,
(...skipping 19 matching lines...) Expand all
76 void BuildObjectRefsFromListValue(DispatcherDelegate* dispatcher, 78 void BuildObjectRefsFromListValue(DispatcherDelegate* dispatcher,
77 const base::Value* list_value); 79 const base::Value* list_value);
78 void BuildObjectRefsFromDictionaryValue(DispatcherDelegate* dispatcher, 80 void BuildObjectRefsFromDictionaryValue(DispatcherDelegate* dispatcher,
79 const base::Value* dict_value); 81 const base::Value* dict_value);
80 82
81 bool AppendObjectRef(DispatcherDelegate* dispatcher, 83 bool AppendObjectRef(DispatcherDelegate* dispatcher,
82 const base::Value* raw_value); 84 const base::Value* raw_value);
83 85
84 // Called on the background thread. 86 // Called on the background thread.
85 void InvokeMethod(jobject object, 87 void InvokeMethod(jobject object,
88 jclass clazz,
86 const JavaType& return_type, 89 const JavaType& return_type,
87 jmethodID id, 90 jmethodID id,
88 jvalue* parameters); 91 jvalue* parameters);
89 void SetInvocationFailure(const char* error_message); 92 void SetInvocationFailure(const char* error_message);
90 void SetPrimitiveResult(const base::ListValue& result_wrapper); 93 void SetPrimitiveResult(const base::ListValue& result_wrapper);
91 void SetObjectResult( 94 void SetObjectResult(
92 const base::android::JavaRef<jobject>& object, 95 const base::android::JavaRef<jobject>& object,
93 const base::android::JavaRef<jclass>& safe_annotation_clazz); 96 const base::android::JavaRef<jclass>& safe_annotation_clazz);
94 97
95 typedef std::map<GinJavaBoundObject::ObjectID, 98 typedef std::map<GinJavaBoundObject::ObjectID,
96 JavaObjectWeakGlobalRef> ObjectRefs; 99 JavaObjectWeakGlobalRef> ObjectRefs;
97 100
98 scoped_ptr<ObjectDelegate> object_; 101 scoped_ptr<ObjectDelegate> object_;
99 const std::string method_name_; 102 const std::string method_name_;
100 scoped_ptr<base::ListValue> arguments_; 103 scoped_ptr<base::ListValue> arguments_;
101 ObjectRefs object_refs_; 104 ObjectRefs object_refs_;
102 bool holds_primitive_result_; 105 bool holds_primitive_result_;
103 scoped_ptr<base::ListValue> primitive_result_; 106 scoped_ptr<base::ListValue> primitive_result_;
104 std::string error_message_; 107 std::string error_message_;
105 base::android::ScopedJavaGlobalRef<jobject> object_result_; 108 base::android::ScopedJavaGlobalRef<jobject> object_result_;
106 base::android::ScopedJavaGlobalRef<jclass> safe_annotation_clazz_; 109 base::android::ScopedJavaGlobalRef<jclass> safe_annotation_clazz_;
107 110
108 DISALLOW_COPY_AND_ASSIGN(GinJavaMethodInvocationHelper); 111 DISALLOW_COPY_AND_ASSIGN(GinJavaMethodInvocationHelper);
109 }; 112 };
110 113
111 } // namespace content 114 } // namespace content
112 115
113 #endif // CONTENT_BROWSER_RENDERER_HOST_JAVA_GIN_JAVA_METHOD_INVOCATION_HELPER_ H_ 116 #endif // CONTENT_BROWSER_RENDERER_HOST_JAVA_GIN_JAVA_METHOD_INVOCATION_HELPER_ H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698