]> khamidou — GitHub mirrors - electron.git/commitdiff
Use our fork of V8ValueConverter for all cases.
authorCheng Zhao <zcbenz@gmail.com>
Mon, 23 Dec 2013 14:42:21 +0000 (22:42 +0800)
committerCheng Zhao <zcbenz@gmail.com>
Mon, 23 Dec 2013 14:42:21 +0000 (22:42 +0800)
atom.gyp
browser/api/atom_api_browser_ipc.cc
browser/api/atom_api_event_emitter.cc
browser/api/atom_browser_bindings.cc
common/v8/native_type_conversions.h
common/v8/v8_value_converter.cc [moved from common/v8_value_converter_impl.cc with 91% similarity]
common/v8/v8_value_converter.h [moved from common/v8_value_converter_impl.h with 65% similarity]
renderer/api/atom_renderer_bindings.cc

index 192f186744681625e8d548322b8ff2765fb9ac99..9aa29a7a5cf9532f60acf897c18a497834824ff9 100644 (file)
--- a/atom.gyp
+++ b/atom.gyp
       'common/v8/node_common.h',
       'common/v8/scoped_persistent.h',
       'common/v8/native_type_conversions.h',
-      'common/v8_value_converter_impl.cc',
-      'common/v8_value_converter_impl.h',
+      'common/v8/v8_value_converter.cc',
+      'common/v8/v8_value_converter.h',
       'renderer/api/atom_api_renderer_ipc.cc',
       'renderer/api/atom_api_renderer_ipc.h',
       'renderer/api/atom_renderer_bindings.cc',
index c82bc670a3c7dd1d6f796d7bafbebf50d245f7a6..024bfffe5bc65d2c317071185bded565ed173f90 100644 (file)
@@ -10,7 +10,6 @@
 #include "content/public/browser/render_view_host.h"
 
 using content::RenderViewHost;
-using content::V8ValueConverter;
 
 namespace atom {
 
index 4a1bddb98b4e2c290a159acc3de979015ebf6e4f..07d98b3c0b6a43f489ce9d22156e1af18452c605 100644 (file)
@@ -39,7 +39,7 @@ bool EventEmitter::Emit(const std::string& name, base::ListValue* args) {
   v8::HandleScope handle_scope(node_isolate);
 
   v8::Handle<v8::Context> context = v8::Context::GetCurrent();
-  scoped_ptr<content::V8ValueConverter> converter(new V8ValueConverterImpl);
+  scoped_ptr<V8ValueConverter> converter(new V8ValueConverter);
 
   v8::Handle<v8::Object> v8_event = Event::CreateV8Object();
   Event* event = Event::Unwrap<Event>(v8_event);
index 6fa06e89695e1ac3a1a4412989b4d2f539dae3b1..4b3e79f59f32482373b13e68da2f678cd84927ed 100644 (file)
@@ -13,8 +13,6 @@
 
 #include "common/v8/node_common.h"
 
-using content::V8ValueConverter;
-
 namespace atom {
 
 AtomBrowserBindings::AtomBrowserBindings() {
@@ -29,7 +27,7 @@ void AtomBrowserBindings::OnRendererMessage(int process_id,
                                             const base::ListValue& args) {
   v8::HandleScope handle_scope(node_isolate);
 
-  scoped_ptr<V8ValueConverter> converter(new V8ValueConverterImpl());
+  scoped_ptr<V8ValueConverter> converter(new V8ValueConverter);
 
   // process.emit(channel, 'message', process_id, routing_id);
   std::vector<v8::Handle<v8::Value>> arguments;
@@ -62,7 +60,7 @@ void AtomBrowserBindings::OnRendererMessageSync(
     IPC::Message* message) {
   v8::HandleScope handle_scope(node_isolate);
 
-  scoped_ptr<V8ValueConverter> converter(new V8ValueConverterImpl());
+  scoped_ptr<V8ValueConverter> converter(new V8ValueConverter);
 
   // Create the event object.
   v8::Handle<v8::Object> event = api::Event::CreateV8Object();
index 47d2529e389fc791634972d4147e95f387fb21c3..4949b6147e51724001367b9956aeaf94f3e490ef 100644 (file)
@@ -16,7 +16,7 @@
 #include "browser/api/atom_api_window.h"
 #include "common/swap_or_assign.h"
 #include "common/v8/scoped_persistent.h"
-#include "common/v8_value_converter_impl.h"
+#include "common/v8/v8_value_converter.h"
 #include "content/public/renderer/v8_value_converter.h"
 #include "ui/gfx/rect.h"
 #include "url/gurl.h"
@@ -66,8 +66,7 @@ struct FromV8Value {
   }
 
   operator scoped_ptr<base::Value>() {
-    scoped_ptr<content::V8ValueConverter> converter(
-        new atom::V8ValueConverterImpl);
+    scoped_ptr<atom::V8ValueConverter> converter(new atom::V8ValueConverter);
     return scoped_ptr<base::Value>(
         converter->FromV8Value(value_, v8::Context::GetCurrent()));
   }
similarity index 91%
rename from common/v8_value_converter_impl.cc
rename to common/v8/v8_value_converter.cc
index 9ad9845e23f5d2f9aae9f7778c8cef724a0a65c6..8f87ffada9d95aae378a83a3ed752d0c4ae40f87 100644 (file)
@@ -2,52 +2,47 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
-#include "common/v8_value_converter_impl.h"
+#include "common/v8/v8_value_converter.h"
 
 #include <string>
 
 #include "base/logging.h"
 #include "base/memory/scoped_ptr.h"
 #include "base/values.h"
-#include "v8/include/v8.h"
 
 namespace atom {
 
-V8ValueConverterImpl::V8ValueConverterImpl()
+V8ValueConverter::V8ValueConverter()
     : date_allowed_(false),
       reg_exp_allowed_(false),
       function_allowed_(false),
       strip_null_from_objects_(false),
       avoid_identity_hash_for_testing_(false) {}
 
-void V8ValueConverterImpl::SetDateAllowed(bool val) {
+void V8ValueConverter::SetDateAllowed(bool val) {
   date_allowed_ = val;
 }
 
-void V8ValueConverterImpl::SetRegExpAllowed(bool val) {
+void V8ValueConverter::SetRegExpAllowed(bool val) {
   reg_exp_allowed_ = val;
 }
 
-void V8ValueConverterImpl::SetFunctionAllowed(bool val) {
+void V8ValueConverter::SetFunctionAllowed(bool val) {
   function_allowed_ = val;
 }
 
-void V8ValueConverterImpl::SetStripNullFromObjects(bool val) {
+void V8ValueConverter::SetStripNullFromObjects(bool val) {
   strip_null_from_objects_ = val;
 }
 
-void V8ValueConverterImpl::SetStrategy(Strategy* strategy) {
-  // Ignore any strategy.
-}
-
-v8::Handle<v8::Value> V8ValueConverterImpl::ToV8Value(
+v8::Handle<v8::Value> V8ValueConverter::ToV8Value(
     const base::Value* value, v8::Handle<v8::Context> context) const {
   v8::Context::Scope context_scope(context);
   v8::HandleScope handle_scope(v8::Isolate::GetCurrent());
   return handle_scope.Close(ToV8ValueImpl(value));
 }
 
-Value* V8ValueConverterImpl::FromV8Value(
+Value* V8ValueConverter::FromV8Value(
     v8::Handle<v8::Value> val,
     v8::Handle<v8::Context> context) const {
   v8::Context::Scope context_scope(context);
@@ -56,7 +51,7 @@ Value* V8ValueConverterImpl::FromV8Value(
   return FromV8ValueImpl(val, &unique_map);
 }
 
-v8::Handle<v8::Value> V8ValueConverterImpl::ToV8ValueImpl(
+v8::Handle<v8::Value> V8ValueConverter::ToV8ValueImpl(
      const base::Value* value) const {
   CHECK(value);
   switch (value->GetType()) {
@@ -99,7 +94,7 @@ v8::Handle<v8::Value> V8ValueConverterImpl::ToV8ValueImpl(
   }
 }
 
-v8::Handle<v8::Value> V8ValueConverterImpl::ToV8Array(
+v8::Handle<v8::Value> V8ValueConverter::ToV8Array(
     const base::ListValue* val) const {
   v8::Handle<v8::Array> result(v8::Array::New(val->GetSize()));
 
@@ -119,7 +114,7 @@ v8::Handle<v8::Value> V8ValueConverterImpl::ToV8Array(
   return result;
 }
 
-v8::Handle<v8::Value> V8ValueConverterImpl::ToV8Object(
+v8::Handle<v8::Value> V8ValueConverter::ToV8Object(
     const base::DictionaryValue* val) const {
   v8::Handle<v8::Object> result(v8::Object::New());
 
@@ -140,7 +135,7 @@ v8::Handle<v8::Value> V8ValueConverterImpl::ToV8Object(
   return result;
 }
 
-Value* V8ValueConverterImpl::FromV8ValueImpl(v8::Handle<v8::Value> val,
+Value* V8ValueConverter::FromV8ValueImpl(v8::Handle<v8::Value> val,
     HashToHandleMap* unique_map) const {
   CHECK(!val.IsEmpty());
 
@@ -200,7 +195,7 @@ Value* V8ValueConverterImpl::FromV8ValueImpl(v8::Handle<v8::Value> val,
   return NULL;
 }
 
-Value* V8ValueConverterImpl::FromV8Array(v8::Handle<v8::Array> val,
+Value* V8ValueConverter::FromV8Array(v8::Handle<v8::Array> val,
     HashToHandleMap* unique_map) const {
   if (!UpdateAndCheckUniqueness(unique_map, val))
     return base::Value::CreateNullValue();
@@ -237,7 +232,7 @@ Value* V8ValueConverterImpl::FromV8Array(v8::Handle<v8::Array> val,
   return result;
 }
 
-Value* V8ValueConverterImpl::FromV8Object(
+Value* V8ValueConverter::FromV8Object(
     v8::Handle<v8::Object> val,
     HashToHandleMap* unique_map) const {
   if (!UpdateAndCheckUniqueness(unique_map, val))
@@ -314,7 +309,7 @@ Value* V8ValueConverterImpl::FromV8Object(
   return result.release();
 }
 
-bool V8ValueConverterImpl::UpdateAndCheckUniqueness(
+bool V8ValueConverter::UpdateAndCheckUniqueness(
     HashToHandleMap* map,
     v8::Handle<v8::Object> handle) const {
   typedef HashToHandleMap::const_iterator Iterator;
similarity index 65%
rename from common/v8_value_converter_impl.h
rename to common/v8/v8_value_converter.h
index 38d19a4d521b35cbc6c8d4050f29f6ddd72c1329..bd25a5880307d7efbd5748298863be82a213cdb8 100644 (file)
@@ -2,14 +2,14 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
-#ifndef ATOM_COMMON_V8_VALUE_CONVERTER_IMPL_H_
-#define ATOM_COMMON_V8_VALUE_CONVERTER_IMPL_H_
+#ifndef ATOM_COMMON_V8_V8_VALUE_CONVERTER_H_
+#define ATOM_COMMON_V8_V8_VALUE_CONVERTER_H_
 
 #include <map>
 
 #include "base/basictypes.h"
 #include "base/compiler_specific.h"
-#include "content/public/renderer/v8_value_converter.h"
+#include "v8/include/v8.h"
 
 namespace base {
 class BinaryValue;
@@ -20,27 +20,20 @@ class Value;
 
 namespace atom {
 
-// The content::V8ValueConverter depends on WebKit, we get rid of the WebKit
-// dependency by removing support of binary data.
-class V8ValueConverterImpl : public content::V8ValueConverter {
+class V8ValueConverter {
  public:
-  V8ValueConverterImpl();
-
-  // V8ValueConverter implementation.
-  virtual void SetDateAllowed(bool val) OVERRIDE;
-  virtual void SetRegExpAllowed(bool val) OVERRIDE;
-  virtual void SetFunctionAllowed(bool val) OVERRIDE;
-  virtual void SetStripNullFromObjects(bool val) OVERRIDE;
-  virtual void SetStrategy(Strategy* strategy) OVERRIDE;
-  virtual v8::Handle<v8::Value> ToV8Value(
-      const base::Value* value,
-      v8::Handle<v8::Context> context) const OVERRIDE;
-  virtual base::Value* FromV8Value(
-      v8::Handle<v8::Value> value,
-      v8::Handle<v8::Context> context) const OVERRIDE;
+  V8ValueConverter();
+
+  void SetDateAllowed(bool val);
+  void SetRegExpAllowed(bool val);
+  void SetFunctionAllowed(bool val);
+  void SetStripNullFromObjects(bool val);
+  v8::Handle<v8::Value> ToV8Value(const base::Value* value,
+                                  v8::Handle<v8::Context> context) const;
+  base::Value* FromV8Value(v8::Handle<v8::Value> value,
+                           v8::Handle<v8::Context> context) const;
 
  private:
-  friend class ScopedAvoidIdentityHashForTesting;
   typedef std::multimap<int, v8::Handle<v8::Object> > HashToHandleMap;
 
   v8::Handle<v8::Value> ToV8ValueImpl(const base::Value* value) const;
@@ -79,9 +72,9 @@ class V8ValueConverterImpl : public content::V8ValueConverter {
 
   bool avoid_identity_hash_for_testing_;
 
-  DISALLOW_COPY_AND_ASSIGN(V8ValueConverterImpl);
+  DISALLOW_COPY_AND_ASSIGN(V8ValueConverter);
 };
 
 }  // namespace atom
 
-#endif  // ATOM_COMMON_V8_VALUE_CONVERTER_IMPL_H_
+#endif  // ATOM_COMMON_V8_V8_VALUE_CONVERTER_H_
index f9d3975490d68355f74ea8cdcf91148514e0f448..499410bc0710fc083bd6bef33b7f24a4dd878219 100644 (file)
@@ -11,8 +11,6 @@
 
 #include "common/v8/node_common.h"
 
-using content::V8ValueConverter;
-
 namespace atom {
 
 namespace {
@@ -60,7 +58,7 @@ void AtomRendererBindings::OnBrowserMessage(content::RenderView* render_view,
   v8::Context::Scope context_scope(context);
 
   v8::Handle<v8::Object> process = GetProcessObject(context);
-  scoped_ptr<V8ValueConverter> converter(V8ValueConverter::create());
+  scoped_ptr<V8ValueConverter> converter(new V8ValueConverter);
 
   std::vector<v8::Handle<v8::Value>> arguments;
   arguments.reserve(1 + args.GetSize());