Chromium Code Reviews| OLD | NEW |
|---|---|
| 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_ANDROID_JAVA_GIN_JAVA_METHOD_INVOCATION_HELPER_H_ | 5 #ifndef CONTENT_BROWSER_ANDROID_JAVA_GIN_JAVA_METHOD_INVOCATION_HELPER_H_ |
| 6 #define CONTENT_BROWSER_ANDROID_JAVA_GIN_JAVA_METHOD_INVOCATION_HELPER_H_ | 6 #define CONTENT_BROWSER_ANDROID_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" |
| 11 #include "base/android/scoped_java_ref.h" | 11 #include "base/android/scoped_java_ref.h" |
| 12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
| 13 #include "base/values.h" | 13 #include "base/values.h" |
| 14 #include "content/browser/android/java/gin_java_bound_object.h" | 14 #include "content/browser/android/java/gin_java_bound_object.h" |
| 15 #include "content/browser/android/java/java_type.h" | 15 #include "content/browser/android/java/java_type.h" |
| 16 #include "content/common/android/gin_java_bridge_errors.h" | 16 #include "content/common/android/gin_java_bridge_errors.h" |
| 17 #include "content/common/content_export.h" | 17 #include "content/common/content_export.h" |
| 18 | 18 |
| 19 namespace content { | 19 namespace content { |
| 20 | 20 |
| 21 class JavaMethod; | 21 class JavaMethod; |
| 22 | 22 |
| 23 // Instances of this class are created and initialized on the UI thread, do | |
|
benm (inactive)
2014/12/05 17:09:33
Can we keep a comment here about the threading ple
mnaganov (inactive)
2014/12/05 18:07:40
Done.
| |
| 24 // their work on the background thread, and then again examined on the UI | |
| 25 // thread. They don't work on both threads simultaneously, though. | |
| 26 class CONTENT_EXPORT GinJavaMethodInvocationHelper | 23 class CONTENT_EXPORT GinJavaMethodInvocationHelper |
| 27 : public base::RefCountedThreadSafe<GinJavaMethodInvocationHelper> { | 24 : public base::RefCountedThreadSafe<GinJavaMethodInvocationHelper> { |
| 28 public: | 25 public: |
| 29 // DispatcherDelegate is used on the UI thread | |
| 30 class DispatcherDelegate { | 26 class DispatcherDelegate { |
| 31 public: | 27 public: |
| 32 DispatcherDelegate() {} | 28 DispatcherDelegate() {} |
| 33 virtual ~DispatcherDelegate() {} | 29 virtual ~DispatcherDelegate() {} |
| 34 virtual JavaObjectWeakGlobalRef GetObjectWeakRef( | 30 virtual JavaObjectWeakGlobalRef GetObjectWeakRef( |
| 35 GinJavaBoundObject::ObjectID object_id) = 0; | 31 GinJavaBoundObject::ObjectID object_id) = 0; |
| 36 | 32 |
| 37 private: | 33 private: |
| 38 DISALLOW_COPY_AND_ASSIGN(DispatcherDelegate); | 34 DISALLOW_COPY_AND_ASSIGN(DispatcherDelegate); |
| 39 }; | 35 }; |
| 40 | 36 |
| 41 // ObjectDelegate is used in the background thread | |
| 42 class ObjectDelegate { | 37 class ObjectDelegate { |
| 43 public: | 38 public: |
| 44 ObjectDelegate() {} | 39 ObjectDelegate() {} |
| 45 virtual ~ObjectDelegate() {} | 40 virtual ~ObjectDelegate() {} |
| 46 virtual base::android::ScopedJavaLocalRef<jobject> GetLocalRef( | 41 virtual base::android::ScopedJavaLocalRef<jobject> GetLocalRef( |
| 47 JNIEnv* env) = 0; | 42 JNIEnv* env) = 0; |
| 48 virtual base::android::ScopedJavaLocalRef<jclass> GetLocalClassRef( | 43 virtual base::android::ScopedJavaLocalRef<jclass> GetLocalClassRef( |
| 49 JNIEnv* env) = 0; | 44 JNIEnv* env) = 0; |
| 50 virtual const JavaMethod* FindMethod(const std::string& method_name, | 45 virtual const JavaMethod* FindMethod(const std::string& method_name, |
| 51 size_t num_parameters) = 0; | 46 size_t num_parameters) = 0; |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 108 GinJavaBridgeError invocation_error_; | 103 GinJavaBridgeError invocation_error_; |
| 109 base::android::ScopedJavaGlobalRef<jobject> object_result_; | 104 base::android::ScopedJavaGlobalRef<jobject> object_result_; |
| 110 base::android::ScopedJavaGlobalRef<jclass> safe_annotation_clazz_; | 105 base::android::ScopedJavaGlobalRef<jclass> safe_annotation_clazz_; |
| 111 | 106 |
| 112 DISALLOW_COPY_AND_ASSIGN(GinJavaMethodInvocationHelper); | 107 DISALLOW_COPY_AND_ASSIGN(GinJavaMethodInvocationHelper); |
| 113 }; | 108 }; |
| 114 | 109 |
| 115 } // namespace content | 110 } // namespace content |
| 116 | 111 |
| 117 #endif // CONTENT_BROWSER_ANDROID_JAVA_GIN_JAVA_METHOD_INVOCATION_HELPER_H_ | 112 #endif // CONTENT_BROWSER_ANDROID_JAVA_GIN_JAVA_METHOD_INVOCATION_HELPER_H_ |
| OLD | NEW |