diff --git a/atom/browser/api/atom_api_web_contents.cc b/atom/browser/api/atom_api_web_contents.cc index d8201973fd8..e9165657011 100644 --- a/atom/browser/api/atom_api_web_contents.cc +++ b/atom/browser/api/atom_api_web_contents.cc @@ -170,10 +170,8 @@ WebContents::WebContents(v8::Isolate* isolate, bool in_memory = false; options.Get("partition", &partition); options.Get("inMemory", &in_memory); - if (!partition.empty()) { - browser_context = AtomBrowserMainParts::Get() - ->GetBrowserContextForPartition(partition, in_memory); - } + if (!partition.empty()) + browser_context = brightray::BrowserContext::From(partition, in_memory); content::SiteInstance* site_instance = content::SiteInstance::CreateForURL( browser_context, GURL("chrome-guest://fake-host")); content::WebContents::CreateParams params(browser_context, site_instance); diff --git a/atom/browser/atom_browser_context.cc b/atom/browser/atom_browser_context.cc index 43573b1c707..81973857b12 100644 --- a/atom/browser/atom_browser_context.cc +++ b/atom/browser/atom_browser_context.cc @@ -56,8 +56,10 @@ std::string RemoveWhitespace(const std::string& str) { } // namespace -AtomBrowserContext::AtomBrowserContext() - : job_factory_(new AtomURLRequestJobFactory) { +AtomBrowserContext::AtomBrowserContext(const std::string& partition, + bool in_memory) + : brightray::BrowserContext(partition, in_memory), + job_factory_(new AtomURLRequestJobFactory) { } AtomBrowserContext::~AtomBrowserContext() { @@ -162,3 +164,13 @@ void AtomBrowserContext::RegisterPrefs(PrefRegistrySimple* pref_registry) { } } // namespace atom + +namespace brightray { + +// static +BrowserContext* BrowserContext::Create(const std::string& partition, + bool in_memory) { + return new atom::AtomBrowserContext(partition, in_memory); +} + +} // namespace brightray diff --git a/atom/browser/atom_browser_context.h b/atom/browser/atom_browser_context.h index c1ff613b8c0..c99461ad9a8 100644 --- a/atom/browser/atom_browser_context.h +++ b/atom/browser/atom_browser_context.h @@ -17,8 +17,8 @@ class WebViewManager; class AtomBrowserContext : public brightray::BrowserContext { public: - AtomBrowserContext(); - virtual ~AtomBrowserContext(); + AtomBrowserContext(const std::string& partition, bool in_memory); + ~AtomBrowserContext() override; // brightray::URLRequestContextGetter::Delegate: std::string GetUserAgent() override; @@ -41,7 +41,8 @@ class AtomBrowserContext : public brightray::BrowserContext { scoped_ptr download_manager_delegate_; scoped_ptr guest_manager_; - AtomURLRequestJobFactory* job_factory_; // Weak reference. + // Managed by brightray::BrowserContext. + AtomURLRequestJobFactory* job_factory_; DISALLOW_COPY_AND_ASSIGN(AtomBrowserContext); }; diff --git a/atom/browser/atom_browser_main_parts.cc b/atom/browser/atom_browser_main_parts.cc index e614f9b6365..31a49046414 100644 --- a/atom/browser/atom_browser_main_parts.cc +++ b/atom/browser/atom_browser_main_parts.cc @@ -50,26 +50,11 @@ AtomBrowserMainParts* AtomBrowserMainParts::Get() { return self_; } -content::BrowserContext* AtomBrowserMainParts::GetBrowserContextForPartition( - const std::string& partition, bool in_memory) { - if (ContainsKey(browser_context_map_, partition)) - return browser_context_map_[partition].get(); - - brightray::BrowserContext* browser_context = CreateBrowserContext(); - browser_context->Initialize(partition, in_memory); - browser_context_map_[partition] = make_scoped_refptr(browser_context); - return browser_context; -} - void AtomBrowserMainParts::RegisterDestructionCallback( const base::Closure& callback) { destruction_callbacks_.push_back(callback); } -brightray::BrowserContext* AtomBrowserMainParts::CreateBrowserContext() { - return new AtomBrowserContext(); -} - void AtomBrowserMainParts::PostEarlyInitialization() { brightray::BrowserMainParts::PostEarlyInitialization(); diff --git a/atom/browser/atom_browser_main_parts.h b/atom/browser/atom_browser_main_parts.h index de53f66788b..59ff7c977c8 100644 --- a/atom/browser/atom_browser_main_parts.h +++ b/atom/browser/atom_browser_main_parts.h @@ -6,7 +6,6 @@ #define ATOM_BROWSER_ATOM_BROWSER_MAIN_PARTS_H_ #include -#include #include #include "base/callback.h" @@ -32,10 +31,6 @@ class AtomBrowserMainParts : public brightray::BrowserMainParts { static AtomBrowserMainParts* Get(); - // Returns the BrowserContext associated with the partition. - content::BrowserContext* GetBrowserContextForPartition( - const std::string& partition, bool in_memory); - // Register a callback that should be destroyed before JavaScript environment // gets destroyed. void RegisterDestructionCallback(const base::Closure& callback); @@ -43,10 +38,7 @@ class AtomBrowserMainParts : public brightray::BrowserMainParts { Browser* browser() { return browser_.get(); } protected: - // Implementations of brightray::BrowserMainParts. - brightray::BrowserContext* CreateBrowserContext() override; - - // Implementations of content::BrowserMainParts. + // content::BrowserMainParts: void PostEarlyInitialization() override; void PreMainMessageLoopRun() override; #if defined(OS_MACOSX) @@ -77,10 +69,6 @@ class AtomBrowserMainParts : public brightray::BrowserMainParts { // List of callbacks should be executed before destroying JS env. std::list destruction_callbacks_; - // partition_id => browser_context - std::map> - browser_context_map_; - static AtomBrowserMainParts* self_; DISALLOW_COPY_AND_ASSIGN(AtomBrowserMainParts); diff --git a/vendor/brightray b/vendor/brightray index ca80107e3de..b103a37d053 160000 --- a/vendor/brightray +++ b/vendor/brightray @@ -1 +1 @@ -Subproject commit ca80107e3dec28d5b49d64da9985525c3e2c4e84 +Subproject commit b103a37d05335766421f4228fcb392cc57f8ea67