From 47420c2e01de1f403669aa892ddc78ad26916b47 Mon Sep 17 00:00:00 2001 From: Corey Johnson & Nathan Sobo Date: Wed, 23 Jan 2013 12:55:59 -0700 Subject: [PATCH] Inject `$native` into WebWorker contexts This is just to make sure it works. Will inject the remaining extensions when they are converted to from v8 extensions to context bindings. --- native/atom_cef_render_process_handler.h | 13 +++++++++++- native/atom_cef_render_process_handler.mm | 24 +++++++++++++++++++++++ 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/native/atom_cef_render_process_handler.h b/native/atom_cef_render_process_handler.h index c6d979e8b..edb49888b 100644 --- a/native/atom_cef_render_process_handler.h +++ b/native/atom_cef_render_process_handler.h @@ -16,7 +16,18 @@ class AtomCefRenderProcessHandler : public CefRenderProcessHandler { virtual bool OnProcessMessageReceived(CefRefPtr browser, CefProcessId source_process, CefRefPtr message) 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; + void Reload(CefRefPtr browser); void Shutdown(CefRefPtr browser); bool CallMessageReceivedHandler(CefRefPtr context, CefRefPtr message); diff --git a/native/atom_cef_render_process_handler.mm b/native/atom_cef_render_process_handler.mm index 2d5a82cf6..0c6f5ac4a 100644 --- a/native/atom_cef_render_process_handler.mm +++ b/native/atom_cef_render_process_handler.mm @@ -29,6 +29,30 @@ void AtomCefRenderProcessHandler::OnContextReleased(CefRefPtr browse [PathWatcher removePathWatcherForContext:context]; } + + +void AtomCefRenderProcessHandler::OnWorkerContextCreated(int worker_id, + const CefString& url, + CefRefPtr context) { + v8_extensions::Native::CreateContextBinding(context); +} + +void AtomCefRenderProcessHandler::OnWorkerContextReleased(int worker_id, + const CefString& url, + CefRefPtr context) { + NSLog(@"Web worker context released"); +} + +void AtomCefRenderProcessHandler::OnWorkerUncaughtException(int worker_id, + const CefString& url, + CefRefPtr context, + CefRefPtr exception, + CefRefPtr stackTrace) { + + std::string message = exception->GetMessage().ToString(); + NSLog(@"Exception throw in worker thread %s", message.c_str()); +} + bool AtomCefRenderProcessHandler::OnProcessMessageReceived(CefRefPtr browser, CefProcessId source_process, CefRefPtr message) {