Skip to content

Commit

Permalink
Merge pull request #3715 from brave/pr3710_fix_delete_legacy_tor_dche…
Browse files Browse the repository at this point in the history
…ck_0.72.x

Fix DCHECK when deleting legacy Tor profile (uplift to 0.72.x)
  • Loading branch information
yrliou authored Oct 16, 2019
2 parents dc5776e + 8fbf535 commit 01b138b
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions browser/brave_browser_main_parts.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,14 @@
#include "media/base/media_switches.h"

#if BUILDFLAG(ENABLE_TOR)
#include <string>
#include "base/files/file_util.h"
#include "brave/common/tor/tor_constants.h"
#include "chrome/browser/browser_process_impl.h"
#include "chrome/browser/profiles/profile_attributes_storage.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/profiles/profile_metrics.h"
#include "components/account_id/account_id.h"
#endif

#if !defined(OS_ANDROID)
Expand All @@ -42,6 +45,18 @@ void BraveBrowserMainParts::PostBrowserStart() {

// Delete Tor legacy profile if exists.
if (base::PathExists(tor_legacy_path)) {
// Add tor legacy path into profile attributes storage first if nonexist
// because we will hit DCHECK(!GetProfileAttributesWithPath(...)) in
// ProfileInfoCache::DeleteProfileFromCache when we trying to delete it
// without this being added into the storage first.
ProfileAttributesEntry* entry = nullptr;
ProfileAttributesStorage& storage =
profile_manager->GetProfileAttributesStorage();
if (!storage.GetProfileAttributesWithPath(tor_legacy_path, &entry)) {
storage.AddProfile(tor_legacy_path, base::string16(), std::string(),
base::string16(), 0, std::string(), EmptyAccountId());
}

profile_manager->MaybeScheduleProfileForDeletion(
tor_legacy_path, base::DoNothing(),
ProfileMetrics::DELETE_PROFILE_SETTINGS);
Expand Down

0 comments on commit 01b138b

Please sign in to comment.