There is no more node_isolate.

This commit is contained in:
Cheng Zhao 2014-06-28 19:49:55 +08:00
parent e0e1d45859
commit 58ccb27792
7 changed files with 32 additions and 25 deletions

View file

@ -27,7 +27,7 @@ void ShowMessageBox(int type,
mate::Arguments* args) {
v8::Handle<v8::Value> peek = args->PeekNext();
atom::MessageBoxCallback callback;
if (mate::Converter<atom::MessageBoxCallback>::FromV8(node_isolate,
if (mate::Converter<atom::MessageBoxCallback>::FromV8(args->isolate(),
peek,
&callback)) {
atom::ShowMessageBox(window, (atom::MessageBoxType)type, buttons, title,
@ -46,7 +46,7 @@ void ShowOpenDialog(const std::string& title,
mate::Arguments* args) {
v8::Handle<v8::Value> peek = args->PeekNext();
file_dialog::OpenDialogCallback callback;
if (mate::Converter<file_dialog::OpenDialogCallback>::FromV8(node_isolate,
if (mate::Converter<file_dialog::OpenDialogCallback>::FromV8(args->isolate(),
peek,
&callback)) {
file_dialog::ShowOpenDialog(window, title, default_path, properties,
@ -65,7 +65,7 @@ void ShowSaveDialog(const std::string& title,
mate::Arguments* args) {
v8::Handle<v8::Value> peek = args->PeekNext();
file_dialog::SaveDialogCallback callback;
if (mate::Converter<file_dialog::SaveDialogCallback>::FromV8(node_isolate,
if (mate::Converter<file_dialog::SaveDialogCallback>::FromV8(args->isolate(),
peek,
&callback)) {
file_dialog::ShowSaveDialog(window, title, default_path, callback);

View file

@ -122,7 +122,7 @@ base::string16 Menu::GetLabelForCommandId(int command_id) const {
"getLabelForCommandId",
command_id);
base::string16 label;
mate::ConvertFromV8(node_isolate, result, &label);
mate::ConvertFromV8(isolate, result, &label);
return label;
}
@ -264,9 +264,10 @@ namespace {
void Initialize(v8::Handle<v8::Object> exports) {
using atom::api::Menu;
v8::Isolate* isolate = v8::Isolate::GetCurrent();
v8::Local<v8::Function> constructor = mate::CreateConstructor<Menu>(
node_isolate, "Menu", base::Bind(&Menu::Create));
mate::Dictionary dict(v8::Isolate::GetCurrent(), exports);
isolate, "Menu", base::Bind(&Menu::Create));
mate::Dictionary dict(isolate, exports);
dict.Set("Menu", static_cast<v8::Handle<v8::Value>>(constructor));
#if defined(OS_MACOSX)
dict.SetMethod("setApplicationMenu", &Menu::SetApplicationMenu);

View file

@ -58,8 +58,9 @@ class CustomProtocolRequestJob : public AdapterRequestJob {
virtual void GetJobTypeInUI() OVERRIDE {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
v8::Locker locker(node_isolate);
v8::HandleScope handle_scope(node_isolate);
v8::Isolate* isolate = v8::Isolate::GetCurrent();
v8::Locker locker(isolate);
v8::HandleScope handle_scope(isolate);
// Call the JS handler.
Protocol::JsProtocolHandler callback =
@ -75,7 +76,7 @@ class CustomProtocolRequestJob : public AdapterRequestJob {
return;
} else if (result->IsObject()) {
v8::Handle<v8::Object> obj = result->ToObject();
mate::Dictionary dict(node_isolate, obj);
mate::Dictionary dict(isolate, obj);
std::string name = mate::V8ToString(obj->GetConstructorName());
if (name == "RequestStringJob") {
std::string mime_type, charset, data;

View file

@ -46,10 +46,11 @@ namespace api {
namespace {
void OnCapturePageDone(
v8::Isolate* isolate,
const base::Callback<void(v8::Handle<v8::Value>)>& callback,
const std::vector<unsigned char>& data) {
v8::Locker locker(node_isolate);
v8::HandleScope handle_scope(node_isolate);
v8::Locker locker(isolate);
v8::HandleScope handle_scope(isolate);
v8::Local<v8::Value> buffer = node::Buffer::New(
reinterpret_cast<const char*>(data.data()),
@ -307,7 +308,8 @@ void Window::CapturePage(mate::Arguments* args) {
return;
}
window_->CapturePage(rect, base::Bind(&OnCapturePageDone, callback));
window_->CapturePage(
rect, base::Bind(&OnCapturePageDone, args->isolate(), callback));
}
void Window::SetRepresentedFilename(const std::string& filename) {
@ -388,9 +390,10 @@ namespace {
void Initialize(v8::Handle<v8::Object> exports) {
using atom::api::Window;
v8::Isolate* isolate = v8::Isolate::GetCurrent();
v8::Local<v8::Function> constructor = mate::CreateConstructor<Window>(
node_isolate, "BrowserWindow", base::Bind(&Window::New));
mate::Dictionary dict(v8::Isolate::GetCurrent(), exports);
isolate, "BrowserWindow", base::Bind(&Window::New));
mate::Dictionary dict(isolate, exports);
dict.Set("BrowserWindow", static_cast<v8::Handle<v8::Value>>(constructor));
}

View file

@ -31,20 +31,21 @@ bool EventEmitter::Emit(const base::StringPiece& name,
const base::ListValue& args,
content::WebContents* sender,
IPC::Message* message) {
v8::Locker locker(node_isolate);
v8::HandleScope handle_scope(node_isolate);
v8::Isolate* isolate = v8::Isolate::GetCurrent();
v8::Locker locker(isolate);
v8::HandleScope handle_scope(isolate);
v8::Handle<v8::Context> context = v8::Context::GetCurrent();
v8::Handle<v8::Context> context = isolate->GetCurrentContext();
scoped_ptr<atom::V8ValueConverter> converter(new atom::V8ValueConverter);
mate::Handle<mate::Event> event = mate::Event::Create(node_isolate);
mate::Handle<mate::Event> event = mate::Event::Create(isolate);
if (sender && message)
event->SetSenderAndMessage(sender, message);
// v8_args = [name, event, args...];
std::vector<v8::Handle<v8::Value>> v8_args;
v8_args.reserve(args.GetSize() + 2);
v8_args.push_back(mate::StringToV8(node_isolate, name));
v8_args.push_back(mate::StringToV8(isolate, name));
v8_args.push_back(event.ToV8());
for (size_t i = 0; i < args.GetSize(); i++) {
const base::Value* value(NULL);
@ -53,8 +54,8 @@ bool EventEmitter::Emit(const base::StringPiece& name,
}
// this.emit.apply(this, v8_args);
node::MakeCallback(
GetWrapper(node_isolate), "emit", v8_args.size(), &v8_args[0]);
node::MakeCallback(isolate, GetWrapper(isolate), "emit", v8_args.size(),
&v8_args[0]);
return event->prevent_default();
}

View file

@ -51,9 +51,10 @@ void AtomBrowserMainParts::PostEarlyInitialization() {
v8::V8::Initialize();
// Create context.
v8::Locker locker(node_isolate);
v8::HandleScope handle_scope(node_isolate);
v8::Local<v8::Context> context = v8::Context::New(node_isolate);
v8::Isolate* isolate = v8::Isolate::GetCurrent();
v8::Locker locker(isolate);
v8::HandleScope handle_scope(isolate);
v8::Local<v8::Context> context = v8::Context::New(isolate);
// Create the global environment.
global_env = node_bindings_->CreateEnvironment(context);

2
vendor/native_mate vendored

@ -1 +1 @@
Subproject commit c49cebacb23149f82571b2ca691be7d9a345352c
Subproject commit 6f574c38020bdf9d6ed9dd079905f4b110fbd10e