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

Side by Side Diff: content/renderer/pepper/v8_var_converter.h

Issue 23330008: Introduce MockResourceConverter to modularize testing of V8VarConverter (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 4 months 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
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 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/callback.h" 10 #include "base/callback.h"
11 #include "base/compiler_specific.h" 11 #include "base/compiler_specific.h"
12 #include "base/message_loop/message_loop_proxy.h" 12 #include "base/message_loop/message_loop_proxy.h"
13 #include "ppapi/c/pp_var.h" 13 #include "ppapi/c/pp_var.h"
14 #include "v8/include/v8.h" 14 #include "v8/include/v8.h"
15 #include "content/common/content_export.h" 15 #include "content/common/content_export.h"
16 16
17 namespace ppapi { 17 namespace ppapi {
18 class ScopedPPVar; 18 class ScopedPPVar;
19 } 19 }
20 20
21 namespace content { 21 namespace content {
22 namespace V8VarConverter {
23 22
24 // Converts the given PP_Var to a v8::Value. True is returned upon success. 23 class ResourceConverter;
25 bool CONTENT_EXPORT ToV8Value(const PP_Var& var,
26 v8::Handle<v8::Context> context,
27 v8::Handle<v8::Value>* result);
28 24
29 // A version of FromV8Value that accepts the message loop to run the callback 25 class CONTENT_EXPORT V8VarConverter {
30 // from for the purposes of testing. The default is to use the current message 26 public:
31 // loop. See the description of FromV8Value below. 27 V8VarConverter();
32 void CONTENT_EXPORT FromV8Value( 28 // Constructor for testing.
33 v8::Handle<v8::Value> val, 29 V8VarConverter(
34 v8::Handle<v8::Context> context, 30 const scoped_refptr<base::MessageLoopProxy>& message_loop_proxy,
35 const base::Callback<void(const ppapi::ScopedPPVar&, bool)>& callback, 31 scoped_ptr<ResourceConverter> resource_converter);
36 const scoped_refptr<base::MessageLoopProxy>& message_loop_proxy); 32 ~V8VarConverter();
37 33
38 // Converts the given v8::Value to a PP_Var. Every PP_Var in the reference graph 34 // Converts the given PP_Var to a v8::Value. True is returned upon success.
39 // in the result will have a refcount equal to the number of references to it in 35 bool ToV8Value(const PP_Var& var,
40 // the graph. The root of the result will have one additional reference. The 36 v8::Handle<v8::Context> context,
41 // callback is run when conversion is complete with the resulting var and a bool 37 v8::Handle<v8::Value>* result);
42 // indicating success or failure. Conversion is asynchronous because converting
43 // some resources may result in communication across IPC. |context| is
44 // guaranteed to only be used synchronously.
45 void CONTENT_EXPORT FromV8Value(
46 v8::Handle<v8::Value> val,
47 v8::Handle<v8::Context> context,
48 const base::Callback<void(const ppapi::ScopedPPVar&, bool)>& callback);
49 38
50 } // namespace V8VarConverter 39 // Converts the given v8::Value to a PP_Var. Every PP_Var in the reference
40 // graph in the result will have a refcount equal to the number of references
41 // to it in the graph. The root of the result will have one additional
42 // reference. The callback is run when conversion is complete with the
43 // resulting var and a bool indicating success or failure. Conversion is
44 // asynchronous because converting some resources may result in communication
45 // across IPC. |context| is guaranteed to only be used synchronously.
46 void FromV8Value(
47 v8::Handle<v8::Value> val,
48 v8::Handle<v8::Context> context,
49 const base::Callback<void(const ppapi::ScopedPPVar&, bool)>& callback);
50
51 private:
52 // The message loop to run the callback to |FromV8Value| from.
53 scoped_refptr<base::MessageLoopProxy> message_loop_proxy_;
54
55 // The converter to use for converting V8 vars to resources.
56 scoped_ptr<ResourceConverter> resource_converter_;
57
58 DISALLOW_COPY_AND_ASSIGN(V8VarConverter);
59 };
60
51 } // namespace content 61 } // namespace content
52 62
53 #endif // CONTENT_RENDERER_PEPPER_V8_VAR_CONVERTER_H 63 #endif // CONTENT_RENDERER_PEPPER_V8_VAR_CONVERTER_H
OLDNEW
« no previous file with comments | « content/renderer/pepper/resource_converter.cc ('k') | content/renderer/pepper/v8_var_converter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698