From 409215cf10d51ba0f315b356a2273dba8aed02b4 Mon Sep 17 00:00:00 2001 From: Marshall Greenblatt Date: Thu, 11 Apr 2013 20:47:15 +0000 Subject: [PATCH] Merge revision 1209 changes: - Remove V8 worker bindings (issue #451). git-svn-id: https://chromiumembedded.googlecode.com/svn/branches/1453@1210 5089003a-bbd8-11dd-ad1f-f1f9622dbc98 --- .../capi/cef_render_process_handler_capi.h | 33 --- cef3/include/cef_render_process_handler.h | 37 --- .../renderer/content_renderer_client.cc | 77 ----- .../libcef/renderer/content_renderer_client.h | 2 - cef3/libcef/renderer/v8_impl.cc | 5 - .../cpptoc/render_process_handler_cpptoc.cc | 90 ------ .../ctocpp/render_process_handler_ctocpp.cc | 81 ------ .../ctocpp/render_process_handler_ctocpp.h | 7 - cef3/patch/patch.cfg | 5 - cef3/patch/patches/webkit_451.patch | 263 ------------------ cef3/tests/cefclient/client_app.cpp | 29 -- cef3/tests/cefclient/client_app.h | 33 --- cef3/tests/unittests/v8_unittest.cc | 240 +--------------- 13 files changed, 4 insertions(+), 898 deletions(-) delete mode 100644 cef3/patch/patches/webkit_451.patch diff --git a/cef3/include/capi/cef_render_process_handler_capi.h b/cef3/include/capi/cef_render_process_handler_capi.h index 13949fe8a..b59e117b7 100644 --- a/cef3/include/capi/cef_render_process_handler_capi.h +++ b/cef3/include/capi/cef_render_process_handler_capi.h @@ -132,39 +132,6 @@ typedef struct _cef_render_process_handler_t { struct _cef_v8context_t* context, struct _cef_v8exception_t* exception, struct _cef_v8stack_trace_t* stackTrace); - /// - // Called on the WebWorker thread immediately after the V8 context for a new - // WebWorker has been created. To retrieve the JavaScript 'self' object use - // the cef_v8context_t::get_global() function. V8 handles can only be accessed - // from the thread on which they are created. A task runner for posting tasks - // on the associated thread can be retrieved via the - // cef_v8context_t::get_task_runner() function. - /// - void (CEF_CALLBACK *on_worker_context_created)( - struct _cef_render_process_handler_t* self, int worker_id, - const cef_string_t* url, struct _cef_v8context_t* context); - - /// - // Called on the WebWorker thread immediately before the V8 context for a - // WebWorker is released. No references to the context should be kept after - // this function is called. Any tasks posted or pending on the WebWorker - // thread after this function is called may not be executed. - /// - void (CEF_CALLBACK *on_worker_context_released)( - struct _cef_render_process_handler_t* self, int worker_id, - const cef_string_t* url, struct _cef_v8context_t* context); - - /// - // Called on the WebWorker thread for global uncaught exceptions in a - // WebWorker. Execution of this callback is disabled by default. To enable set - // CefSettings.uncaught_exception_stack_size > 0. - /// - void (CEF_CALLBACK *on_worker_uncaught_exception)( - struct _cef_render_process_handler_t* self, int worker_id, - const cef_string_t* url, struct _cef_v8context_t* context, - struct _cef_v8exception_t* exception, - struct _cef_v8stack_trace_t* stackTrace); - /// // Called when a new node in the the browser gets focus. The |node| value may // be NULL if no specific node has gained focus. The node object passed to diff --git a/cef3/include/cef_render_process_handler.h b/cef3/include/cef_render_process_handler.h index 0f21b1d2c..7ba767265 100644 --- a/cef3/include/cef_render_process_handler.h +++ b/cef3/include/cef_render_process_handler.h @@ -130,43 +130,6 @@ class CefRenderProcessHandler : public virtual CefBase { CefRefPtr exception, CefRefPtr stackTrace) {} - /// - // Called on the WebWorker thread immediately after the V8 context for a new - // WebWorker has been created. To retrieve the JavaScript 'self' object use - // the CefV8Context::GetGlobal() method. V8 handles can only be accessed from - // the thread on which they are created. A task runner for posting tasks on - // the associated thread can be retrieved via the - // CefV8Context::GetTaskRunner() method. - /// - /*--cef()--*/ - virtual void OnWorkerContextCreated(int worker_id, - const CefString& url, - CefRefPtr context) {} - - /// - // Called on the WebWorker thread immediately before the V8 context for a - // WebWorker is released. No references to the context should be kept after - // this method is called. Any tasks posted or pending on the WebWorker - // thread after this method is called may not be executed. - /// - /*--cef()--*/ - virtual void OnWorkerContextReleased(int worker_id, - const CefString& url, - CefRefPtr context) {} - - /// - // Called on the WebWorker thread for global uncaught exceptions in a - // WebWorker. Execution of this callback is disabled by default. To enable set - // CefSettings.uncaught_exception_stack_size > 0. - /// - /*--cef()--*/ - virtual void OnWorkerUncaughtException( - int worker_id, - const CefString& url, - CefRefPtr context, - CefRefPtr exception, - CefRefPtr stackTrace) {} - /// // Called when a new node in the the browser gets focus. The |node| value may // be empty if no specific node has gained focus. The node object passed to diff --git a/cef3/libcef/renderer/content_renderer_client.cc b/cef3/libcef/renderer/content_renderer_client.cc index 280f5d9d6..78ca2b17c 100644 --- a/cef3/libcef/renderer/content_renderer_client.cc +++ b/cef3/libcef/renderer/content_renderer_client.cc @@ -48,7 +48,6 @@ MSVC_POP_WARNING(); #include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityPolicy.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebWorkerInfo.h" -#include "third_party/WebKit/Source/WebKit/chromium/public/WebWorkerScriptObserver.h" #include "v8/include/v8.h" #include "webkit/glue/worker_task_runner.h" @@ -131,79 +130,6 @@ class CefWebWorkerTaskRunner : public base::SequencedTaskRunner, } // namespace - -class CefWebWorkerScriptObserver : public WebKit::WebWorkerScriptObserver { - public: - CefWebWorkerScriptObserver() { - } - - virtual void didCreateWorkerScriptContext( - const WebKit::WebWorkerRunLoop& run_loop, - const WebKit::WebURL& url, - v8::Handle context) OVERRIDE { - // Create global objects associated with the WebWorker Isolate. - CefV8IsolateCreated(); - - int stack_size = - CefContentRendererClient::Get()->uncaught_exception_stack_size(); - if (stack_size > 0) - CefV8SetUncaughtExceptionStackSize(stack_size); - - webkit_glue::WorkerTaskRunner* worker_runner = - webkit_glue::WorkerTaskRunner::Instance(); - int worker_id = worker_runner->CurrentWorkerId(); - DCHECK_GT(worker_id, 0); - GURL gurl = GURL(url); - - CefV8SetWorkerAttributes(worker_id, gurl); - - // Notify the render process handler. - CefRefPtr application = CefContentClient::Get()->application(); - if (application.get()) { - CefRefPtr handler = - application->GetRenderProcessHandler(); - if (handler.get()) { - v8::HandleScope handle_scope; - v8::Context::Scope scope(context); - - CefRefPtr contextPtr(new CefV8ContextImpl(context)); - handler->OnWorkerContextCreated(worker_id, gurl.spec(), contextPtr); - } - } - } - - virtual void willReleaseWorkerScriptContext( - const WebKit::WebWorkerRunLoop& run_loop, - const WebKit::WebURL& url, - v8::Handle context) OVERRIDE { - v8::HandleScope handle_scope; - v8::Context::Scope scope(context); - - // Notify the render process handler. - CefRefPtr application = CefContentClient::Get()->application(); - if (application.get()) { - CefRefPtr handler = - application->GetRenderProcessHandler(); - if (handler.get()) { - webkit_glue::WorkerTaskRunner* worker_runner = - webkit_glue::WorkerTaskRunner::Instance(); - int worker_id = worker_runner->CurrentWorkerId(); - DCHECK_GT(worker_id, 0); - - CefRefPtr contextPtr(new CefV8ContextImpl(context)); - GURL gurl = GURL(url); - handler->OnWorkerContextReleased(worker_id, gurl.spec(), contextPtr); - } - } - - CefV8ReleaseContext(context); - - // Destroy global objects associated with the WebWorker Isolate. - CefV8IsolateDestroyed(); - } -}; - - struct CefContentRendererClient::SchemeInfo { std::string scheme_name; bool is_local; @@ -286,9 +212,6 @@ void CefContentRendererClient::WebKitInitialized() { WebKit::WebRuntimeFeatures::enableMediaStream( command_line.HasSwitch(switches::kEnableMediaStream)); - worker_script_observer_.reset(new CefWebWorkerScriptObserver()); - WebKit::WebWorkerInfo::addScriptObserver(worker_script_observer_.get()); - if (!scheme_info_list_.empty()) { // Register the custom schemes. SchemeInfoList::const_iterator it = scheme_info_list_.begin(); diff --git a/cef3/libcef/renderer/content_renderer_client.h b/cef3/libcef/renderer/content_renderer_client.h index 56e8ffb6c..237f0eac1 100644 --- a/cef3/libcef/renderer/content_renderer_client.h +++ b/cef3/libcef/renderer/content_renderer_client.h @@ -21,7 +21,6 @@ #include "content/public/renderer/content_renderer_client.h" class CefRenderProcessObserver; -class CefWebWorkerScriptObserver; struct Cef_CrossOriginWhiteListEntry_Params; class CefContentRendererClient : public content::ContentRendererClient, @@ -103,7 +102,6 @@ class CefContentRendererClient : public content::ContentRendererClient, scoped_refptr render_task_runner_; scoped_ptr observer_; - scoped_ptr worker_script_observer_; // Map of RenderView pointers to CefBrowserImpl references. typedef std::map > BrowserMap; diff --git a/cef3/libcef/renderer/v8_impl.cc b/cef3/libcef/renderer/v8_impl.cc index 5288bddc1..2b6356f4a 100644 --- a/cef3/libcef/renderer/v8_impl.cc +++ b/cef3/libcef/renderer/v8_impl.cc @@ -706,11 +706,6 @@ void MessageListenerCallbackImpl(v8::Handle message, if (CEF_CURRENTLY_ON_RT()) { handler->OnUncaughtException(context->GetBrowser(), context->GetFrame(), context, exception, stackTrace); - } else { - CefV8IsolateManager* manager = GetIsolateManager(); - DCHECK_GT(manager->worker_id(), 0); - handler->OnWorkerUncaughtException(manager->worker_id(), - manager->worker_url().spec(), context, exception, stackTrace); } } diff --git a/cef3/libcef_dll/cpptoc/render_process_handler_cpptoc.cc b/cef3/libcef_dll/cpptoc/render_process_handler_cpptoc.cc index 11684705a..fb8bc84df 100644 --- a/cef3/libcef_dll/cpptoc/render_process_handler_cpptoc.cc +++ b/cef3/libcef_dll/cpptoc/render_process_handler_cpptoc.cc @@ -218,90 +218,6 @@ void CEF_CALLBACK render_process_handler_on_uncaught_exception( CefV8StackTraceCToCpp::Wrap(stackTrace)); } -void CEF_CALLBACK render_process_handler_on_worker_context_created( - struct _cef_render_process_handler_t* self, int worker_id, - const cef_string_t* url, struct _cef_v8context_t* context) { - // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING - - DCHECK(self); - if (!self) - return; - // Verify param: url; type: string_byref_const - DCHECK(url); - if (!url) - return; - // Verify param: context; type: refptr_diff - DCHECK(context); - if (!context) - return; - - // Execute - CefRenderProcessHandlerCppToC::Get(self)->OnWorkerContextCreated( - worker_id, - CefString(url), - CefV8ContextCToCpp::Wrap(context)); -} - -void CEF_CALLBACK render_process_handler_on_worker_context_released( - struct _cef_render_process_handler_t* self, int worker_id, - const cef_string_t* url, struct _cef_v8context_t* context) { - // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING - - DCHECK(self); - if (!self) - return; - // Verify param: url; type: string_byref_const - DCHECK(url); - if (!url) - return; - // Verify param: context; type: refptr_diff - DCHECK(context); - if (!context) - return; - - // Execute - CefRenderProcessHandlerCppToC::Get(self)->OnWorkerContextReleased( - worker_id, - CefString(url), - CefV8ContextCToCpp::Wrap(context)); -} - -void CEF_CALLBACK render_process_handler_on_worker_uncaught_exception( - struct _cef_render_process_handler_t* self, int worker_id, - const cef_string_t* url, struct _cef_v8context_t* context, - struct _cef_v8exception_t* exception, - struct _cef_v8stack_trace_t* stackTrace) { - // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING - - DCHECK(self); - if (!self) - return; - // Verify param: url; type: string_byref_const - DCHECK(url); - if (!url) - return; - // Verify param: context; type: refptr_diff - DCHECK(context); - if (!context) - return; - // Verify param: exception; type: refptr_diff - DCHECK(exception); - if (!exception) - return; - // Verify param: stackTrace; type: refptr_diff - DCHECK(stackTrace); - if (!stackTrace) - return; - - // Execute - CefRenderProcessHandlerCppToC::Get(self)->OnWorkerUncaughtException( - worker_id, - CefString(url), - CefV8ContextCToCpp::Wrap(context), - CefV8ExceptionCToCpp::Wrap(exception), - CefV8StackTraceCToCpp::Wrap(stackTrace)); -} - void CEF_CALLBACK render_process_handler_on_focused_node_changed( struct _cef_render_process_handler_t* self, cef_browser_t* browser, cef_frame_t* frame, cef_domnode_t* node) { @@ -374,12 +290,6 @@ CefRenderProcessHandlerCppToC::CefRenderProcessHandlerCppToC( render_process_handler_on_context_released; struct_.struct_.on_uncaught_exception = render_process_handler_on_uncaught_exception; - struct_.struct_.on_worker_context_created = - render_process_handler_on_worker_context_created; - struct_.struct_.on_worker_context_released = - render_process_handler_on_worker_context_released; - struct_.struct_.on_worker_uncaught_exception = - render_process_handler_on_worker_uncaught_exception; struct_.struct_.on_focused_node_changed = render_process_handler_on_focused_node_changed; struct_.struct_.on_process_message_received = diff --git a/cef3/libcef_dll/ctocpp/render_process_handler_ctocpp.cc b/cef3/libcef_dll/ctocpp/render_process_handler_ctocpp.cc index 0374e5e7b..4a66178fb 100644 --- a/cef3/libcef_dll/ctocpp/render_process_handler_ctocpp.cc +++ b/cef3/libcef_dll/ctocpp/render_process_handler_ctocpp.cc @@ -214,87 +214,6 @@ void CefRenderProcessHandlerCToCpp::OnUncaughtException( CefV8StackTraceCppToC::Wrap(stackTrace)); } -void CefRenderProcessHandlerCToCpp::OnWorkerContextCreated(int worker_id, - const CefString& url, CefRefPtr context) { - if (CEF_MEMBER_MISSING(struct_, on_worker_context_created)) - return; - - // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING - - // Verify param: url; type: string_byref_const - DCHECK(!url.empty()); - if (url.empty()) - return; - // Verify param: context; type: refptr_diff - DCHECK(context.get()); - if (!context.get()) - return; - - // Execute - struct_->on_worker_context_created(struct_, - worker_id, - url.GetStruct(), - CefV8ContextCppToC::Wrap(context)); -} - -void CefRenderProcessHandlerCToCpp::OnWorkerContextReleased(int worker_id, - const CefString& url, CefRefPtr context) { - if (CEF_MEMBER_MISSING(struct_, on_worker_context_released)) - return; - - // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING - - // Verify param: url; type: string_byref_const - DCHECK(!url.empty()); - if (url.empty()) - return; - // Verify param: context; type: refptr_diff - DCHECK(context.get()); - if (!context.get()) - return; - - // Execute - struct_->on_worker_context_released(struct_, - worker_id, - url.GetStruct(), - CefV8ContextCppToC::Wrap(context)); -} - -void CefRenderProcessHandlerCToCpp::OnWorkerUncaughtException(int worker_id, - const CefString& url, CefRefPtr context, - CefRefPtr exception, - CefRefPtr stackTrace) { - if (CEF_MEMBER_MISSING(struct_, on_worker_uncaught_exception)) - return; - - // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING - - // Verify param: url; type: string_byref_const - DCHECK(!url.empty()); - if (url.empty()) - return; - // Verify param: context; type: refptr_diff - DCHECK(context.get()); - if (!context.get()) - return; - // Verify param: exception; type: refptr_diff - DCHECK(exception.get()); - if (!exception.get()) - return; - // Verify param: stackTrace; type: refptr_diff - DCHECK(stackTrace.get()); - if (!stackTrace.get()) - return; - - // Execute - struct_->on_worker_uncaught_exception(struct_, - worker_id, - url.GetStruct(), - CefV8ContextCppToC::Wrap(context), - CefV8ExceptionCppToC::Wrap(exception), - CefV8StackTraceCppToC::Wrap(stackTrace)); -} - void CefRenderProcessHandlerCToCpp::OnFocusedNodeChanged( CefRefPtr browser, CefRefPtr frame, CefRefPtr node) { diff --git a/cef3/libcef_dll/ctocpp/render_process_handler_ctocpp.h b/cef3/libcef_dll/ctocpp/render_process_handler_ctocpp.h index ae115483c..b79385077 100644 --- a/cef3/libcef_dll/ctocpp/render_process_handler_ctocpp.h +++ b/cef3/libcef_dll/ctocpp/render_process_handler_ctocpp.h @@ -50,13 +50,6 @@ class CefRenderProcessHandlerCToCpp CefRefPtr frame, CefRefPtr context, CefRefPtr exception, CefRefPtr stackTrace) OVERRIDE; - virtual void OnWorkerContextCreated(int worker_id, const CefString& url, - CefRefPtr context) OVERRIDE; - virtual void OnWorkerContextReleased(int worker_id, const CefString& url, - CefRefPtr context) OVERRIDE; - virtual void OnWorkerUncaughtException(int worker_id, const CefString& url, - CefRefPtr context, CefRefPtr exception, - CefRefPtr stackTrace) OVERRIDE; virtual void OnFocusedNodeChanged(CefRefPtr browser, CefRefPtr frame, CefRefPtr node) OVERRIDE; virtual bool OnProcessMessageReceived(CefRefPtr browser, diff --git a/cef3/patch/patch.cfg b/cef3/patch/patch.cfg index a8d1aa873..f8c3a1144 100644 --- a/cef3/patch/patch.cfg +++ b/cef3/patch/patch.cfg @@ -26,11 +26,6 @@ patches = [ 'name': 'message_loop_443', 'path': '../base/', }, - { - # http://code.google.com/p/chromiumembedded/issues/detail?id=451 - 'name': 'webkit_451', - 'path': '../third_party/WebKit/Source/', - }, { # http://code.google.com/p/chromiumembedded/issues/detail?id=899 'name': 'webkit_features', diff --git a/cef3/patch/patches/webkit_451.patch b/cef3/patch/patches/webkit_451.patch deleted file mode 100644 index bb371c50f..000000000 --- a/cef3/patch/patches/webkit_451.patch +++ /dev/null @@ -1,263 +0,0 @@ -Index: Platform/chromium/public/WebWorkerScriptObserver.h -=================================================================== ---- Platform/chromium/public/WebWorkerScriptObserver.h (revision 0) -+++ Platform/chromium/public/WebWorkerScriptObserver.h (revision 0) -@@ -0,0 +1,50 @@ -+/* -+ * Copyright (C) 2013 Google Inc. All rights reserved. -+ * -+ * Redistribution and use in source and binary forms, with or without -+ * modification, are permitted provided that the following conditions -+ * are met: -+ * 1. Redistributions of source code must retain the above copyright -+ * notice, this list of conditions and the following disclaimer. -+ * 2. Redistributions in binary form must reproduce the above copyright -+ * notice, this list of conditions and the following disclaimer in the -+ * documentation and/or other materials provided with the distribution. -+ * -+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY -+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -+ * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY -+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -+ */ -+ -+#ifndef WebWorkerScriptObserver_h -+#define WebWorkerScriptObserver_h -+ -+#include -+ -+namespace WebKit { -+ -+ class WebURL; -+ class WebWorkerRunLoop; -+ -+ class WebWorkerScriptObserver { -+ public: -+ // Notifies that a new script context has been created for a worker. -+ // This will be called only once per worker context. -+ virtual void didCreateWorkerScriptContext(const WebWorkerRunLoop&, const WebURL&, v8::Handle) { } -+ -+ // WebKit is about to release its reference to a v8 context for a worker. -+ virtual void willReleaseWorkerScriptContext(const WebWorkerRunLoop&, const WebURL&, v8::Handle) { } -+ -+ protected: -+ virtual ~WebWorkerScriptObserver() { } -+ }; -+ -+} // namespace WebKit -+ -+#endif - -Property changes on: Platform\chromium\public\WebWorkerScriptObserver.h -___________________________________________________________________ -Added: svn:eol-style - + LF - -Index: WebCore/bindings/v8/WorkerScriptController.cpp -=================================================================== ---- WebCore/bindings/v8/WorkerScriptController.cpp (revision 145278) -+++ WebCore/bindings/v8/WorkerScriptController.cpp (working copy) -@@ -51,11 +51,23 @@ - - #if PLATFORM(CHROMIUM) - #include -+#include - #include -+#include - #endif - - namespace WebCore { - -+namespace { -+ -+static Vector& observerVector() -+{ -+ AtomicallyInitializedStatic(Vector&, observers = *new Vector); -+ return observers; -+} -+ -+} // namespace -+ - WorkerScriptController::WorkerScriptController(WorkerContext* workerContext) - : m_workerContext(workerContext) - , m_isolate(v8::Isolate::New()) -@@ -73,6 +85,8 @@ - WorkerScriptController::~WorkerScriptController() - { - m_domDataStore.clear(); -+ if (!m_context.isEmpty()) -+ notifyWillReleaseWorkerScriptContext(); - #if PLATFORM(CHROMIUM) - // The corresponding call to didStartWorkerRunLoop is in - // WorkerThread::workerThread(). -@@ -134,6 +148,8 @@ - v8::Handle globalObject = v8::Handle::Cast(m_context->Global()->GetPrototype()); - globalObject->SetPrototype(jsWorkerContext); - -+ notifyDidCreateWorkerScriptContext(); -+ - return true; - } - -@@ -258,6 +274,39 @@ - return workerContext->script(); - } - -+void WorkerScriptController::addObserver(WebKit::WebWorkerScriptObserver* observer) -+{ -+ if (WebCore::WorkerThread::workerThreadCount() > 0) -+ return; -+ -+ observerVector().append(observer); -+} -+ -+void WorkerScriptController::removeObserver(WebKit::WebWorkerScriptObserver* observer) -+{ -+ if (WebCore::WorkerThread::workerThreadCount() > 0) -+ return; -+ -+ Vector& observers = observerVector(); -+ size_t pos = observers.find(observer); -+ if (pos != notFound) -+ observers.remove(pos); -+} -+ -+void WorkerScriptController::notifyDidCreateWorkerScriptContext() -+{ -+ const Vector& observers = observerVector(); -+ for (Vector::const_iterator i = observers.begin(); i != observers.end(); ++i) -+ (*i)->didCreateWorkerScriptContext(WebKit::WebWorkerRunLoop(&m_workerContext->thread()->runLoop()), m_workerContext->url(), m_context.get()); -+} -+ -+void WorkerScriptController::notifyWillReleaseWorkerScriptContext() -+{ -+ const Vector& observers = observerVector(); -+ for (Vector::const_iterator i = observers.begin(); i != observers.end(); ++i) -+ (*i)->willReleaseWorkerScriptContext(WebKit::WebWorkerRunLoop(&m_workerContext->thread()->runLoop()), m_workerContext->url(), m_context.get()); -+} -+ - } // namespace WebCore - - #endif // ENABLE(WORKERS) -Index: WebCore/bindings/v8/WorkerScriptController.h -=================================================================== ---- WebCore/bindings/v8/WorkerScriptController.h (revision 145278) -+++ WebCore/bindings/v8/WorkerScriptController.h (working copy) -@@ -40,6 +40,10 @@ - #include - #include - -+namespace WebKit { -+class WebWorkerScriptObserver; -+} -+ - namespace WebCore { - - class ScriptSourceCode; -@@ -95,10 +99,17 @@ - // Returns a local handle of the context. - v8::Local context() { return v8::Local::New(m_context.get()); } - -+ // Add or remove an observer. Can only be called while no WebWorkers exist. -+ static void addObserver(WebKit::WebWorkerScriptObserver*); -+ static void removeObserver(WebKit::WebWorkerScriptObserver*); -+ - private: - bool initializeContextIfNeeded(); - void disposeContext(); - -+ void notifyDidCreateWorkerScriptContext(); -+ void notifyWillReleaseWorkerScriptContext(); -+ - WorkerContext* m_workerContext; - v8::Isolate* m_isolate; - ScopedPersistent m_context; -Index: WebKit/chromium/public/WebWorkerInfo.h -=================================================================== ---- WebKit/chromium/public/WebWorkerInfo.h (revision 145278) -+++ WebKit/chromium/public/WebWorkerInfo.h (working copy) -@@ -35,9 +35,15 @@ - - namespace WebKit { - -+class WebWorkerScriptObserver; -+ - class WebWorkerInfo { - public: - WEBKIT_EXPORT static unsigned dedicatedWorkerCount(); -+ -+ // Add or remove an observer. Can only be called while no WebWorkers exist. -+ WEBKIT_EXPORT static void addScriptObserver(WebWorkerScriptObserver*); -+ WEBKIT_EXPORT static void removeScriptObserver(WebWorkerScriptObserver*); - }; - - } -Index: WebKit/chromium/public/WebWorkerScriptObserver.h -=================================================================== ---- WebKit/chromium/public/WebWorkerScriptObserver.h (revision 0) -+++ WebKit/chromium/public/WebWorkerScriptObserver.h (revision 0) -@@ -0,0 +1,25 @@ -+/* -+ * Copyright (C) 2013 Google Inc. All rights reserved. -+ * -+ * Redistribution and use in source and binary forms, with or without -+ * modification, are permitted provided that the following conditions -+ * are met: -+ * 1. Redistributions of source code must retain the above copyright -+ * notice, this list of conditions and the following disclaimer. -+ * 2. Redistributions in binary form must reproduce the above copyright -+ * notice, this list of conditions and the following disclaimer in the -+ * documentation and/or other materials provided with the distribution. -+ * -+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY -+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -+ * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY -+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -+ */ -+ -+#include "../../../Platform/chromium/public/WebWorkerScriptObserver.h" - -Property changes on: WebKit\chromium\public\WebWorkerScriptObserver.h -___________________________________________________________________ -Added: svn:eol-style - + LF - -Index: WebKit/chromium/src/WebWorkerInfo.cpp -=================================================================== ---- WebKit/chromium/src/WebWorkerInfo.cpp (revision 145278) -+++ WebKit/chromium/src/WebWorkerInfo.cpp (working copy) -@@ -31,6 +31,7 @@ - #include "config.h" - #include "WebWorkerInfo.h" - -+#include "WorkerScriptController.h" - #include "WorkerThread.h" - - namespace WebKit { -@@ -40,4 +41,14 @@ - return WebCore::WorkerThread::workerThreadCount(); - } - -+void WebWorkerInfo::addScriptObserver(WebWorkerScriptObserver* observer) -+{ -+ WebCore::WorkerScriptController::addObserver(observer); - } -+ -+void WebWorkerInfo::removeScriptObserver(WebWorkerScriptObserver* observer) -+{ -+ WebCore::WorkerScriptController::removeObserver(observer); -+} -+ -+} diff --git a/cef3/tests/cefclient/client_app.cpp b/cef3/tests/cefclient/client_app.cpp index 3fc87e534..41ec282ad 100644 --- a/cef3/tests/cefclient/client_app.cpp +++ b/cef3/tests/cefclient/client_app.cpp @@ -335,35 +335,6 @@ void ClientApp::OnUncaughtException(CefRefPtr browser, } } -void ClientApp::OnWorkerContextCreated(int worker_id, - const CefString& url, - CefRefPtr context) { - RenderDelegateSet::iterator it = render_delegates_.begin(); - for (; it != render_delegates_.end(); ++it) - (*it)->OnWorkerContextCreated(this, worker_id, url, context); -} - -void ClientApp::OnWorkerContextReleased(int worker_id, - const CefString& url, - CefRefPtr context) { - RenderDelegateSet::iterator it = render_delegates_.begin(); - for (; it != render_delegates_.end(); ++it) - (*it)->OnWorkerContextReleased(this, worker_id, url, context); -} - -void ClientApp::OnWorkerUncaughtException( - int worker_id, - const CefString& url, - CefRefPtr context, - CefRefPtr exception, - CefRefPtr stackTrace) { - RenderDelegateSet::iterator it = render_delegates_.begin(); - for (; it != render_delegates_.end(); ++it) { - (*it)->OnWorkerUncaughtException(this, worker_id, url, context, exception, - stackTrace); - } -} - void ClientApp::OnFocusedNodeChanged(CefRefPtr browser, CefRefPtr frame, CefRefPtr node) { diff --git a/cef3/tests/cefclient/client_app.h b/cef3/tests/cefclient/client_app.h index 0e371d1b5..6a6ef1795 100644 --- a/cef3/tests/cefclient/client_app.h +++ b/cef3/tests/cefclient/client_app.h @@ -77,24 +77,6 @@ class ClientApp : public CefApp, CefRefPtr exception, CefRefPtr stackTrace) {} - virtual void OnWorkerContextCreated(CefRefPtr app, - int worker_id, - const CefString& url, - CefRefPtr context) {} - - virtual void OnWorkerContextReleased(CefRefPtr app, - int worker_id, - const CefString& url, - CefRefPtr context) {} - - virtual void OnWorkerUncaughtException( - CefRefPtr app, - int worker_id, - const CefString& url, - CefRefPtr context, - CefRefPtr exception, - CefRefPtr stackTrace) {} - virtual void OnFocusedNodeChanged(CefRefPtr app, CefRefPtr browser, CefRefPtr frame, @@ -186,21 +168,6 @@ class ClientApp : public CefApp, CefRefPtr exception, CefRefPtr stackTrace) OVERRIDE; - virtual void OnWorkerContextCreated( - int worker_id, - const CefString& url, - CefRefPtr context) OVERRIDE; - virtual void OnWorkerContextReleased( - int worker_id, - const CefString& url, - CefRefPtr context) OVERRIDE; - virtual void OnWorkerUncaughtException( - int worker_id, - const CefString& url, - CefRefPtr context, - CefRefPtr exception, - CefRefPtr stackTrace) - OVERRIDE; virtual void OnFocusedNodeChanged(CefRefPtr browser, CefRefPtr frame, CefRefPtr node) OVERRIDE; diff --git a/cef3/tests/unittests/v8_unittest.cc b/cef3/tests/unittests/v8_unittest.cc index 56305226b..5882df8c6 100644 --- a/cef3/tests/unittests/v8_unittest.cc +++ b/cef3/tests/unittests/v8_unittest.cc @@ -74,9 +74,6 @@ enum V8TestMode { V8TEST_ON_UNCAUGHT_EXCEPTION, V8TEST_ON_UNCAUGHT_EXCEPTION_DEV_TOOLS, V8TEST_EXTENSION, - V8TEST_WORKER_BINDING, - V8TEST_WORKER_ON_UNCAUGHT_EXCEPTION, - V8TEST_WORKER_ON_UNCAUGHT_EXCEPTION_DEV_TOOLS, }; // Set to the current test being run in the browser process. Will always be @@ -220,16 +217,11 @@ class V8RendererTest : public ClientApp::RenderDelegate { RunStackTraceTest(); break; case V8TEST_ON_UNCAUGHT_EXCEPTION: - case V8TEST_WORKER_ON_UNCAUGHT_EXCEPTION: RunOnUncaughtExceptionTest(); break; case V8TEST_ON_UNCAUGHT_EXCEPTION_DEV_TOOLS: - case V8TEST_WORKER_ON_UNCAUGHT_EXCEPTION_DEV_TOOLS: RunOnUncaughtExceptionDevToolsTest(); break; - case V8TEST_WORKER_BINDING: - // The test is triggered in OnWorkerContextCreated(). - break; default: // Was a startup test. EXPECT_TRUE(startup_test_success_); @@ -1652,8 +1644,7 @@ class V8RendererTest : public ClientApp::RenderDelegate { if (test_mode_ == V8TEST_NONE) return; - if (test_mode_ == V8TEST_ON_UNCAUGHT_EXCEPTION_DEV_TOOLS || - test_mode_ == V8TEST_WORKER_ON_UNCAUGHT_EXCEPTION_DEV_TOOLS) { + if (test_mode_ == V8TEST_ON_UNCAUGHT_EXCEPTION_DEV_TOOLS) { if (browser_.get() == NULL) { app_ = app; browser_ = browser; @@ -1769,204 +1760,12 @@ class V8RendererTest : public ClientApp::RenderDelegate { } } - virtual void OnWorkerContextCreated( - CefRefPtr app, - int worker_id, - const CefString& url, - CefRefPtr context) OVERRIDE { - if (test_mode_ == V8TEST_NONE) - return; - - EXPECT_STREQ(kV8WorkerTestUrl, url.ToString().c_str()); - - EXPECT_TRUE(context.get()); - EXPECT_TRUE(context->IsValid()); - test_context_worker_ = context; - - CefRefPtr task_runner = context->GetTaskRunner(); - EXPECT_TRUE(task_runner.get()); - EXPECT_TRUE(task_runner->BelongsToCurrentThread()); - test_task_runner_worker_ = task_runner; - - EXPECT_FALSE(context->GetBrowser().get()); - EXPECT_FALSE(context->GetFrame().get()); - - if (test_mode_ == V8TEST_WORKER_BINDING) { - static const char test_func[] = "run_async"; - - class Handler : public CefV8Handler { - public: - Handler() {} - virtual bool Execute(const CefString& name, - CefRefPtr object, - const CefV8ValueList& arguments, - CefRefPtr& retval, - CefString& exception) OVERRIDE { - EXPECT_STREQ(test_func, name.ToString().c_str()); - EXPECT_EQ((size_t)1, arguments.size()); - - callback_ = arguments[0]; - EXPECT_TRUE(callback_->IsFunction()); - - EXPECT_TRUE(context_->IsValid()); - - CefRefPtr current_context = - CefV8Context::GetCurrentContext(); - EXPECT_TRUE(current_context->IsSame(context_)); - - CefRefPtr task_runner = - current_context->GetTaskRunner(); - EXPECT_TRUE(task_runner.get()); - EXPECT_TRUE(task_runner->BelongsToCurrentThread()); - EXPECT_TRUE(task_runner->IsSame(task_runner_)); - - // Execute the callback asynchronously. - // Can't use templates with nested classes on Linux. - class Task : public CefTask { - public: - explicit Task(Handler* handler) - : handler_(handler) { - handler_->AddRef(); - } - ~Task() { - handler_->Release(); - } - virtual void Execute() OVERRIDE { - handler_->ExecCallback(); - } - private: - Handler* handler_; - IMPLEMENT_REFCOUNTING(Task); - }; - task_runner->PostTask(new Task(this)); - - retval = CefV8Value::CreateBool(true); - return true; - } - - void ExecCallback() { - EXPECT_TRUE(callback_->IsValid()); - EXPECT_TRUE(context_->IsValid()); - - CefRefPtr task_runner = context_->GetTaskRunner(); - EXPECT_TRUE(task_runner.get()); - EXPECT_TRUE(task_runner->BelongsToCurrentThread()); - EXPECT_TRUE(task_runner->IsSame(task_runner_)); - - CefRefPtr retval = - callback_->ExecuteFunctionWithContext(context_, NULL, - CefV8ValueList()); - EXPECT_TRUE(retval.get()); - EXPECT_TRUE(retval->IsValid()); - EXPECT_TRUE(retval->IsBool()); - EXPECT_EQ(true, retval->GetBoolValue()); - - callback_ = NULL; - context_ = NULL; - task_runner_ = NULL; - } - - CefRefPtr callback_; - CefRefPtr context_; - CefRefPtr task_runner_; - - IMPLEMENT_REFCOUNTING(Handler); - }; - - Handler* handler = new Handler(); - CefRefPtr handlerPtr(handler); - - handler->context_ = context; - handler->task_runner_ = task_runner; - - CefRefPtr global = context->GetGlobal(); - EXPECT_TRUE(global.get()); - - global->SetValue(test_func, - CefV8Value::CreateFunction(test_func, handlerPtr), - V8_PROPERTY_ATTRIBUTE_NONE); - } - } - - virtual void OnWorkerContextReleased( - CefRefPtr app, - int worker_id, - const CefString& url, - CefRefPtr context) OVERRIDE { - if (test_mode_ == V8TEST_NONE) - return; - - EXPECT_STREQ(kV8WorkerTestUrl, url.ToString().c_str()); - - EXPECT_TRUE(context.get()); - EXPECT_TRUE(context->IsValid()); - - CefRefPtr task_runner = context->GetTaskRunner(); - EXPECT_TRUE(task_runner.get()); - EXPECT_TRUE(task_runner->BelongsToCurrentThread()); - EXPECT_TRUE(task_runner->IsSame(test_task_runner_worker_)); - - EXPECT_TRUE(context->IsSame(test_context_worker_)); - - test_context_worker_ = NULL; - test_task_runner_worker_ = NULL; - - if (test_mode_ == V8TEST_WORKER_BINDING) { - // Destroy the test on the renderer thread. - CefPostTask(TID_RENDERER, - NewCefRunnableMethod(this, &V8RendererTest::DestroyTest)); - } - } - - void OnWorkerUncaughtException( - CefRefPtr app, - int worker_id, - const CefString& url, - CefRefPtr context, - CefRefPtr exception, - CefRefPtr stackTrace) OVERRIDE { - if (test_mode_ == V8TEST_NONE) - return; - - EXPECT_TRUE(context.get()); - EXPECT_TRUE(context->IsValid()); - - CefRefPtr task_runner = context->GetTaskRunner(); - EXPECT_TRUE(task_runner.get()); - EXPECT_TRUE(task_runner->BelongsToCurrentThread()); - EXPECT_TRUE(task_runner->IsSame(test_task_runner_worker_)); - - EXPECT_TRUE(context->IsSame(test_context_worker_)); - - if (test_mode_ == V8TEST_WORKER_ON_UNCAUGHT_EXCEPTION || - test_mode_ == V8TEST_WORKER_ON_UNCAUGHT_EXCEPTION_DEV_TOOLS) { - EXPECT_STREQ("Uncaught ReferenceError: asd is not defined", - exception->GetMessage().ToString().c_str()); - std::ostringstream stackFormatted; - for (int i = 0; i < stackTrace->GetFrameCount(); ++i) { - stackFormatted << "at " - << stackTrace->GetFrame(i)->GetFunctionName().ToString() - << "() in " << stackTrace->GetFrame(i)->GetScriptName().ToString() - << " on line " << stackTrace->GetFrame(i)->GetLineNumber() << "\n"; - } - const char* stackFormattedShouldBe = - "at test2() in http://tests/V8Test.Worker.js on line 2\n" - "at test() in http://tests/V8Test.Worker.js on line 1\n"; - EXPECT_STREQ(stackFormattedShouldBe, stackFormatted.str().c_str()); - - // Destroy the test on the renderer thread. - CefPostTask(TID_RENDERER, - NewCefRunnableMethod(this, &V8RendererTest::DestroyTest)); - } - } - virtual void OnBrowserDestroyed(CefRefPtr app, CefRefPtr browser) OVERRIDE { if (test_mode_ == V8TEST_NONE) return; - if (test_mode_ == V8TEST_ON_UNCAUGHT_EXCEPTION_DEV_TOOLS || - test_mode_ == V8TEST_WORKER_ON_UNCAUGHT_EXCEPTION_DEV_TOOLS) { + if (test_mode_ == V8TEST_ON_UNCAUGHT_EXCEPTION_DEV_TOOLS) { if (browser->IsPopup()) { // After window destruction there is still a call to // ScriptController::setCaptureCallStackForUncaughtExceptions(0), @@ -1985,8 +1784,7 @@ class V8RendererTest : public ClientApp::RenderDelegate { if (test_mode_ == V8TEST_NONE) return false; - if (test_mode_ == V8TEST_ON_UNCAUGHT_EXCEPTION_DEV_TOOLS || - test_mode_ == V8TEST_WORKER_ON_UNCAUGHT_EXCEPTION_DEV_TOOLS) { + if (test_mode_ == V8TEST_ON_UNCAUGHT_EXCEPTION_DEV_TOOLS) { EXPECT_TRUE(browser.get()); EXPECT_EQ(PID_BROWSER, source_process); EXPECT_TRUE(message.get()); @@ -2132,9 +1930,6 @@ class V8RendererTest : public ClientApp::RenderDelegate { CefRefPtr test_context_; CefRefPtr test_object_; - CefRefPtr test_context_worker_; - CefRefPtr test_task_runner_worker_; - // Used by startup tests to indicate success. TrackCallback startup_test_success_; @@ -2171,28 +1966,6 @@ class V8TestHandler : public TestHandler { "\n", "text/html"); CreateBrowser(kV8OnUncaughtExceptionTestUrl); - } else if (test_mode_ == V8TEST_WORKER_BINDING) { - AddResource(kV8WorkerParentTestUrl, "" - "" - "", "text/html"); - AddResource(kV8WorkerTestUrl, - "function cb() { self.close(); return true; }\n" - "self.run_async(cb);", - "application/javascript"); - CreateBrowser(kV8WorkerParentTestUrl); - } else if (test_mode_ == V8TEST_WORKER_ON_UNCAUGHT_EXCEPTION || - test_mode_ == V8TEST_WORKER_ON_UNCAUGHT_EXCEPTION_DEV_TOOLS) { - AddResource(kV8WorkerParentTestUrl, "" - "" - "", "text/html"); - AddResource(kV8WorkerTestUrl, - "function test(){ test2(); }\n" - "function test2(){ asd(); }\n" - "self.onmessage = function(event) { self.setTimeout(test, 0); }", - "application/javascript"); - CreateBrowser(kV8WorkerParentTestUrl); } else { EXPECT_TRUE(test_url_ != NULL); AddResource(test_url_, "" @@ -2204,8 +1977,7 @@ class V8TestHandler : public TestHandler { virtual void OnLoadEnd(CefRefPtr browser, CefRefPtr frame, int httpStatusCode) OVERRIDE { - if (test_mode_ == V8TEST_ON_UNCAUGHT_EXCEPTION_DEV_TOOLS || - test_mode_ == V8TEST_WORKER_ON_UNCAUGHT_EXCEPTION_DEV_TOOLS) { + if (test_mode_ == V8TEST_ON_UNCAUGHT_EXCEPTION_DEV_TOOLS) { if (browser->IsPopup()) { EXPECT_STREQ( GetBrowser()->GetHost()->GetDevToolsURL(true).ToString().c_str(), @@ -2329,7 +2101,3 @@ V8_TEST(StackTrace, V8TEST_STACK_TRACE); V8_TEST(OnUncaughtException, V8TEST_ON_UNCAUGHT_EXCEPTION); V8_TEST(OnUncaughtExceptionDevTools, V8TEST_ON_UNCAUGHT_EXCEPTION_DEV_TOOLS); V8_TEST(Extension, V8TEST_EXTENSION); -V8_TEST(WorkerBinding, V8TEST_WORKER_BINDING); -V8_TEST(WorkerOnUncaughtException, V8TEST_WORKER_ON_UNCAUGHT_EXCEPTION); -V8_TEST(WorkerOnUncaughtExceptionDevTools, - V8TEST_WORKER_ON_UNCAUGHT_EXCEPTION_DEV_TOOLS);