Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1351)

Side by Side Diff: content/browser/renderer_host/java/java_method.h

Issue 8509019: Add JavaBoundObject (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Use mutable Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(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 } // namespace JavaType
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() const;
49 void EnsureTypesAndIDAreSetUp() const;
50
51 std::string name_;
52 mutable base::android::ScopedJavaGlobalRef<jobject> java_method_;
53 mutable bool have_calculated_num_parameters_;
54 mutable size_t num_parameters_;
55 mutable std::vector<JavaType::Type> parameter_types_;
56 mutable JavaType::Type return_type_;
57 mutable jmethodID id_;
58
59 DISALLOW_IMPLICIT_CONSTRUCTORS(JavaMethod);
60 };
61
62 #endif // CONTENT_BROWSER_RENDERER_HOST_JAVA_JAVA_METHOD_H_
OLDNEW
« no previous file with comments | « content/browser/renderer_host/java/java_bound_object.cc ('k') | content/browser/renderer_host/java/java_method.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698