Closed Bug 1627022 Opened 4 years ago Closed 4 years ago

Clear about:home cache when appropriate when doing sanitization

Categories

(Firefox :: New Tab Page, task, P3)

task

Tracking

()

RESOLVED FIXED
Firefox 80
Tracking Status
firefox80 --- fixed

People

(Reporter: mconley, Assigned: mconley)

References

(Blocks 1 open bug)

Details

Attachments

(2 files)

The about:home cache contains information about user history and activity in the Highlights section. We should make sure to clear that from the disk when appropriate inside of Sanitizer.jsm.

Flags: needinfo?(sdowne)
Priority: -- → P3

Hey Mike, if there was an action in https://searchfox.org/mozilla-central/source/browser/components/newtab/common/Actions.jsm for clearing cache, that newtab feeds could listen to, and use to clear their cache. Would Sanitizer.jsm have what it needs to trigger that action?

Or is it more complex than that?

Flags: needinfo?(sdowne)

(In reply to Scott [:thecount] Downe from comment #1)

Sorry, this question dropped off my radar. I don't think the feeds need to know this - to clear the cache, AboutHomeStartupCache.clearCache in BrowserGlue.jsm needs to be called. I suspect Sanitizer will have to call that directly, or AboutHomeStartupCache will need to listen to some observer notification to know when to do it.

Hey ewright, I know you've recently done work around cookie cleanup... are you familiar at all with Sanitizer.jsm?

What I want to do here is make sure that the about:home startup cache gets cleared when the user has indicated that there's some past state (history, cookies, cache, etc) that they want to clear. Since about:home can contain a composite of past state (history, bookmarks, screenshots, etc), it probably makes sense to be fairly aggressive about clearing the cache any time sanitization occurs. Does that make sense? And if so, do you think Sanitizer.jsm should call AboutHomeStartupCache.clearCache directly, or should there be some indirection via observer notifications or something?

Flags: needinfo?(ewright)

That all sounds reasonable to me, I would probably choose to clear the cache directly, though I wouldn't consider myself an expert on Sanitizer.jsm, so there may be some reasons not to.

Flags: needinfo?(ewright)
Assignee: nobody → mconley
Status: NEW → ASSIGNED
Flags: needinfo?(amarchesini)

I don't understand why we want to touch nsIClearDataService and add a new cleaner for about:home. Can you tell me more?
Can we simply use existing cleaers and call: Services.clearData.deleteDataFromPincipal(the_about_home_principal) ?
In particular, why https://phabricator.services.mozilla.com/D82091 fails without the first patch?

Flags: needinfo?(amarchesini) → needinfo?(mconley)

(In reply to Andrea Marchesini [:baku] from comment #9)

In particular, why https://phabricator.services.mozilla.com/D82091 fails without the first patch?

It fails because clearing the downloads, places or history data doesn't clear out the HTTP cache, which is where the about:home startup cache lives.

I don't understand why we want to touch nsIClearDataService and add a new cleaner for about:home. Can you tell me more?
Can we simply use existing cleaers and call: Services.clearData.deleteDataFromPincipal(the_about_home_principal) ?

We could do this - we could update the DownloadsCleaner, HistoryCleaner and SessionHistoryCleaner to also clear the about:home HTTP cache entry when they clear. My only concern with this is:

  1. We're distributing the responsibility of clearing the about:home startup cache over several cleaners. Suppose in the future that the about:home document is composed of something new that we want to clear... we'll have to remember to add the about:home clearing to that cleaner as well. I suspect that's easier to forget if there isn't a dedicated cleaner, but that's conjecture. As it spreads out the responsibility for clearing the about:home startup cache, it also can spread out things like comments / inline documentation to make it clearer what's going on. The comment at line 1112 in ClearDataService.jsm - where would that live if cleaning was spread over multiple cleaners?
  2. All of the pre-existing cleaners apply to and work on mobile. The about:home startup cache is Desktop-only. It seems simpler to condition the running of the cleaner on the platform when it's separate, and not individually within several cleaners.

This seemed the simplest and most "encapsulated" solution, but to be honest, I'm willing to acquiesce to the folks who are more likely to work on / maintain this code. If you think it makes more sense to spread out cleaning across the DownloadsCleaner, HistoryCleaner and SessionHistoryCleaner, I can do that - just say the word.

Flags: needinfo?(mconley) → needinfo?(amarchesini)
  1. We're distributing the responsibility of clearing the about:home startup cache over several cleaners. Suppose in the future that the about:home document is composed of something new that we want to clear... we'll have to remember to add the about:home clearing to that cleaner as well. I suspect that's easier to forget if there isn't a dedicated cleaner, but that's conjecture.

we have a similar issue with forget-about-site. In order to do the "right" thing we added a special flag here:
https://searchfox.org/mozilla-central/rev/7ec7ee4a9bde171ba195ab46ed6077e4baaef34d/toolkit/components/cleardata/nsIClearDataService.idl#251-256

we can add: CLEAR_ABOUTHOME = CLEAR_HISTORY | CLER_DOWNLOAD...;
and then you call: Services.clearData.deleteDataFromPincipal(the_about_home_principal, CLEAR_ABOUT_HOME);

  1. All of the pre-existing cleaners apply to and work on mobile. The about:home startup cache is Desktop-only. It seems simpler to condition the running of the cleaner on the platform when it's separate, and not individually within several cleaners.

You still need to call the cleanup in the sanitizer.jsm. Right? Can we add the if(desktop){}-stmt there?

Flags: needinfo?(amarchesini)
Attachment #9161067 - Attachment description: Bug 1627022 - Add a new cleaner that sanitizes the about:home startup cache when appropriate. r?johannh! → Bug 1627022 - Add a new cleaner that sanitizes the about:home startup cache when appropriate. r?baku!
Flags: needinfo?(amarchesini)
Pushed by mconley@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/d5510a39f3ed
Add a new cleaner that sanitizes the about:home startup cache when appropriate. r=baku
https://hg.mozilla.org/integration/autoland/rev/e8a1d0ac7b50
Add a test that makes sure we clear the about:home startup cache when sanitizing. r=k88hudson
Status: ASSIGNED → RESOLVED
Closed: 4 years ago
Resolution: --- → FIXED
Target Milestone: --- → Firefox 80
Flags: needinfo?(amarchesini)
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: