From: Cheng Zhao Date: Fri, 7 Aug 2015 11:34:00 +0000 (+0800) Subject: Use WebScopedRunV8Script in converted C++ functions X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=1bb0dde360e0da83f955aba4407b4d9a6a9ce6e6;p=platform%2Fframework%2Fweb%2Fcrosswalk-tizen.git Use WebScopedRunV8Script in converted C++ functions --- diff --git a/atom/browser/api/atom_api_web_contents.cc b/atom/browser/api/atom_api_web_contents.cc index 6adcf53..63707f8 100644 --- a/atom/browser/api/atom_api_web_contents.cc +++ b/atom/browser/api/atom_api_web_contents.cc @@ -13,7 +13,7 @@ #include "atom/browser/native_window.h" #include "atom/browser/web_view_guest_delegate.h" #include "atom/common/api/api_messages.h" -#include "atom/common/event_emitter_caller.h" +#include "atom/common/api/event_emitter_caller.h" #include "atom/common/native_mate_converters/callback.h" #include "atom/common/native_mate_converters/file_path_converter.h" #include "atom/common/native_mate_converters/gfx_converter.h" diff --git a/atom/browser/api/event_emitter.h b/atom/browser/api/event_emitter.h index 178c61d..4fb953b 100644 --- a/atom/browser/api/event_emitter.h +++ b/atom/browser/api/event_emitter.h @@ -7,7 +7,7 @@ #include -#include "atom/common/event_emitter_caller.h" +#include "atom/common/api/event_emitter_caller.h" #include "native_mate/wrappable.h" namespace content { diff --git a/atom/common/event_emitter_caller.cc b/atom/common/api/event_emitter_caller.cc similarity index 69% rename from atom/common/event_emitter_caller.cc rename to atom/common/api/event_emitter_caller.cc index 68c4821..6b0a07a 100644 --- a/atom/common/event_emitter_caller.cc +++ b/atom/common/api/event_emitter_caller.cc @@ -2,8 +2,9 @@ // Use of this source code is governed by the MIT license that can be // found in the LICENSE file. -#include "atom/common/event_emitter_caller.h" +#include "atom/common/api/event_emitter_caller.h" +#include "atom/common/api/locker.h" #include "base/memory/scoped_ptr.h" #include "third_party/WebKit/public/web/WebScopedMicrotaskSuppression.h" @@ -13,22 +14,13 @@ namespace mate { namespace internal { -namespace { - -// Returns whether current process is browser process, currently we detect it -// by checking whether current has used V8 Lock, but it might be a bad idea. -inline bool IsBrowserProcess() { - return v8::Locker::IsActive(); -} - -} // namespace - v8::Local CallEmitWithArgs(v8::Isolate* isolate, v8::Local obj, ValueVector* args) { // Perform microtask checkpoint after running JavaScript. scoped_ptr script_scope( - IsBrowserProcess() ? nullptr : new blink::WebScopedRunV8Script(isolate)); + Locker::IsBrowserProcess() ? + nullptr : new blink::WebScopedRunV8Script(isolate)); // Use node::MakeCallback to call the callback, and it will also run pending // tasks in Node.js. return node::MakeCallback( diff --git a/atom/common/event_emitter_caller.h b/atom/common/api/event_emitter_caller.h similarity index 92% rename from atom/common/event_emitter_caller.h rename to atom/common/api/event_emitter_caller.h index e8ad50a..a2567da 100644 --- a/atom/common/event_emitter_caller.h +++ b/atom/common/api/event_emitter_caller.h @@ -2,8 +2,8 @@ // Use of this source code is governed by the MIT license that can be // found in the LICENSE file. -#ifndef ATOM_COMMON_EVENT_EMITTER_CALLER_H_ -#define ATOM_COMMON_EVENT_EMITTER_CALLER_H_ +#ifndef ATOM_COMMON_API_EVENT_EMITTER_CALLER_H_ +#define ATOM_COMMON_API_EVENT_EMITTER_CALLER_H_ #include @@ -50,4 +50,4 @@ v8::Local EmitEvent(v8::Isolate* isolate, } // namespace mate -#endif // ATOM_COMMON_EVENT_EMITTER_CALLER_H_ +#endif // ATOM_COMMON_API_EVENT_EMITTER_CALLER_H_ diff --git a/atom/common/api/locker.cc b/atom/common/api/locker.cc new file mode 100644 index 0000000..fe0b234 --- /dev/null +++ b/atom/common/api/locker.cc @@ -0,0 +1,17 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE.chromium file. + +#include "atom/common/api/locker.h" + +namespace mate { + +Locker::Locker(v8::Isolate* isolate) { + if (IsBrowserProcess()) + locker_.reset(new v8::Locker(isolate)); +} + +Locker::~Locker() { +} + +} // namespace mate diff --git a/atom/common/api/locker.h b/atom/common/api/locker.h new file mode 100644 index 0000000..201217f --- /dev/null +++ b/atom/common/api/locker.h @@ -0,0 +1,34 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE.chromium file. + +#ifndef ATOM_COMMON_API_LOCKER_H_ +#define ATOM_COMMON_API_LOCKER_H_ + +#include "base/memory/scoped_ptr.h" +#include "v8/include/v8.h" + +namespace mate { + +// Only lock when lockers are used in current thread. +class Locker { + public: + explicit Locker(v8::Isolate* isolate); + ~Locker(); + + // Returns whether current process is browser process, currently we detect it + // by checking whether current has used V8 Lock, but it might be a bad idea. + static inline bool IsBrowserProcess() { return v8::Locker::IsActive(); } + + private: + void* operator new(size_t size); + void operator delete(void*, size_t); + + scoped_ptr locker_; + + DISALLOW_COPY_AND_ASSIGN(Locker); +}; + +} // namespace mate + +#endif // ATOM_COMMON_API_LOCKER_H_ diff --git a/atom/common/native_mate_converters/callback.h b/atom/common/native_mate_converters/callback.h index e7dc6af..6e51cda 100644 --- a/atom/common/native_mate_converters/callback.h +++ b/atom/common/native_mate_converters/callback.h @@ -2,13 +2,17 @@ // Use of this source code is governed by the MIT license that can be // found in the LICENSE file. +#ifndef ATOM_COMMON_NATIVE_MATE_CONVERTERS_CALLBACK_H_ +#define ATOM_COMMON_NATIVE_MATE_CONVERTERS_CALLBACK_H_ + #include +#include "atom/common/api/locker.h" #include "base/bind.h" #include "base/callback.h" #include "native_mate/function_template.h" -#include "native_mate/locker.h" #include "native_mate/scoped_persistent.h" +#include "third_party/WebKit/public/web/WebScopedMicrotaskSuppression.h" namespace mate { @@ -25,6 +29,9 @@ struct V8FunctionInvoker(ArgTypes...)> { ArgTypes... raw) { Locker locker(isolate); v8::EscapableHandleScope handle_scope(isolate); + scoped_ptr script_scope( + Locker::IsBrowserProcess() ? + nullptr : new blink::WebScopedRunV8Script(isolate)); v8::Local holder = function->NewHandle(); v8::Local context = holder->CreationContext(); v8::Context::Scope context_scope(context); @@ -40,6 +47,9 @@ struct V8FunctionInvoker { ArgTypes... raw) { Locker locker(isolate); v8::HandleScope handle_scope(isolate); + scoped_ptr script_scope( + Locker::IsBrowserProcess() ? + nullptr : new blink::WebScopedRunV8Script(isolate)); v8::Local holder = function->NewHandle(); v8::Local context = holder->CreationContext(); v8::Context::Scope context_scope(context); @@ -54,6 +64,9 @@ struct V8FunctionInvoker { ArgTypes... raw) { Locker locker(isolate); v8::HandleScope handle_scope(isolate); + scoped_ptr script_scope( + Locker::IsBrowserProcess() ? + nullptr : new blink::WebScopedRunV8Script(isolate)); v8::Local holder = function->NewHandle(); v8::Local context = holder->CreationContext(); v8::Context::Scope context_scope(context); @@ -87,3 +100,5 @@ struct Converter > { }; } // namespace mate + +#endif // ATOM_COMMON_NATIVE_MATE_CONVERTERS_CALLBACK_H_ diff --git a/atom/common/node_bindings.cc b/atom/common/node_bindings.cc index b329589..304b6a7 100644 --- a/atom/common/node_bindings.cc +++ b/atom/common/node_bindings.cc @@ -7,8 +7,9 @@ #include #include +#include "atom/common/api/event_emitter_caller.h" +#include "atom/common/api/locker.h" #include "atom/common/atom_command_line.h" -#include "atom/common/event_emitter_caller.h" #include "atom/common/native_mate_converters/file_path_converter.h" #include "base/command_line.h" #include "base/base_paths.h" @@ -17,7 +18,6 @@ #include "base/path_service.h" #include "content/public/browser/browser_thread.h" #include "content/public/common/content_paths.h" -#include "native_mate/locker.h" #include "native_mate/dictionary.h" #include "third_party/WebKit/public/web/WebScopedMicrotaskSuppression.h" diff --git a/atom/renderer/atom_render_view_observer.cc b/atom/renderer/atom_render_view_observer.cc index 6864813..1f199ea 100644 --- a/atom/renderer/atom_render_view_observer.cc +++ b/atom/renderer/atom_render_view_observer.cc @@ -11,7 +11,7 @@ #include "atom/common/native_mate_converters/string16_converter.h" #include "atom/common/api/api_messages.h" -#include "atom/common/event_emitter_caller.h" +#include "atom/common/api/event_emitter_caller.h" #include "atom/common/native_mate_converters/value_converter.h" #include "atom/common/options_switches.h" #include "atom/renderer/atom_renderer_client.h" diff --git a/filenames.gypi b/filenames.gypi index 977eb16..b062c6e 100644 --- a/filenames.gypi +++ b/filenames.gypi @@ -238,6 +238,10 @@ 'atom/common/api/atom_api_v8_util.cc', 'atom/common/api/atom_bindings.cc', 'atom/common/api/atom_bindings.h', + 'atom/common/api/event_emitter_caller.cc', + 'atom/common/api/event_emitter_caller.h', + 'atom/common/api/locker.cc', + 'atom/common/api/locker.h', 'atom/common/api/object_life_monitor.cc', 'atom/common/api/object_life_monitor.h', 'atom/common/asar/archive.cc', @@ -266,8 +270,6 @@ 'atom/common/crash_reporter/win/crash_service_main.h', 'atom/common/draggable_region.cc', 'atom/common/draggable_region.h', - 'atom/common/event_emitter_caller.cc', - 'atom/common/event_emitter_caller.h', 'atom/common/google_api_key.h', 'atom/common/id_weak_map.cc', 'atom/common/id_weak_map.h', diff --git a/script/lib/config.py b/script/lib/config.py index 144ec87..1298651 100644 --- a/script/lib/config.py +++ b/script/lib/config.py @@ -7,7 +7,7 @@ import sys BASE_URL = os.getenv('LIBCHROMIUMCONTENT_MIRROR') or \ - 'http://gh-contractor-zcbenz.s3.amazonaws.com/libchromiumcontent' + 'http://github-janky-artifacts.s3.amazonaws.com/libchromiumcontent' LIBCHROMIUMCONTENT_COMMIT = 'dd51a41b42246b0b5159bfad5e327c8cf10bc585' PLATFORM = { diff --git a/vendor/native_mate b/vendor/native_mate index ebcf4c0..67d9eaa 160000 --- a/vendor/native_mate +++ b/vendor/native_mate @@ -1 +1 @@ -Subproject commit ebcf4c022467a43a5379446e1c031ffd10438b9c +Subproject commit 67d9eaa215e8727d86dc7b1f7a10be8699848f1f