Skip to content
This repository has been archived by the owner on Jan 4, 2019. It is now read-only.

Commit

Permalink
remove circular reference for persistent/private profile
Browse files Browse the repository at this point in the history
  • Loading branch information
bridiver committed Jun 29, 2016
1 parent 76bd4e8 commit 6e31e0e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
12 changes: 7 additions & 5 deletions atom/browser/atom_browser_context.cc
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ AtomBrowserContext::AtomBrowserContext(const std::string& partition,
#endif
partition_(partition) {
if (in_memory) {
original_context_ = AtomBrowserContext::From(partition, false);
original_context_ = AtomBrowserContext::From(partition, false).get();
original_context()->otr_context_ = this;
}
}
Expand All @@ -125,8 +125,10 @@ AtomBrowserContext::~AtomBrowserContext() {

if (otr_context_.get()) {
// destroy the otr profile
otr_context()->user_prefs()->ClearMutableValues();
otr_context_.swap(nullptr);
auto user_prefs = user_prefs::UserPrefs::Get(otr_context_.get());
if (user_prefs)
user_prefs->ClearMutableValues();
otr_context_ = NULL;
} else {
ExtensionPrefValueMapFactory::GetForBrowserContext(this)->
ClearAllIncognitoSessionOnlyPreferences();
Expand All @@ -145,7 +147,7 @@ AtomBrowserContext* AtomBrowserContext::original_context() {
if (!IsOffTheRecord()) {
return this;
}
return static_cast<AtomBrowserContext*>(original_context_.get());
return static_cast<AtomBrowserContext*>(original_context_);
}

AtomBrowserContext* AtomBrowserContext::otr_context() {
Expand Down Expand Up @@ -314,7 +316,7 @@ void AtomBrowserContext::RegisterUserPrefs() {
new JsonPrefStore(filepath, task_runner, std::unique_ptr<PrefFilter>());

// prepare factory
bool async = false;
bool async = true;
syncable_prefs::PrefServiceSyncableFactory factory;
factory.set_async(async);
factory.set_extension_prefs(extension_prefs);
Expand Down
2 changes: 1 addition & 1 deletion atom/browser/atom_browser_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ class AtomBrowserContext : public brightray::BrowserContext {
AtomCertVerifier* cert_verifier_;
AtomNetworkDelegate* network_delegate_;

scoped_refptr<brightray::BrowserContext> original_context_;
brightray::BrowserContext* original_context_;
scoped_refptr<brightray::BrowserContext> otr_context_;
const std::string partition_;

Expand Down

0 comments on commit 6e31e0e

Please sign in to comment.