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);
} // 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() {
}
} // namespace atom
+
+namespace brightray {
+
+// static
+BrowserContext* BrowserContext::Create(const std::string& partition,
+ bool in_memory) {
+ return new atom::AtomBrowserContext(partition, in_memory);
+}
+
+} // namespace brightray
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;
scoped_ptr<AtomDownloadManagerDelegate> download_manager_delegate_;
scoped_ptr<WebViewManager> guest_manager_;
- AtomURLRequestJobFactory* job_factory_; // Weak reference.
+ // Managed by brightray::BrowserContext.
+ AtomURLRequestJobFactory* job_factory_;
DISALLOW_COPY_AND_ASSIGN(AtomBrowserContext);
};
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();
#define ATOM_BROWSER_ATOM_BROWSER_MAIN_PARTS_H_
#include <list>
-#include <map>
#include <string>
#include "base/callback.h"
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);
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)
// List of callbacks should be executed before destroying JS env.
std::list<base::Closure> destruction_callbacks_;
- // partition_id => browser_context
- std::map<std::string, scoped_refptr<brightray::BrowserContext>>
- browser_context_map_;
-
static AtomBrowserMainParts* self_;
DISALLOW_COPY_AND_ASSIGN(AtomBrowserMainParts);
-Subproject commit ca80107e3dec28d5b49d64da9985525c3e2c4e84
+Subproject commit b103a37d05335766421f4228fcb392cc57f8ea67