diff --git a/atom.gyp b/atom.gyp index 192f1867446..9aa29a7a5cf 100644 --- a/atom.gyp +++ b/atom.gyp @@ -168,8 +168,8 @@ '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', diff --git a/browser/api/atom_api_browser_ipc.cc b/browser/api/atom_api_browser_ipc.cc index c82bc670a3c..024bfffe5bc 100644 --- a/browser/api/atom_api_browser_ipc.cc +++ b/browser/api/atom_api_browser_ipc.cc @@ -10,7 +10,6 @@ #include "content/public/browser/render_view_host.h" using content::RenderViewHost; -using content::V8ValueConverter; namespace atom { diff --git a/browser/api/atom_api_event_emitter.cc b/browser/api/atom_api_event_emitter.cc index 4a1bddb98b4..07d98b3c0b6 100644 --- a/browser/api/atom_api_event_emitter.cc +++ b/browser/api/atom_api_event_emitter.cc @@ -39,7 +39,7 @@ bool EventEmitter::Emit(const std::string& name, base::ListValue* args) { v8::HandleScope handle_scope(node_isolate); v8::Handle context = v8::Context::GetCurrent(); - scoped_ptr converter(new V8ValueConverterImpl); + scoped_ptr converter(new V8ValueConverter); v8::Handle v8_event = Event::CreateV8Object(); Event* event = Event::Unwrap(v8_event); diff --git a/browser/api/atom_browser_bindings.cc b/browser/api/atom_browser_bindings.cc index 6fa06e89695..4b3e79f59f3 100644 --- a/browser/api/atom_browser_bindings.cc +++ b/browser/api/atom_browser_bindings.cc @@ -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 converter(new V8ValueConverterImpl()); + scoped_ptr converter(new V8ValueConverter); // process.emit(channel, 'message', process_id, routing_id); std::vector> arguments; @@ -62,7 +60,7 @@ void AtomBrowserBindings::OnRendererMessageSync( IPC::Message* message) { v8::HandleScope handle_scope(node_isolate); - scoped_ptr converter(new V8ValueConverterImpl()); + scoped_ptr converter(new V8ValueConverter); // Create the event object. v8::Handle event = api::Event::CreateV8Object(); diff --git a/common/v8/native_type_conversions.h b/common/v8/native_type_conversions.h index 47d2529e389..4949b6147e5 100644 --- a/common/v8/native_type_conversions.h +++ b/common/v8/native_type_conversions.h @@ -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() { - scoped_ptr converter( - new atom::V8ValueConverterImpl); + scoped_ptr converter(new atom::V8ValueConverter); return scoped_ptr( converter->FromV8Value(value_, v8::Context::GetCurrent())); } diff --git a/common/v8_value_converter_impl.cc b/common/v8/v8_value_converter.cc similarity index 91% rename from common/v8_value_converter_impl.cc rename to common/v8/v8_value_converter.cc index 9ad9845e23f..8f87ffada9d 100644 --- a/common/v8_value_converter_impl.cc +++ b/common/v8/v8_value_converter.cc @@ -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 #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 V8ValueConverterImpl::ToV8Value( +v8::Handle V8ValueConverter::ToV8Value( const base::Value* value, v8::Handle 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 val, v8::Handle context) const { v8::Context::Scope context_scope(context); @@ -56,7 +51,7 @@ Value* V8ValueConverterImpl::FromV8Value( return FromV8ValueImpl(val, &unique_map); } -v8::Handle V8ValueConverterImpl::ToV8ValueImpl( +v8::Handle V8ValueConverter::ToV8ValueImpl( const base::Value* value) const { CHECK(value); switch (value->GetType()) { @@ -99,7 +94,7 @@ v8::Handle V8ValueConverterImpl::ToV8ValueImpl( } } -v8::Handle V8ValueConverterImpl::ToV8Array( +v8::Handle V8ValueConverter::ToV8Array( const base::ListValue* val) const { v8::Handle result(v8::Array::New(val->GetSize())); @@ -119,7 +114,7 @@ v8::Handle V8ValueConverterImpl::ToV8Array( return result; } -v8::Handle V8ValueConverterImpl::ToV8Object( +v8::Handle V8ValueConverter::ToV8Object( const base::DictionaryValue* val) const { v8::Handle result(v8::Object::New()); @@ -140,7 +135,7 @@ v8::Handle V8ValueConverterImpl::ToV8Object( return result; } -Value* V8ValueConverterImpl::FromV8ValueImpl(v8::Handle val, +Value* V8ValueConverter::FromV8ValueImpl(v8::Handle val, HashToHandleMap* unique_map) const { CHECK(!val.IsEmpty()); @@ -200,7 +195,7 @@ Value* V8ValueConverterImpl::FromV8ValueImpl(v8::Handle val, return NULL; } -Value* V8ValueConverterImpl::FromV8Array(v8::Handle val, +Value* V8ValueConverter::FromV8Array(v8::Handle val, HashToHandleMap* unique_map) const { if (!UpdateAndCheckUniqueness(unique_map, val)) return base::Value::CreateNullValue(); @@ -237,7 +232,7 @@ Value* V8ValueConverterImpl::FromV8Array(v8::Handle val, return result; } -Value* V8ValueConverterImpl::FromV8Object( +Value* V8ValueConverter::FromV8Object( v8::Handle 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 handle) const { typedef HashToHandleMap::const_iterator Iterator; diff --git a/common/v8_value_converter_impl.h b/common/v8/v8_value_converter.h similarity index 65% rename from common/v8_value_converter_impl.h rename to common/v8/v8_value_converter.h index 38d19a4d521..bd25a588030 100644 --- a/common/v8_value_converter_impl.h +++ b/common/v8/v8_value_converter.h @@ -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 #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(); - // 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 ToV8Value( - const base::Value* value, - v8::Handle context) const OVERRIDE; - virtual base::Value* FromV8Value( - v8::Handle value, - v8::Handle context) const OVERRIDE; + void SetDateAllowed(bool val); + void SetRegExpAllowed(bool val); + void SetFunctionAllowed(bool val); + void SetStripNullFromObjects(bool val); + v8::Handle ToV8Value(const base::Value* value, + v8::Handle context) const; + base::Value* FromV8Value(v8::Handle value, + v8::Handle context) const; private: - friend class ScopedAvoidIdentityHashForTesting; typedef std::multimap > HashToHandleMap; v8::Handle 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_ diff --git a/renderer/api/atom_renderer_bindings.cc b/renderer/api/atom_renderer_bindings.cc index f9d3975490d..499410bc071 100644 --- a/renderer/api/atom_renderer_bindings.cc +++ b/renderer/api/atom_renderer_bindings.cc @@ -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 process = GetProcessObject(context); - scoped_ptr converter(V8ValueConverter::create()); + scoped_ptr converter(new V8ValueConverter); std::vector> arguments; arguments.reserve(1 + args.GetSize());