OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CONTENT_RENDERER_PEPPER_V8_VAR_CONVERTER_H | 5 #ifndef CONTENT_RENDERER_PEPPER_V8_VAR_CONVERTER_H |
6 #define CONTENT_RENDERER_PEPPER_V8_VAR_CONVERTER_H | 6 #define CONTENT_RENDERER_PEPPER_V8_VAR_CONVERTER_H |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/callback.h" | 9 #include "base/callback.h" |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
11 #include "base/message_loop/message_loop_proxy.h" | 11 #include "base/message_loop/message_loop_proxy.h" |
12 #include "ppapi/c/pp_instance.h" | 12 #include "ppapi/c/pp_instance.h" |
13 #include "ppapi/c/pp_var.h" | 13 #include "ppapi/c/pp_var.h" |
14 #include "ppapi/shared_impl/scoped_pp_var.h" | 14 #include "ppapi/shared_impl/scoped_pp_var.h" |
15 #include "v8/include/v8.h" | 15 #include "v8/include/v8.h" |
16 #include "content/common/content_export.h" | 16 #include "content/common/content_export.h" |
17 | 17 |
18 namespace content { | 18 namespace content { |
19 | 19 |
20 class ResourceConverter; | 20 class ResourceConverter; |
21 | 21 |
22 class CONTENT_EXPORT V8VarConverter { | 22 class CONTENT_EXPORT V8VarConverter { |
23 public: | 23 public: |
24 // Whether or not to allow converting object vars. If they are not allowed | 24 // Whether or not to allow converting object vars. If they are not allowed |
25 // and they are passed in, conversion will fail. | 25 // and they are passed in, conversion will fail. |
26 enum AllowObjectVars { | 26 enum AllowObjectVars { |
27 kDisallowObjectVars, | 27 kDisallowObjectVars, |
28 kAllowObjectVars | 28 kAllowObjectVars |
29 }; | 29 }; |
30 explicit V8VarConverter(PP_Instance instance); | |
31 V8VarConverter(PP_Instance instance, AllowObjectVars object_vars_allowed); | 30 V8VarConverter(PP_Instance instance, AllowObjectVars object_vars_allowed); |
32 | 31 |
33 // Constructor for testing. | 32 // Constructor for testing. |
34 V8VarConverter(PP_Instance instance, | 33 V8VarConverter(PP_Instance instance, |
35 scoped_ptr<ResourceConverter> resource_converter); | 34 scoped_ptr<ResourceConverter> resource_converter); |
36 ~V8VarConverter(); | 35 ~V8VarConverter(); |
37 | 36 |
38 // Converts the given PP_Var to a v8::Value. True is returned upon success. | 37 // Converts the given PP_Var to a v8::Value. True is returned upon success. |
39 bool ToV8Value(const PP_Var& var, | 38 bool ToV8Value(const PP_Var& var, |
40 v8::Handle<v8::Context> context, | 39 v8::Handle<v8::Context> context, |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 // Returns true on success, false on failure. | 76 // Returns true on success, false on failure. |
78 bool FromV8ValueInternal(v8::Handle<v8::Value> val, | 77 bool FromV8ValueInternal(v8::Handle<v8::Value> val, |
79 v8::Handle<v8::Context> context, | 78 v8::Handle<v8::Context> context, |
80 ppapi::ScopedPPVar* result_var); | 79 ppapi::ScopedPPVar* result_var); |
81 | 80 |
82 PP_Instance instance_; | 81 PP_Instance instance_; |
83 | 82 |
84 // Whether or not to support conversion to PP_VARTYPE_OBJECT. | 83 // Whether or not to support conversion to PP_VARTYPE_OBJECT. |
85 AllowObjectVars object_vars_allowed_; | 84 AllowObjectVars object_vars_allowed_; |
86 | 85 |
87 // The message loop to run the callback to |FromV8Value| from. | |
88 scoped_refptr<base::MessageLoopProxy> message_loop_proxy_; | |
89 | |
90 // The converter to use for converting V8 vars to resources. | 86 // The converter to use for converting V8 vars to resources. |
91 scoped_ptr<ResourceConverter> resource_converter_; | 87 scoped_ptr<ResourceConverter> resource_converter_; |
92 | 88 |
93 DISALLOW_COPY_AND_ASSIGN(V8VarConverter); | 89 DISALLOW_COPY_AND_ASSIGN(V8VarConverter); |
94 }; | 90 }; |
95 | 91 |
96 } // namespace content | 92 } // namespace content |
97 | 93 |
98 #endif // CONTENT_RENDERER_PEPPER_V8_VAR_CONVERTER_H | 94 #endif // CONTENT_RENDERER_PEPPER_V8_VAR_CONVERTER_H |
OLD | NEW |