Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CONTENT_BROWSER_RENDERER_HOST_JAVA_JAVA_METHOD_H_ | |
| 6 #define CONTENT_BROWSER_RENDERER_HOST_JAVA_JAVA_METHOD_H_ | |
| 7 | |
| 8 #include <jni.h> | |
| 9 #include <string> | |
| 10 #include <vector> | |
| 11 | |
| 12 #include "base/android/scoped_java_ref.h" | |
| 13 | |
| 14 namespace JavaType { | |
| 15 enum Type { | |
| 16 TypeBoolean, | |
| 17 TypeByte, | |
| 18 TypeChar, | |
| 19 TypeShort, | |
| 20 TypeInt, | |
| 21 TypeLong, | |
| 22 TypeFloat, | |
| 23 TypeDouble, | |
| 24 // This is only used as a return type, so we should never convert from | |
| 25 // JavaScript with this type. | |
| 26 TypeVoid, | |
| 27 TypeArray, | |
| 28 // We special-case strings, as they get special handling when coercing. | |
| 29 TypeString, | |
| 30 TypeObject, | |
| 31 }; | |
| 32 } | |
|
M-A Ruel
2011/11/11 16:22:28
} // namespace JavaType
Steve Block
2011/11/11 16:31:34
Done.
| |
| 33 | |
| 34 // Wrapper around java.lang.reflect.Method. This class must be used on a single | |
| 35 // thread only. | |
| 36 class JavaMethod { | |
| 37 public: | |
| 38 explicit JavaMethod(const base::android::JavaRef<jobject>& method); | |
| 39 ~JavaMethod(); | |
| 40 | |
| 41 const std::string& name() const { return name_; } | |
| 42 size_t num_parameters() const; | |
| 43 JavaType::Type parameter_type(size_t index) const; | |
| 44 JavaType::Type return_type() const; | |
| 45 jmethodID id() const; | |
| 46 | |
| 47 private: | |
| 48 void EnsureNumParametersIsSetUp(); | |
| 49 void EnsureTypesAndIDAreSetUp(); | |
| 50 | |
| 51 std::string name_; | |
| 52 base::android::ScopedJavaGlobalRef<jobject> java_method_; | |
| 53 bool have_calculated_num_parameters_; | |
| 54 size_t num_parameters_; | |
| 55 std::vector<JavaType::Type> parameter_types_; | |
| 56 JavaType::Type return_type_; | |
| 57 jmethodID id_; | |
| 58 | |
| 59 DISALLOW_IMPLICIT_CONSTRUCTORS(JavaMethod); | |
| 60 }; | |
| 61 | |
| 62 #endif // CONTENT_BROWSER_RENDERER_HOST_JAVA_JAVA_METHOD_H_ | |
| OLD | NEW |