Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(661)

Unified Diff: net/proxy/proxy_resolver_v8.cc

Issue 11959029: Make the v8 Isolate used in the proxy resolver explicit. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased. Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« chrome/browser/io_thread.cc ('K') | « net/proxy/proxy_resolver_v8.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/proxy/proxy_resolver_v8.cc
diff --git a/net/proxy/proxy_resolver_v8.cc b/net/proxy/proxy_resolver_v8.cc
index 935072b33ea431e8e1fc55e9094e1db1244cc470..72254b318ac4ec1e21527f6a949ae4b966c6aed6 100644
--- a/net/proxy/proxy_resolver_v8.cc
+++ b/net/proxy/proxy_resolver_v8.cc
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#define V8_DISABLE_DEPRECATIONS 1
-
#include "net/proxy/proxy_resolver_v8.h"
#include <algorithm>
@@ -334,15 +332,17 @@ bool IsInNetEx(const std::string& ip_address, const std::string& ip_prefix) {
class ProxyResolverV8::Context {
public:
- explicit Context(ProxyResolverV8* parent)
- : parent_(parent) {
+ Context(ProxyResolverV8* parent, v8::Isolate* isolate)
+ : parent_(parent),
+ isolate_(isolate) {
+ DCHECK(isolate);
}
~Context() {
- v8::Locker locked;
+ v8::Locker locked(isolate_);
- v8_this_.Dispose();
- v8_context_.Dispose();
+ v8_this_.Dispose(isolate_);
+ v8_context_.Dispose(isolate_);
}
JSBindings* js_bindings() {
@@ -350,7 +350,7 @@ class ProxyResolverV8::Context {
}
int ResolveProxy(const GURL& query_url, ProxyInfo* results) {
- v8::Locker locked;
+ v8::Locker locked(isolate_);
v8::HandleScope scope;
v8::Context::Scope function_scope(v8_context_);
@@ -401,10 +401,11 @@ class ProxyResolverV8::Context {
}
int InitV8(const scoped_refptr<ProxyResolverScriptData>& pac_script) {
- v8::Locker locked;
+ v8::Locker locked(isolate_);
v8::HandleScope scope;
- v8_this_ = v8::Persistent<v8::External>::New(v8::External::New(this));
+ v8_this_ = v8::Persistent<v8::External>::New(isolate_,
+ v8::External::New(this));
v8::Local<v8::ObjectTemplate> global_template = v8::ObjectTemplate::New();
// Attach the javascript bindings.
@@ -479,7 +480,7 @@ class ProxyResolverV8::Context {
}
void PurgeMemory() {
- v8::Locker locked;
+ v8::Locker locked(isolate_);
v8::V8::LowMemoryNotification();
}
@@ -669,6 +670,7 @@ class ProxyResolverV8::Context {
mutable base::Lock lock_;
ProxyResolverV8* parent_;
+ v8::Isolate* isolate_;
v8::Persistent<v8::External> v8_this_;
v8::Persistent<v8::Context> v8_context_;
};
@@ -729,11 +731,30 @@ int ProxyResolverV8::SetPacScript(
return ERR_PAC_SCRIPT_FAILED;
// Try parsing the PAC script.
- scoped_ptr<Context> context(new Context(this));
+ scoped_ptr<Context> context(new Context(this, GetDefaultIsolate()));
int rv = context->InitV8(script_data);
if (rv == OK)
context_.reset(context.release());
return rv;
}
+// static
+void ProxyResolverV8::RememberDefaultIsolate() {
+ v8::Isolate* isolate = v8::Isolate::GetCurrent();
+ DCHECK(isolate)
+ << "ProxyResolverV8::RememberDefaultIsolate called on wrong thread";
+ DCHECK(g_default_isolate_ == NULL || g_default_isolate_ == isolate)
+ << "Default Isolate can not be changed";
+ g_default_isolate_ = isolate;
+}
+
+// static
+v8::Isolate* ProxyResolverV8::GetDefaultIsolate() {
+ DCHECK(g_default_isolate_)
+ << "Must call ProxyResolverV8::RememberDefaultIsolate() first";
+ return g_default_isolate_;
+}
+
+v8::Isolate* ProxyResolverV8::g_default_isolate_ = NULL;
+
} // namespace net
« chrome/browser/io_thread.cc ('K') | « net/proxy/proxy_resolver_v8.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698