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:
Cheng Zhao 2014-01-27 15:14:11 +08:00
parent 5250871e69
commit d63de1ae15
8 changed files with 32 additions and 0 deletions

View file

@ -35,6 +35,7 @@ static const char* kEarlyUseProtocolError = "This method can only be used"
// Emit an event for the protocol module.
void EmitEventInUI(const std::string& event, const std::string& parameter) {
v8::Locker locker(node_isolate);
v8::HandleScope handle_scope(node_isolate);
v8::Handle<v8::Value> argv[] = {
@ -72,6 +73,7 @@ class CustomProtocolRequestJob : public AdapterRequestJob {
virtual void GetJobTypeInUI() OVERRIDE {
DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
v8::Locker locker(node_isolate);
v8::HandleScope handle_scope(node_isolate);
// Call the JS handler.