Re-subimission of https://codereview.chromium.org/1041213003/
[chromium-blink-merge.git] / content / browser / android / java / java_method.h
blobb5ba26a6f5f5a6e6505ebfa7c72d16dfafa49398
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
3 // found in the LICENSE file.
5 #ifndef CONTENT_BROWSER_ANDROID_JAVA_JAVA_METHOD_H_
6 #define CONTENT_BROWSER_ANDROID_JAVA_JAVA_METHOD_H_
8 #include <jni.h>
9 #include <string>
10 #include <vector>
12 #include "base/android/scoped_java_ref.h"
13 #include "content/browser/android/java/java_type.h"
14 #include "content/common/content_export.h"
16 namespace content {
18 // Wrapper around java.lang.reflect.Method. This class must be used on a single
19 // thread only.
20 class CONTENT_EXPORT JavaMethod {
21 public:
22 explicit JavaMethod(const base::android::JavaRef<jobject>& method);
23 ~JavaMethod();
25 const std::string& name() const { return name_; }
26 size_t num_parameters() const;
27 bool is_static() const;
28 const JavaType& parameter_type(size_t index) const;
29 const JavaType& return_type() const;
30 jmethodID id() const;
32 private:
33 void EnsureNumParametersIsSetUp() const;
34 void EnsureTypesAndIDAreSetUp() const;
36 std::string name_;
37 mutable base::android::ScopedJavaGlobalRef<jobject> java_method_;
38 mutable bool have_calculated_num_parameters_;
39 mutable size_t num_parameters_;
40 mutable std::vector<JavaType> parameter_types_;
41 mutable JavaType return_type_;
42 mutable bool is_static_;
43 mutable jmethodID id_;
45 DISALLOW_IMPLICIT_CONSTRUCTORS(JavaMethod);
48 } // namespace content
50 #endif // CONTENT_BROWSER_ANDROID_JAVA_JAVA_METHOD_H_