Upstream version 9.37.197.0
[platform/framework/web/crosswalk.git] / src / content / browser / renderer_host / java / java_method.h
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 #include "content/browser/renderer_host/java/java_type.h"
14
15 namespace content {
16
17 // Wrapper around java.lang.reflect.Method. This class must be used on a single
18 // thread only.
19 class JavaMethod {
20  public:
21   explicit JavaMethod(const base::android::JavaRef<jobject>& method);
22   ~JavaMethod();
23
24   const std::string& name() const { return name_; }
25   size_t num_parameters() const;
26   bool is_static() const;
27   const JavaType& parameter_type(size_t index) const;
28   const JavaType& return_type() const;
29   jmethodID id() const;
30
31  private:
32   void EnsureNumParametersIsSetUp() const;
33   void EnsureTypesAndIDAreSetUp() const;
34
35   std::string name_;
36   mutable base::android::ScopedJavaGlobalRef<jobject> java_method_;
37   mutable bool have_calculated_num_parameters_;
38   mutable size_t num_parameters_;
39   mutable std::vector<JavaType> parameter_types_;
40   mutable JavaType return_type_;
41   mutable bool is_static_;
42   mutable jmethodID id_;
43
44   DISALLOW_IMPLICIT_CONSTRUCTORS(JavaMethod);
45 };
46
47 }  // namespace content
48
49 #endif  // CONTENT_BROWSER_RENDERER_HOST_JAVA_JAVA_METHOD_H_