| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_JAVA_METHOD_H_ | 5 #ifndef CONTENT_BROWSER_RENDERER_HOST_JAVA_JAVA_METHOD_H_ |
| 6 #define CONTENT_BROWSER_RENDERER_HOST_JAVA_JAVA_METHOD_H_ | 6 #define CONTENT_BROWSER_RENDERER_HOST_JAVA_JAVA_METHOD_H_ |
| 7 | 7 |
| 8 #include <jni.h> | 8 #include <jni.h> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "base/android/scoped_java_ref.h" | 12 #include "base/android/scoped_java_ref.h" |
| 13 #include "content/browser/renderer_host/java/java_type.h" | 13 #include "content/browser/renderer_host/java/java_type.h" |
| 14 | 14 |
| 15 namespace content { |
| 16 |
| 15 // Wrapper around java.lang.reflect.Method. This class must be used on a single | 17 // Wrapper around java.lang.reflect.Method. This class must be used on a single |
| 16 // thread only. | 18 // thread only. |
| 17 class JavaMethod { | 19 class JavaMethod { |
| 18 public: | 20 public: |
| 19 explicit JavaMethod(const base::android::JavaRef<jobject>& method); | 21 explicit JavaMethod(const base::android::JavaRef<jobject>& method); |
| 20 ~JavaMethod(); | 22 ~JavaMethod(); |
| 21 | 23 |
| 22 const std::string& name() const { return name_; } | 24 const std::string& name() const { return name_; } |
| 23 size_t num_parameters() const; | 25 size_t num_parameters() const; |
| 24 const JavaType& parameter_type(size_t index) const; | 26 const JavaType& parameter_type(size_t index) const; |
| 25 const JavaType& return_type() const; | 27 const JavaType& return_type() const; |
| 26 jmethodID id() const; | 28 jmethodID id() const; |
| 27 | 29 |
| 28 private: | 30 private: |
| 29 void EnsureNumParametersIsSetUp() const; | 31 void EnsureNumParametersIsSetUp() const; |
| 30 void EnsureTypesAndIDAreSetUp() const; | 32 void EnsureTypesAndIDAreSetUp() const; |
| 31 | 33 |
| 32 std::string name_; | 34 std::string name_; |
| 33 mutable base::android::ScopedJavaGlobalRef<jobject> java_method_; | 35 mutable base::android::ScopedJavaGlobalRef<jobject> java_method_; |
| 34 mutable bool have_calculated_num_parameters_; | 36 mutable bool have_calculated_num_parameters_; |
| 35 mutable size_t num_parameters_; | 37 mutable size_t num_parameters_; |
| 36 mutable std::vector<JavaType> parameter_types_; | 38 mutable std::vector<JavaType> parameter_types_; |
| 37 mutable JavaType return_type_; | 39 mutable JavaType return_type_; |
| 38 mutable jmethodID id_; | 40 mutable jmethodID id_; |
| 39 | 41 |
| 40 DISALLOW_IMPLICIT_CONSTRUCTORS(JavaMethod); | 42 DISALLOW_IMPLICIT_CONSTRUCTORS(JavaMethod); |
| 41 }; | 43 }; |
| 42 | 44 |
| 45 } // namespace content |
| 46 |
| 43 #endif // CONTENT_BROWSER_RENDERER_HOST_JAVA_JAVA_METHOD_H_ | 47 #endif // CONTENT_BROWSER_RENDERER_HOST_JAVA_JAVA_METHOD_H_ |
| OLD | NEW |