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

Unified 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 side-by-side diff with in-line comments
Download patch
« 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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/renderer/pepper/v8_var_converter.h
diff --git a/content/renderer/pepper/v8_var_converter.h b/content/renderer/pepper/v8_var_converter.h
index aad4a14e128657fd709bb3adcab8139e98a46a08..a9865c305e9abebd26dfae2c1fec87abfe769fba 100644
--- a/content/renderer/pepper/v8_var_converter.h
+++ b/content/renderer/pepper/v8_var_converter.h
@@ -19,35 +19,45 @@ class ScopedPPVar;
}
namespace content {
-namespace V8VarConverter {
-
-// Converts the given PP_Var to a v8::Value. True is returned upon success.
-bool CONTENT_EXPORT ToV8Value(const PP_Var& var,
- v8::Handle<v8::Context> context,
- v8::Handle<v8::Value>* result);
-
-// A version of FromV8Value that accepts the message loop to run the callback
-// from for the purposes of testing. The default is to use the current message
-// loop. See the description of FromV8Value below.
-void CONTENT_EXPORT FromV8Value(
- v8::Handle<v8::Value> val,
- v8::Handle<v8::Context> context,
- const base::Callback<void(const ppapi::ScopedPPVar&, bool)>& callback,
- const scoped_refptr<base::MessageLoopProxy>& message_loop_proxy);
-
-// Converts the given v8::Value to a PP_Var. Every PP_Var in the reference graph
-// in the result will have a refcount equal to the number of references to it in
-// the graph. The root of the result will have one additional reference. The
-// callback is run when conversion is complete with the resulting var and a bool
-// indicating success or failure. Conversion is asynchronous because converting
-// some resources may result in communication across IPC. |context| is
-// guaranteed to only be used synchronously.
-void CONTENT_EXPORT FromV8Value(
- v8::Handle<v8::Value> val,
- v8::Handle<v8::Context> context,
- const base::Callback<void(const ppapi::ScopedPPVar&, bool)>& callback);
-
-} // namespace V8VarConverter
+
+class ResourceConverter;
+
+class CONTENT_EXPORT V8VarConverter {
+ public:
+ V8VarConverter();
+ // Constructor for testing.
+ V8VarConverter(
+ const scoped_refptr<base::MessageLoopProxy>& message_loop_proxy,
+ scoped_ptr<ResourceConverter> resource_converter);
+ ~V8VarConverter();
+
+ // Converts the given PP_Var to a v8::Value. True is returned upon success.
+ bool ToV8Value(const PP_Var& var,
+ v8::Handle<v8::Context> context,
+ v8::Handle<v8::Value>* result);
+
+ // Converts the given v8::Value to a PP_Var. Every PP_Var in the reference
+ // graph in the result will have a refcount equal to the number of references
+ // to it in the graph. The root of the result will have one additional
+ // reference. The callback is run when conversion is complete with the
+ // resulting var and a bool indicating success or failure. Conversion is
+ // asynchronous because converting some resources may result in communication
+ // across IPC. |context| is guaranteed to only be used synchronously.
+ void FromV8Value(
+ v8::Handle<v8::Value> val,
+ v8::Handle<v8::Context> context,
+ const base::Callback<void(const ppapi::ScopedPPVar&, bool)>& callback);
+
+ private:
+ // The message loop to run the callback to |FromV8Value| from.
+ scoped_refptr<base::MessageLoopProxy> message_loop_proxy_;
+
+ // The converter to use for converting V8 vars to resources.
+ scoped_ptr<ResourceConverter> resource_converter_;
+
+ DISALLOW_COPY_AND_ASSIGN(V8VarConverter);
+};
+
} // namespace content
#endif // CONTENT_RENDERER_PEPPER_V8_VAR_CONVERTER_H
« 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