Chromium Code Reviews| Index: net/proxy/proxy_resolver_v8.cc |
| diff --git a/net/proxy/proxy_resolver_v8.cc b/net/proxy/proxy_resolver_v8.cc |
| index 51503170ae7b64e8ffa3a3fa57c921644d6c7054..d8f2add743d57c2684b46edfe9d93b426ee7bcd8 100644 |
| --- a/net/proxy/proxy_resolver_v8.cc |
| +++ b/net/proxy/proxy_resolver_v8.cc |
| @@ -335,14 +335,16 @@ bool IsInNetEx(const std::string& ip_address, const std::string& ip_prefix) { |
| class ProxyResolverV8::Context { |
| public: |
| - explicit Context(ProxyResolverJSBindings* js_bindings) |
| + explicit Context(ProxyResolverJSBindings* js_bindings, |
|
eroman
2013/01/18 19:21:14
nit: no more need for constructor to be marked exp
Sven Panne
2013/01/21 08:50:06
Done.
|
| + v8::Isolate* v8_default_isolate) |
| : is_resolving_host_(false), |
| - js_bindings_(js_bindings) { |
| + js_bindings_(js_bindings), |
| + v8_default_isolate_(v8_default_isolate) { |
| DCHECK(js_bindings != NULL); |
| } |
| ~Context() { |
| - v8::Locker locked; |
| + v8::Locker locked(v8_default_isolate_); |
| v8_this_.Dispose(); |
| v8_context_.Dispose(); |
| @@ -355,7 +357,7 @@ class ProxyResolverV8::Context { |
| } |
| int ResolveProxy(const GURL& query_url, ProxyInfo* results) { |
| - v8::Locker locked; |
| + v8::Locker locked(v8_default_isolate_); |
| v8::HandleScope scope; |
| v8::Context::Scope function_scope(v8_context_); |
| @@ -406,7 +408,7 @@ class ProxyResolverV8::Context { |
| } |
| int InitV8(const scoped_refptr<ProxyResolverScriptData>& pac_script) { |
| - v8::Locker locked; |
| + v8::Locker locked(v8_default_isolate_); |
| v8::HandleScope scope; |
| v8_this_ = v8::Persistent<v8::External>::New(v8::External::New(this)); |
| @@ -488,7 +490,7 @@ class ProxyResolverV8::Context { |
| } |
| void PurgeMemory() { |
| - v8::Locker locked; |
| + v8::Locker locked(v8_default_isolate_); |
| v8::V8::LowMemoryNotification(); |
| } |
| @@ -595,7 +597,7 @@ class ProxyResolverV8::Context { |
| bool success; |
| { |
| - v8::Unlocker unlocker; |
| + v8::Unlocker unlocker(args.GetIsolate()); |
| ScopedHostResolve scoped_host_resolve(context); |
| // We shouldn't be called with any arguments, but will not complain if |
| @@ -618,7 +620,7 @@ class ProxyResolverV8::Context { |
| bool success; |
| { |
| - v8::Unlocker unlocker; |
| + v8::Unlocker unlocker(args.GetIsolate()); |
| ScopedHostResolve scoped_host_resolve(context); |
| // We shouldn't be called with any arguments, but will not complain if |
| @@ -645,7 +647,7 @@ class ProxyResolverV8::Context { |
| bool success; |
| { |
| - v8::Unlocker unlocker; |
| + v8::Unlocker unlocker(args.GetIsolate()); |
| ScopedHostResolve scoped_host_resolve(context); |
| success = context->js_bindings_->DnsResolve(hostname, &ip_address); |
| } |
| @@ -667,7 +669,7 @@ class ProxyResolverV8::Context { |
| bool success; |
| { |
| - v8::Unlocker unlocker; |
| + v8::Unlocker unlocker(args.GetIsolate()); |
| ScopedHostResolve scoped_host_resolve(context); |
| success = context->js_bindings_->DnsResolveEx(hostname, &ip_address_list); |
| } |
| @@ -714,6 +716,7 @@ class ProxyResolverV8::Context { |
| mutable base::Lock lock_; |
| bool is_resolving_host_; |
| ProxyResolverJSBindings* js_bindings_; |
| + v8::Isolate* v8_default_isolate_; |
| v8::Persistent<v8::External> v8_this_; |
| v8::Persistent<v8::Context> v8_context_; |
| }; |
| @@ -721,9 +724,11 @@ class ProxyResolverV8::Context { |
| // ProxyResolverV8 ------------------------------------------------------------ |
| ProxyResolverV8::ProxyResolverV8( |
| - ProxyResolverJSBindings* custom_js_bindings) |
| + ProxyResolverJSBindings* custom_js_bindings, |
| + v8::Isolate* v8_default_isolate) |
| : ProxyResolver(true /*expects_pac_bytes*/), |
| - js_bindings_(custom_js_bindings) { |
| + js_bindings_(custom_js_bindings), |
| + v8_default_isolate_(v8_default_isolate) { |
| } |
| ProxyResolverV8::~ProxyResolverV8() {} |
| @@ -794,7 +799,8 @@ int ProxyResolverV8::SetPacScript( |
| return ERR_PAC_SCRIPT_FAILED; |
| // Try parsing the PAC script. |
| - scoped_ptr<Context> context(new Context(js_bindings_.get())); |
| + scoped_ptr<Context> context(new Context(js_bindings_.get(), |
| + v8_default_isolate_)); |
| int rv = context->InitV8(script_data); |
| if (rv == OK) |
| context_.reset(context.release()); |