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