-
Notifications
You must be signed in to change notification settings - Fork 920
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Clear IPFS cache when clearing browsing data #7578
Conversation
6cfb437
to
f8647b2
Compare
f8647b2
to
030dca1
Compare
FROM_HERE, {base::TaskPriority::USER_VISIBLE, base::MayBlock()}, | ||
base::BindOnce(&BraveBrowsingDataRemoverDelegate::WaitForIPFSRepoGC, | ||
base::Unretained(this), base::Passed(&process)), | ||
CreateTaskCompletionClosure(TracingDataType::kHostCache)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
kHostCache is the most reasonable existing one I could find in the list, type value is only meant for recording purpose, so we should be good here. This value is gone in chromium latest version, so we would need to update the value to kEmbedderData during future chromium upgrade.
#include "base/task/thread_pool.h" | ||
#include "base/threading/thread_restrictions.h" | ||
#include "base/time/time.h" | ||
#include "brave/browser/ipfs/ipfs_service_factory.h" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This does not have the dependency added in this PR.
We have some existing deps problems for the browsing_data target, which I would like it to be addressed in a separate PR.
For chromium, their browsing_data_remover_delegate source files are listed in the browser target itself, I think we should probably consider doing the same since we need chrome/browser and brave/browser in existing files in our browsing_data target.
030dca1
to
50c6f40
Compare
return; | ||
|
||
base::FilePath path = service->GetIpfsExecutablePath(); | ||
if (path.empty()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should get the last known good path when the executable path is not determined here please in a follow up.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, opened brave/brave-browser#13605.
class BraveBrowsingDataRemoverDelegate; | ||
|
||
#define BRAVE_CHROME_BROWSING_DATA_REMOVER_DELEGATE_H \ | ||
friend class BraveBrowsingDataRemoverDelegate; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure I am seeing why we need the friend
here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mkarolin For CreateTaskCompletionClosure.
|
||
#define BRAVE_SCOPED_ALLOW_BASE_SYNC_PRIMITIVES_H \ | ||
friend class ::BraveBrowsingDataRemoverDelegate; | ||
#include "../../../../base/threading/thread_restrictions.h" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: empty line after a multi-line #define
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
force pushed to add an empty line after define for this file and chromium_src/chrome/browser/browsing_data/chrome_browsing_data_remover_delegate.h
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
chromium_src
/patches
LGTM.
CI already done with all green, use Skip CI label now just to fix the nit above. |
50c6f40
to
0d78434
Compare
Verification FAILED on both
Found a crash when clearing the data as per brave/brave-browser#13625. |
base::ThreadPool::PostTaskAndReply( | ||
FROM_HERE, {base::TaskPriority::USER_VISIBLE, base::MayBlock()}, | ||
base::BindOnce(&BraveBrowsingDataRemoverDelegate::WaitForIPFSRepoGC, | ||
base::Unretained(this), base::Passed(&process)), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(sorry, just randomly came across this)
we really shouldn't use base::Unretained
like this, because this
can easily die before the task is started (especially given that most tasks posted around can be time consuming). Note, that CreateTaskCompletionClosure
binds a weak pointer.
Fortunately, in our case WaitForIPFSRepoGC
doesn't use that pointer at all, so we shouldn't crash. The most easy fix would be to just post a free function (i.e. not a member of BraveBrowsingDataRemoverDelegate
) - there are examples of WaitForExitWithTimeout
across the codebase
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also, probably we'd better explicitly mention TaskShutdownBehavior::CONTINUE_ON_SHUTDOWN
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you @iefremov, I'll open a follow-up PR for this.
Resolves brave/brave-browser#13302
This PR runs
ipfs repo gc
command when users clear browsing data via settings with cache type selected.One thing to note here (brave/brave-browser#13605) is that it will only be run if ipfs component is loaded (ex: user tries to launch local node during this browser session) and IPFS is not disabled, otherwise we won't have the executable path ready to use.
There are no new automatic tests added because we need to be able to run ipfs binary to have any meaningful tests, which is unlikely right now.
Submitter Checklist:
QA/Yes
orQA/No
;release-notes/include
orrelease-notes/exclude
;OS/...
) to the associated issuenpm run test -- brave_browser_tests
,npm run test -- brave_unit_tests
,npm run lint
,npm run gn_check
,npm run tslint
git rebase master
(if needed).Reviewer Checklist:
gn
After-merge Checklist:
changes has landed on.
Test Plan:
Pre-condition: IPFS resolve method is set to
Local node
in the settings. (If it's not, visit https://dweb.link/ipfs/QmbWqxBEKC3P8tqsKc98xmWNzrzDtRLMiMPL8wBuTGsMnR to trigger the infobar to enable local node support)/go-ipfs_v0.7.0_darwin-amd64 --api=/ip4/127.0.0.1/tcp/45001 repo stat
(Use port 45001 for development build, port 45002 on nightly, 45003 on dev, 45004 on beta, 45005 on release), to see the initial NumObjects.Example of command result:
Clear browsing data
setting, open the dialog and unselectCached images and files
.Cached images and files
.Clear browsing data
dialog again, chooseOn Exit
and make sureCached images and files
is selected./go-ipfs_v0.7.0_darwin-amd64 --api=/ip4/127.0.0.1/tcp/45001 repo stat
, should see the numbers are dropped from what you observed in step 8. (Might need to wait for like a minute for daemon to launch before running this command.)