Skip to content

Commit

Permalink
Merge pull request #7929 from brave/ipfs_clear_cache_remove_unretained
Browse files Browse the repository at this point in the history
Remove base::Unretained usage in BraveBrowsingDataRemoverDelegate::Cl…
  • Loading branch information
yrliou authored Feb 11, 2021
2 parents 2b7826e + e94e2c0 commit e3d28f7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
8 changes: 6 additions & 2 deletions browser/browsing_data/brave_browsing_data_remover_delegate.cc
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ BraveBrowsingDataRemoverDelegate::BraveBrowsingDataRemoverDelegate(
: ChromeBrowsingDataRemoverDelegate(browser_context),
profile_(Profile::FromBrowserContext(browser_context)) {}

BraveBrowsingDataRemoverDelegate::~BraveBrowsingDataRemoverDelegate() = default;

void BraveBrowsingDataRemoverDelegate::RemoveEmbedderData(
const base::Time& delete_begin,
const base::Time& delete_end,
Expand Down Expand Up @@ -170,9 +172,11 @@ void BraveBrowsingDataRemoverDelegate::ClearIPFSCache() {
}

base::ThreadPool::PostTaskAndReply(
FROM_HERE, {base::TaskPriority::USER_VISIBLE, base::MayBlock()},
FROM_HERE,
{base::TaskPriority::USER_VISIBLE, base::MayBlock(),
base::TaskShutdownBehavior::CONTINUE_ON_SHUTDOWN},
base::BindOnce(&BraveBrowsingDataRemoverDelegate::WaitForIPFSRepoGC,
base::Unretained(this), base::Passed(&process)),
weak_ptr_factory_.GetWeakPtr(), base::Passed(&process)),
CreateTaskCompletionClosure(TracingDataType::kIPFSCache));
}
#endif // BUILDFLAG(IPFS_ENABLED)
5 changes: 4 additions & 1 deletion browser/browsing_data/brave_browsing_data_remover_delegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#ifndef BRAVE_BROWSER_BROWSING_DATA_BRAVE_BROWSING_DATA_REMOVER_DELEGATE_H_
#define BRAVE_BROWSER_BROWSING_DATA_BRAVE_BROWSING_DATA_REMOVER_DELEGATE_H_

#include "base/memory/weak_ptr.h"
#include "base/time/time.h"
#include "brave/components/ipfs/buildflags/buildflags.h"
#include "chrome/browser/browsing_data/chrome_browsing_data_remover_delegate.h"
Expand All @@ -25,7 +26,7 @@ class BraveBrowsingDataRemoverDelegate
public:
explicit BraveBrowsingDataRemoverDelegate(
content::BrowserContext* browser_context);
~BraveBrowsingDataRemoverDelegate() override = default;
~BraveBrowsingDataRemoverDelegate() override;

BraveBrowsingDataRemoverDelegate(
const BraveBrowsingDataRemoverDelegate&) = delete;
Expand All @@ -52,6 +53,8 @@ class BraveBrowsingDataRemoverDelegate
#endif

Profile* profile_;
base::WeakPtrFactory<BraveBrowsingDataRemoverDelegate> weak_ptr_factory_{
this};
};

#endif // BRAVE_BROWSER_BROWSING_DATA_BRAVE_BROWSING_DATA_REMOVER_DELEGATE_H_

0 comments on commit e3d28f7

Please sign in to comment.