Store BrowserContext in ref-counted ptr

This commit is contained in:
Cheng Zhao 2015-09-05 20:03:40 +08:00
parent 3773f81fd5
commit ba25bed45b
3 changed files with 7 additions and 14 deletions

View file

@ -52,19 +52,13 @@ AtomBrowserMainParts* AtomBrowserMainParts::Get() {
content::BrowserContext* AtomBrowserMainParts::GetBrowserContextForPartition(
const std::string& partition, bool in_memory) {
if (browser_context_map_.contains(partition))
return browser_context_map_.get(partition);
if (ContainsKey(browser_context_map_, partition))
return browser_context_map_[partition].get();
scoped_ptr<brightray::BrowserContext> browser_context(CreateBrowserContext());
<<<<<<< HEAD
browser_context->Initialize(partition_path.AsUTF8Unsafe(), in_memory);
browser_context_map_.set(id, browser_context.Pass());
return browser_context_map_.get(id);
=======
brightray::BrowserContext* browser_context = CreateBrowserContext();
browser_context->Initialize(partition, in_memory);
browser_context_map_.set(partition, browser_context.Pass());
return browser_context_map_.get(partition);
>>>>>>> Pass partition name instead of path to BrowserContext
browser_context_map_[partition] = make_scoped_refptr(browser_context);
return browser_context;
}
void AtomBrowserMainParts::RegisterDestructionCallback(

View file

@ -10,7 +10,6 @@
#include <string>
#include "base/callback.h"
#include "base/containers/scoped_ptr_hash_map.h"
#include "base/timer/timer.h"
#include "brightray/browser/browser_main_parts.h"
#include "content/public/browser/browser_context.h"
@ -79,7 +78,7 @@ class AtomBrowserMainParts : public brightray::BrowserMainParts {
std::list<base::Closure> destruction_callbacks_;
// partition_id => browser_context
base::ScopedPtrHashMap<std::string, scoped_ptr<brightray::BrowserContext>>
std::map<std::string, scoped_refptr<brightray::BrowserContext>>
browser_context_map_;
static AtomBrowserMainParts* self_;

2
vendor/brightray vendored

@ -1 +1 @@
Subproject commit 55bab304fd1c92a79e636bca0313f7cbda000c06
Subproject commit ca80107e3dec28d5b49d64da9985525c3e2c4e84