diff --git a/atom/browser/api/atom_api_power_monitor.cc b/atom/browser/api/atom_api_power_monitor.cc index afdebfcf7f2..093df2a1d4e 100644 --- a/atom/browser/api/atom_api_power_monitor.cc +++ b/atom/browser/api/atom_api_power_monitor.cc @@ -41,8 +41,9 @@ void PowerMonitor::OnResume() { // static v8::Local PowerMonitor::Create(v8::Isolate* isolate) { if (!Browser::Get()->is_ready()) { - node::ThrowError("Cannot initialize \"power-monitor\" module" - "before app is ready"); + node::ThrowError( + isolate, + "Cannot initialize \"power-monitor\" module before app is ready"); return v8::Null(isolate); } diff --git a/atom/browser/api/atom_api_protocol.cc b/atom/browser/api/atom_api_protocol.cc index 323d282b19a..083ea32b201 100644 --- a/atom/browser/api/atom_api_protocol.cc +++ b/atom/browser/api/atom_api_protocol.cc @@ -192,28 +192,19 @@ Protocol::JsProtocolHandler Protocol::GetProtocolHandler( mate::ObjectTemplateBuilder Protocol::GetObjectTemplateBuilder( v8::Isolate* isolate) { return mate::ObjectTemplateBuilder(isolate) - .SetMethod("registerProtocol", - base::Bind(&Protocol::RegisterProtocol, - base::Unretained(this))) - .SetMethod("unregisterProtocol", - base::Bind(&Protocol::UnregisterProtocol, - base::Unretained(this))) - .SetMethod("isHandledProtocol", - base::Bind(&Protocol::IsHandledProtocol, - base::Unretained(this))) - .SetMethod("interceptProtocol", - base::Bind(&Protocol::InterceptProtocol, - base::Unretained(this))) - .SetMethod("uninterceptProtocol", - base::Bind(&Protocol::UninterceptProtocol, - base::Unretained(this))); + .SetMethod("registerProtocol", &Protocol::RegisterProtocol) + .SetMethod("unregisterProtocol", &Protocol::UnregisterProtocol) + .SetMethod("isHandledProtocol", &Protocol::IsHandledProtocol) + .SetMethod("interceptProtocol", &Protocol::InterceptProtocol) + .SetMethod("uninterceptProtocol", &Protocol::UninterceptProtocol); } -void Protocol::RegisterProtocol(const std::string& scheme, +void Protocol::RegisterProtocol(v8::Isolate* isolate, + const std::string& scheme, const JsProtocolHandler& callback) { if (ContainsKey(protocol_handlers_, scheme) || job_factory_->IsHandledProtocol(scheme)) - return node::ThrowError("The scheme is already registered"); + return node::ThrowError(isolate, "The scheme is already registered"); protocol_handlers_[scheme] = callback; BrowserThread::PostTask(BrowserThread::IO, @@ -222,10 +213,11 @@ void Protocol::RegisterProtocol(const std::string& scheme, base::Unretained(this), scheme)); } -void Protocol::UnregisterProtocol(const std::string& scheme) { +void Protocol::UnregisterProtocol(v8::Isolate* isolate, + const std::string& scheme) { ProtocolHandlersMap::iterator it(protocol_handlers_.find(scheme)); if (it == protocol_handlers_.end()) - return node::ThrowError("The scheme has not been registered"); + return node::ThrowError(isolate, "The scheme has not been registered"); protocol_handlers_.erase(it); BrowserThread::PostTask(BrowserThread::IO, @@ -238,13 +230,14 @@ bool Protocol::IsHandledProtocol(const std::string& scheme) { return job_factory_->IsHandledProtocol(scheme); } -void Protocol::InterceptProtocol(const std::string& scheme, +void Protocol::InterceptProtocol(v8::Isolate* isolate, + const std::string& scheme, const JsProtocolHandler& callback) { if (!job_factory_->HasProtocolHandler(scheme)) - return node::ThrowError("Scheme does not exist."); + return node::ThrowError(isolate, "Scheme does not exist."); if (ContainsKey(protocol_handlers_, scheme)) - return node::ThrowError("Cannot intercept custom procotols"); + return node::ThrowError(isolate, "Cannot intercept custom procotols"); protocol_handlers_[scheme] = callback; BrowserThread::PostTask(BrowserThread::IO, @@ -253,10 +246,11 @@ void Protocol::InterceptProtocol(const std::string& scheme, base::Unretained(this), scheme)); } -void Protocol::UninterceptProtocol(const std::string& scheme) { +void Protocol::UninterceptProtocol(v8::Isolate* isolate, + const std::string& scheme) { ProtocolHandlersMap::iterator it(protocol_handlers_.find(scheme)); if (it == protocol_handlers_.end()) - return node::ThrowError("The scheme has not been registered"); + return node::ThrowError(isolate, "The scheme has not been registered"); protocol_handlers_.erase(it); BrowserThread::PostTask(BrowserThread::IO, diff --git a/atom/browser/api/atom_api_protocol.h b/atom/browser/api/atom_api_protocol.h index deef277333b..34725cecc92 100644 --- a/atom/browser/api/atom_api_protocol.h +++ b/atom/browser/api/atom_api_protocol.h @@ -43,9 +43,10 @@ class Protocol : public mate::EventEmitter { // Register/unregister an networking |scheme| which would be handled by // |callback|. - void RegisterProtocol(const std::string& scheme, + void RegisterProtocol(v8::Isolate* isolate, + const std::string& scheme, const JsProtocolHandler& callback); - void UnregisterProtocol(const std::string& scheme); + void UnregisterProtocol(v8::Isolate* isolate, const std::string& scheme); // Returns whether a scheme has been registered. // FIXME Should accept a callback and be asynchronous so we do not have to use @@ -53,9 +54,10 @@ class Protocol : public mate::EventEmitter { bool IsHandledProtocol(const std::string& scheme); // Intercept/unintercept an existing protocol handler. - void InterceptProtocol(const std::string& scheme, + void InterceptProtocol(v8::Isolate* isolate, + const std::string& scheme, const JsProtocolHandler& callback); - void UninterceptProtocol(const std::string& scheme); + void UninterceptProtocol(v8::Isolate* isolate, const std::string& scheme); // The networking related operations have to be done in IO thread. void RegisterProtocolInIO(const std::string& scheme); diff --git a/atom/browser/api/atom_api_screen.cc b/atom/browser/api/atom_api_screen.cc index c042cc3f1f0..9f81cf6eeff 100644 --- a/atom/browser/api/atom_api_screen.cc +++ b/atom/browser/api/atom_api_screen.cc @@ -113,13 +113,14 @@ mate::ObjectTemplateBuilder Screen::GetObjectTemplateBuilder( // static v8::Local Screen::Create(v8::Isolate* isolate) { if (!Browser::Get()->is_ready()) { - node::ThrowError("Cannot initialize \"screen\" module before app is ready"); + node::ThrowError(isolate, + "Cannot initialize \"screen\" module before app is ready"); return v8::Null(isolate); } gfx::Screen* screen = gfx::Screen::GetNativeScreen(); if (!screen) { - node::ThrowError("Failed to get screen information"); + node::ThrowError(isolate, "Failed to get screen information"); return v8::Null(isolate); } diff --git a/atom/browser/api/atom_api_tray.cc b/atom/browser/api/atom_api_tray.cc index 6d7a9e5dedb..2672f6f67ae 100644 --- a/atom/browser/api/atom_api_tray.cc +++ b/atom/browser/api/atom_api_tray.cc @@ -32,9 +32,9 @@ Tray::~Tray() { } // static -mate::Wrappable* Tray::New(const gfx::Image& image) { +mate::Wrappable* Tray::New(v8::Isolate* isolate, const gfx::Image& image) { if (!Browser::Get()->is_ready()) { - node::ThrowError("Cannot create Tray before app is ready"); + node::ThrowError(isolate, "Cannot create Tray before app is ready"); return nullptr; } return new Tray(image); diff --git a/atom/browser/api/atom_api_tray.h b/atom/browser/api/atom_api_tray.h index 9fe3513094d..6bbbe6d2d90 100644 --- a/atom/browser/api/atom_api_tray.h +++ b/atom/browser/api/atom_api_tray.h @@ -31,7 +31,7 @@ class Menu; class Tray : public mate::EventEmitter, public TrayIconObserver { public: - static mate::Wrappable* New(const gfx::Image& image); + static mate::Wrappable* New(v8::Isolate* isolate, const gfx::Image& image); static void BuildPrototype(v8::Isolate* isolate, v8::Local prototype); diff --git a/atom/browser/api/atom_api_window.cc b/atom/browser/api/atom_api_window.cc index 76aaa3baaff..7461bc73685 100644 --- a/atom/browser/api/atom_api_window.cc +++ b/atom/browser/api/atom_api_window.cc @@ -189,7 +189,8 @@ void Window::OnDevToolsClosed() { mate::Wrappable* Window::New(v8::Isolate* isolate, const mate::Dictionary& options) { if (!Browser::Get()->is_ready()) { - node::ThrowError("Cannot create BrowserWindow before app is ready"); + node::ThrowError(isolate, + "Cannot create BrowserWindow before app is ready"); return nullptr; } return new Window(options); diff --git a/atom/common/api/atom_api_id_weak_map.cc b/atom/common/api/atom_api_id_weak_map.cc index cc2af821de1..614683c473a 100644 --- a/atom/common/api/atom_api_id_weak_map.cc +++ b/atom/common/api/atom_api_id_weak_map.cc @@ -35,7 +35,7 @@ int32_t IDWeakMap::Add(v8::Isolate* isolate, v8::Local object) { v8::Local IDWeakMap::Get(v8::Isolate* isolate, int32_t key) { if (!Has(key)) { - node::ThrowError("Invalid key"); + node::ThrowError(isolate, "Invalid key"); return v8::Undefined(isolate); } diff --git a/atom/common/lib/asar.coffee b/atom/common/lib/asar.coffee index a17ac729253..7ce89156285 100644 --- a/atom/common/lib/asar.coffee +++ b/atom/common/lib/asar.coffee @@ -310,6 +310,38 @@ exports.wrapFsWithAsar = (fs) -> files + internalModuleReadFile = process.binding('fs').internalModuleReadFile + process.binding('fs').internalModuleReadFile = (p) -> + [isAsar, asarPath, filePath] = splitPath p + return internalModuleReadFile p unless isAsar + + archive = getOrCreateArchive asarPath + return undefined unless archive + + info = archive.getFileInfo filePath + return undefined unless info + return '' if info.size is 0 + + buffer = new Buffer(info.size) + fd = archive.getFd() + retrun undefined unless fd >= 0 + + fs.readSync fd, buffer, 0, info.size, info.offset + buffer.toString 'utf8' + + internalModuleStat = process.binding('fs').internalModuleStat + process.binding('fs').internalModuleStat = (p) -> + [isAsar, asarPath, filePath] = splitPath p + return internalModuleStat p unless isAsar + + archive = getOrCreateArchive asarPath + return -34 unless archive # -ENOENT + + stats = archive.stat filePath + return -34 unless stats # -ENOENT + + if stats.isDirectory then return 1 else return 0 + overrideAPI fs, 'open' overrideAPI child_process, 'execFile' overrideAPISync process, 'dlopen', 1 diff --git a/atom/renderer/api/atom_api_renderer_ipc.cc b/atom/renderer/api/atom_api_renderer_ipc.cc index 00a5ba86165..d222f8f73b8 100644 --- a/atom/renderer/api/atom_api_renderer_ipc.cc +++ b/atom/renderer/api/atom_api_renderer_ipc.cc @@ -30,7 +30,9 @@ RenderView* GetCurrentRenderView() { return RenderView::FromWebView(view); } -void Send(const base::string16& channel, const base::ListValue& arguments) { +void Send(v8::Isolate* isolate, + const base::string16& channel, + const base::ListValue& arguments) { RenderView* render_view = GetCurrentRenderView(); if (render_view == NULL) return; @@ -39,10 +41,11 @@ void Send(const base::string16& channel, const base::ListValue& arguments) { render_view->GetRoutingID(), channel, arguments)); if (!success) - node::ThrowError("Unable to send AtomViewHostMsg_Message"); + node::ThrowError(isolate, "Unable to send AtomViewHostMsg_Message"); } -base::string16 SendSync(const base::string16& channel, +base::string16 SendSync(v8::Isolate* isolate, + const base::string16& channel, const base::ListValue& arguments) { base::string16 json; @@ -57,7 +60,7 @@ base::string16 SendSync(const base::string16& channel, bool success = render_view->Send(message); if (!success) - node::ThrowError("Unable to send AtomViewHostMsg_Message_Sync"); + node::ThrowError(isolate, "Unable to send AtomViewHostMsg_Message_Sync"); return json; } diff --git a/common.gypi b/common.gypi index c6f3320c0a5..14b89393a53 100644 --- a/common.gypi +++ b/common.gypi @@ -9,6 +9,7 @@ 'component%': 'static_library', 'python': 'python', 'openssl_no_asm': 1, + 'node_target_type': 'shared_library', 'node_install_npm': 'false', 'node_prefix': '', 'node_shared_cares': 'false', @@ -26,6 +27,7 @@ 'uv_library': 'static_library', 'uv_parent_path': 'vendor/node/deps/uv', 'uv_use_dtrace': 'false', + 'V8_BASE': '', 'v8_postmortem_support': 'false', 'v8_enable_i18n_support': 'false', # Required by Linux (empty for now, should support it in future). @@ -99,7 +101,10 @@ ], }], ['_target_name=="node"', { - 'include_dirs': [ '<(libchromiumcontent_src_dir)/v8/include' ], + 'include_dirs': [ + '<(libchromiumcontent_src_dir)/v8', + '<(libchromiumcontent_src_dir)/v8/include', + ], 'conditions': [ ['OS=="mac" and libchromiumcontent_component==0', { # -all_load is the "whole-archive" on OS X. diff --git a/script/update.py b/script/update.py index aaa07526c05..23497ff9e5a 100755 --- a/script/update.py +++ b/script/update.py @@ -1,6 +1,7 @@ #!/usr/bin/env python import os +import platform import subprocess import sys @@ -43,10 +44,19 @@ def run_gyp(target_arch, component): defines = [ '-Dlibchromiumcontent_component={0}'.format(component), '-Dtarget_arch={0}'.format(target_arch), + '-Dhost_arch={0}'.format(target_arch), '-Dlibrary=static_library', ] return subprocess.call([python, gyp, '-f', 'ninja', '--depth', '.', 'atom.gyp', '-Icommon.gypi'] + defines) + +def get_host_arch(): + if platform.architecture()[0] == '32bit': + return 'ia32' + else: + return 'x64' + + if __name__ == '__main__': sys.exit(main()) diff --git a/vendor/node b/vendor/node index b772c19a8f9..0a8c4d2a8c0 160000 --- a/vendor/node +++ b/vendor/node @@ -1 +1 @@ -Subproject commit b772c19a8f9db65673184822fb294235eff9c364 +Subproject commit 0a8c4d2a8c0118348b5072b1e21bc4bd148b238b