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 <memory> |
| 9 |
8 #include "base/callback.h" | 10 #include "base/callback.h" |
9 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
10 #include "base/macros.h" | 12 #include "base/macros.h" |
11 #include "base/memory/scoped_ptr.h" | |
12 #include "content/common/content_export.h" | 13 #include "content/common/content_export.h" |
13 #include "ppapi/c/pp_instance.h" | 14 #include "ppapi/c/pp_instance.h" |
14 #include "ppapi/c/pp_var.h" | 15 #include "ppapi/c/pp_var.h" |
15 #include "ppapi/shared_impl/scoped_pp_var.h" | 16 #include "ppapi/shared_impl/scoped_pp_var.h" |
16 #include "v8/include/v8.h" | 17 #include "v8/include/v8.h" |
17 | 18 |
18 namespace content { | 19 namespace content { |
19 | 20 |
20 class ResourceConverter; | 21 class ResourceConverter; |
21 | 22 |
22 class CONTENT_EXPORT V8VarConverter { | 23 class CONTENT_EXPORT V8VarConverter { |
23 public: | 24 public: |
24 // Whether or not to allow converting object vars. If they are not allowed | 25 // Whether or not to allow converting object vars. If they are not allowed |
25 // and they are passed in, conversion will fail. | 26 // and they are passed in, conversion will fail. |
26 enum AllowObjectVars { | 27 enum AllowObjectVars { |
27 kDisallowObjectVars, | 28 kDisallowObjectVars, |
28 kAllowObjectVars | 29 kAllowObjectVars |
29 }; | 30 }; |
30 V8VarConverter(PP_Instance instance, AllowObjectVars object_vars_allowed); | 31 V8VarConverter(PP_Instance instance, AllowObjectVars object_vars_allowed); |
31 | 32 |
32 // Constructor for testing. | 33 // Constructor for testing. |
33 V8VarConverter(PP_Instance instance, | 34 V8VarConverter(PP_Instance instance, |
34 scoped_ptr<ResourceConverter> resource_converter); | 35 std::unique_ptr<ResourceConverter> resource_converter); |
35 ~V8VarConverter(); | 36 ~V8VarConverter(); |
36 | 37 |
37 // Converts the given PP_Var to a v8::Value. True is returned upon success. | 38 // Converts the given PP_Var to a v8::Value. True is returned upon success. |
38 bool ToV8Value(const PP_Var& var, | 39 bool ToV8Value(const PP_Var& var, |
39 v8::Local<v8::Context> context, | 40 v8::Local<v8::Context> context, |
40 v8::Local<v8::Value>* result); | 41 v8::Local<v8::Value>* result); |
41 | 42 |
42 struct VarResult { | 43 struct VarResult { |
43 public: | 44 public: |
44 VarResult() : completed_synchronously(false), success(false) {} | 45 VarResult() : completed_synchronously(false), success(false) {} |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 bool FromV8ValueInternal(v8::Local<v8::Value> val, | 78 bool FromV8ValueInternal(v8::Local<v8::Value> val, |
78 v8::Local<v8::Context> context, | 79 v8::Local<v8::Context> context, |
79 ppapi::ScopedPPVar* result_var); | 80 ppapi::ScopedPPVar* result_var); |
80 | 81 |
81 PP_Instance instance_; | 82 PP_Instance instance_; |
82 | 83 |
83 // Whether or not to support conversion to PP_VARTYPE_OBJECT. | 84 // Whether or not to support conversion to PP_VARTYPE_OBJECT. |
84 AllowObjectVars object_vars_allowed_; | 85 AllowObjectVars object_vars_allowed_; |
85 | 86 |
86 // The converter to use for converting V8 vars to resources. | 87 // The converter to use for converting V8 vars to resources. |
87 scoped_ptr<ResourceConverter> resource_converter_; | 88 std::unique_ptr<ResourceConverter> resource_converter_; |
88 | 89 |
89 DISALLOW_COPY_AND_ASSIGN(V8VarConverter); | 90 DISALLOW_COPY_AND_ASSIGN(V8VarConverter); |
90 }; | 91 }; |
91 | 92 |
92 } // namespace content | 93 } // namespace content |
93 | 94 |
94 #endif // CONTENT_RENDERER_PEPPER_V8_VAR_CONVERTER_H_ | 95 #endif // CONTENT_RENDERER_PEPPER_V8_VAR_CONVERTER_H_ |
OLD | NEW |