Wrap callbacks with v8::Locker.
In browser process, because of the use of v8::Locker in ProxyResolverV8, creating HandleScope requires entering locker first, so in browser process we should just use v8::Locker whenever we need to use V8 in a callback called from non-V8 places (like dialog's callback, work pushed to MessageLoop). But also notice that the renderer process doesn't use v8::Locker, so we have to be careful not to use it, otherwise blink would crash when creating HandleScope.
This commit is contained in:
parent
5250871e69
commit
d63de1ae15
8 changed files with 32 additions and 0 deletions
|
@ -24,6 +24,7 @@ v8::Handle<v8::Value> CallDelegate(v8::Handle<v8::Value> default_value,
|
|||
v8::Handle<v8::Object> menu,
|
||||
const char* method,
|
||||
int command_id) {
|
||||
v8::Locker locker(node_isolate);
|
||||
v8::HandleScope handle_scope(node_isolate);
|
||||
|
||||
v8::Handle<v8::Value> delegate = menu->Get(v8::String::New("delegate"));
|
||||
|
@ -52,6 +53,7 @@ Menu::~Menu() {
|
|||
}
|
||||
|
||||
bool Menu::IsCommandIdChecked(int command_id) const {
|
||||
v8::Locker locker(node_isolate);
|
||||
v8::HandleScope handle_scope(node_isolate);
|
||||
return CallDelegate(v8::False(),
|
||||
const_cast<Menu*>(this)->handle(),
|
||||
|
@ -60,6 +62,7 @@ bool Menu::IsCommandIdChecked(int command_id) const {
|
|||
}
|
||||
|
||||
bool Menu::IsCommandIdEnabled(int command_id) const {
|
||||
v8::Locker locker(node_isolate);
|
||||
v8::HandleScope handle_scope(node_isolate);
|
||||
return CallDelegate(v8::True(),
|
||||
const_cast<Menu*>(this)->handle(),
|
||||
|
@ -68,6 +71,7 @@ bool Menu::IsCommandIdEnabled(int command_id) const {
|
|||
}
|
||||
|
||||
bool Menu::IsCommandIdVisible(int command_id) const {
|
||||
v8::Locker locker(node_isolate);
|
||||
v8::HandleScope handle_scope(node_isolate);
|
||||
return CallDelegate(v8::True(),
|
||||
const_cast<Menu*>(this)->handle(),
|
||||
|
@ -77,6 +81,7 @@ bool Menu::IsCommandIdVisible(int command_id) const {
|
|||
|
||||
bool Menu::GetAcceleratorForCommandId(int command_id,
|
||||
ui::Accelerator* accelerator) {
|
||||
v8::Locker locker(node_isolate);
|
||||
v8::HandleScope handle_scope(node_isolate);
|
||||
v8::Handle<v8::Value> shortcut = CallDelegate(v8::Undefined(),
|
||||
handle(),
|
||||
|
@ -91,6 +96,7 @@ bool Menu::GetAcceleratorForCommandId(int command_id,
|
|||
}
|
||||
|
||||
bool Menu::IsItemForCommandIdDynamic(int command_id) const {
|
||||
v8::Locker locker(node_isolate);
|
||||
v8::HandleScope handle_scope(node_isolate);
|
||||
return CallDelegate(v8::False(),
|
||||
const_cast<Menu*>(this)->handle(),
|
||||
|
@ -99,6 +105,7 @@ bool Menu::IsItemForCommandIdDynamic(int command_id) const {
|
|||
}
|
||||
|
||||
string16 Menu::GetLabelForCommandId(int command_id) const {
|
||||
v8::Locker locker(node_isolate);
|
||||
v8::HandleScope handle_scope(node_isolate);
|
||||
return FromV8Value(CallDelegate(v8::False(),
|
||||
const_cast<Menu*>(this)->handle(),
|
||||
|
@ -107,6 +114,7 @@ string16 Menu::GetLabelForCommandId(int command_id) const {
|
|||
}
|
||||
|
||||
string16 Menu::GetSublabelForCommandId(int command_id) const {
|
||||
v8::Locker locker(node_isolate);
|
||||
v8::HandleScope handle_scope(node_isolate);
|
||||
return FromV8Value(CallDelegate(v8::False(),
|
||||
const_cast<Menu*>(this)->handle(),
|
||||
|
@ -115,6 +123,7 @@ string16 Menu::GetSublabelForCommandId(int command_id) const {
|
|||
}
|
||||
|
||||
void Menu::ExecuteCommand(int command_id, int event_flags) {
|
||||
v8::Locker locker(node_isolate);
|
||||
v8::HandleScope handle_scope(node_isolate);
|
||||
CallDelegate(v8::False(), handle(), "executeCommand", command_id);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue