Fix proxy V8 initialization failure resulting from Chromium update.

git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@1110 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
This commit is contained in:
Marshall Greenblatt 2013-02-26 22:54:26 +00:00
parent 0ae0f6cd85
commit d9a4c5690b
2 changed files with 23 additions and 1 deletions

View File

@ -20,7 +20,9 @@
#include "content/public/common/content_client.h" #include "content/public/common/content_client.h"
#include "content/public/common/content_switches.h" #include "content/public/common/content_switches.h"
#include "net/base/net_module.h" #include "net/base/net_module.h"
#include "net/proxy/proxy_resolver_v8.h"
#include "ui/base/resource/resource_bundle.h" #include "ui/base/resource/resource_bundle.h"
#include "v8/include/v8.h"
namespace { namespace {
@ -34,7 +36,8 @@ base::StringPiece ResourceProvider(int resource_id) {
CefBrowserMainParts::CefBrowserMainParts( CefBrowserMainParts::CefBrowserMainParts(
const content::MainFunctionParams& parameters) const content::MainFunctionParams& parameters)
: BrowserMainParts(), : BrowserMainParts(),
devtools_delegate_(NULL) { devtools_delegate_(NULL),
proxy_v8_isolate_(NULL) {
} }
CefBrowserMainParts::~CefBrowserMainParts() { CefBrowserMainParts::~CefBrowserMainParts() {
@ -60,6 +63,15 @@ int CefBrowserMainParts::PreCreateThreads() {
user_prefs_ = new BrowserPrefStore(); user_prefs_ = new BrowserPrefStore();
user_prefs_->SetInitializationCompleted(); user_prefs_->SetInitializationCompleted();
// Create a v8::Isolate for the current thread if it doesn't already exist.
if (!v8::Isolate::GetCurrent()) {
proxy_v8_isolate_ = v8::Isolate::New();
proxy_v8_isolate_->Enter();
}
// Initialize the V8 proxy integration.
net::ProxyResolverV8::RememberDefaultIsolate();
// Initialize proxy configuration tracker. // Initialize proxy configuration tracker.
pref_proxy_config_tracker_.reset( pref_proxy_config_tracker_.reset(
ProxyServiceFactory::CreatePrefProxyConfigTracker( ProxyServiceFactory::CreatePrefProxyConfigTracker(
@ -105,5 +117,10 @@ void CefBrowserMainParts::PostMainMessageLoopRun() {
void CefBrowserMainParts::PostDestroyThreads() { void CefBrowserMainParts::PostDestroyThreads() {
pref_proxy_config_tracker_.reset(NULL); pref_proxy_config_tracker_.reset(NULL);
if (proxy_v8_isolate_) {
proxy_v8_isolate_->Exit();
proxy_v8_isolate_->Dispose();
}
PlatformCleanup(); PlatformCleanup();
} }

View File

@ -23,6 +23,10 @@ namespace content {
struct MainFunctionParams; struct MainFunctionParams;
} }
namespace v8 {
class Isolate;
}
class CefBrowserContext; class CefBrowserContext;
class CefDevToolsDelegate; class CefDevToolsDelegate;
class MessageLoop; class MessageLoop;
@ -54,6 +58,7 @@ class CefBrowserMainParts : public content::BrowserMainParts {
scoped_ptr<PrefProxyConfigTracker> pref_proxy_config_tracker_; scoped_ptr<PrefProxyConfigTracker> pref_proxy_config_tracker_;
scoped_ptr<net::ProxyConfigService> proxy_config_service_; scoped_ptr<net::ProxyConfigService> proxy_config_service_;
scoped_refptr<BrowserPrefStore> user_prefs_; scoped_refptr<BrowserPrefStore> user_prefs_;
v8::Isolate* proxy_v8_isolate_;
DISALLOW_COPY_AND_ASSIGN(CefBrowserMainParts); DISALLOW_COPY_AND_ASSIGN(CefBrowserMainParts);
}; };