Open Bug 1459974 Opened 6 years ago Updated 1 year ago

Sync StorageActivityService data on disk

Categories

(Core :: DOM: Core & HTML, enhancement, P2)

58 Branch
enhancement

Tracking

()

People

(Reporter: baku, Unassigned)

References

(Blocks 1 open bug)

Details

(Whiteboard: [storage-v2])

Attachments

(4 files, 5 obsolete files)

Currently StorageActivityService keeps the list of principals and the timestamps of pages doing writing operations via any Storage API. But this list is just in memory. This can be an issue if firefox is restarted and then, the user wants to clean the history of the last X hours/minutes.

This bug is about writing the list of activities on disk in order to have it back after a restart.
Johann, I think this bug is quite important. We should prioritize it. If you agree, I'm happy to work on it.
Flags: needinfo?(jhofmann)
Oh, right, that's a good point. Leaving this bug unattended for too long could be harmful, I definitely agree. (Though it's a bit unsatisfactory that we have to introduce another on-disk datastore for cleaning up data).

Thanks for catching that!
Blocks: storage-v2
Flags: needinfo?(jhofmann)
Whiteboard: [storage-v2]
Priority: -- → P2
Attached patch part 1 - Sync on disk (obsolete) — Splinter Review
Do you mind to review this set of patches?
The first patch is about creating a syncOnDisk method and use it when needed.
Assignee: nobody → amarchesini
Attachment #8974400 - Flags: review?(jhofmann)
Attached patch part 2 - Read from disk (obsolete) — Splinter Review
Here the reading when the profile directory becomes available
Attachment #8974401 - Flags: review?(jhofmann)
GetActiveOrigin must be async.
Attachment #8974402 - Flags: review?(jhofmann)
Attached patch part 4 - gtest (obsolete) — Splinter Review
Attachment #8974403 - Flags: review?(jhofmann)
Attached patch part 4 - gtest (obsolete) — Splinter Review
Attachment #8974403 - Attachment is obsolete: true
Attachment #8974403 - Flags: review?(jhofmann)
Attachment #8974419 - Flags: review?(jhofmann)
Comment on attachment 8974400 [details] [diff] [review]
part 1 - Sync on disk

Review of attachment 8974400 [details] [diff] [review]:
-----------------------------------------------------------------

Sorry for the big delay, was digging my way out of post-PTO backlog.

This looks pretty reasonable to me, but I don't feel comfortable reviewing big chunks of storage code. I'll forward to asuth.

::: dom/storage/StorageActivityService.cpp
@@ +361,5 @@
> +
> +void
> +StorageActivityService::ScheduleSyncOnDisk(const MutexAutoLock& aProofOfLock)
> +{
> +  // Already scheduleted.

typo: scheduled
Attachment #8974400 - Flags: review?(jhofmann)
Attachment #8974400 - Flags: review?(bugmail)
Attachment #8974400 - Flags: feedback+
Attachment #8974401 - Flags: review?(jhofmann) → review?(bugmail)
Comment on attachment 8974402 [details] [diff] [review]
part 3 - getActiveOrigins must be async

Review of attachment 8974402 [details] [diff] [review]:
-----------------------------------------------------------------

r=me on the browser parts

::: browser/base/content/test/sanitize/browser_sanitize-offlineData.js
@@ +85,5 @@
>    let endDate = Date.now() * 1000;
> +
> +  let principals = await new Promise(resolve => {
> +    sas.getActiveOrigins(endDate - oneHour, endDate, (status, data) => {
> +      if (status != Cr.NS_OK) {

For tests, shouldn't we rather fail here?

::: browser/modules/Sanitizer.jsm
@@ +394,5 @@
> +                resolve([]);
> +                return;
> +              }
> +
> +              let principals = data.QueryInterface(Ci.nsIArray);

Doesn't this fail ESLint because of shadowing? I kinda dislike the no-shadow rule :(

::: dom/interfaces/storage/nsIStorageActivityService.idl
@@ +23,5 @@
>  interface nsIStorageActivityService : nsISupports
>  {
> +  // This calls the callback |cb| when the array of nsIPrincipals, active
> +  // between |from| and |to| timestamps, is ready. Note activities older than 1
> +  // day are forgotten.  Activity details are not persisted, so this only

They are persisted now, right?
Attachment #8974402 - Flags: review?(jhofmann)
Attachment #8974402 - Flags: review?(bugmail)
Attachment #8974402 - Flags: review+
Comment on attachment 8974419 [details] [diff] [review]
part 4 - gtest

Review of attachment 8974419 [details] [diff] [review]:
-----------------------------------------------------------------

This looks all pretty good to me in general, but that's probably an indicator that I don't have enough experience with this code yet. :)

Thanks for the patches!
Attachment #8974419 - Flags: review?(jhofmann)
Attachment #8974419 - Flags: review?(bugmail)
Attachment #8974419 - Flags: review+
Where are we with this bug?
Flags: needinfo?(amarchesini)
Would be great if we can finish the review process and land this code. Who can review this code? It seems not so high priority...
Flags: needinfo?(amarchesini)
Component: DOM → DOM: Core & HTML

We're using storage activity service for cookie purging now, so we want to finish this.

Flags: needinfo?(jhofmann)

Are you going to review the remaining bit? Let me know if I can help here.

Assignee: amarchesini → tihuang

This patch implements the sync mechanism which syncs the storage
activities to the file 'activities.txt' in the profile folder. Any
update to the stoarge acgtivites will be synced to the file. And both
the file and the activites are protected by a mutex.

This patch implements the reading of the activites file. The reading
will happen after the profile has been fully loaded.

Depends on D84148

We have to convert the nsIStorageActivityService.getActiveOrigins into
async since it might be called while the activity hasn't been loaded
yet.

Depends on D84149

Depends on D84150

Does this mean we can obsolete :baku's original 4 patches?

Flags: needinfo?(tihuang)
Attachment #8974400 - Attachment is obsolete: true
Attachment #8974400 - Flags: review?(bugmail)
Attachment #8974401 - Attachment is obsolete: true
Attachment #8974401 - Flags: review?(bugmail)
Attachment #8974402 - Attachment is obsolete: true
Attachment #8974402 - Flags: review?(bugmail)
Comment on attachment 8974419 [details] [diff] [review]
part 4 - gtest

Yes, we can. Basically, I rebased his patches and put them on phabricator.
Attachment #8974419 - Attachment is obsolete: true
Flags: needinfo?(tihuang)
Attachment #8974419 - Flags: review?(bugmail)

Tim, are you still working on this? Do you want me to take it up instead if you're busy (thanks for rebasing those patches)?

Flags: needinfo?(jhofmann) → needinfo?(tihuang)

I am not working on this. It would be good if you can take it. Thanks.

Assignee: tihuang → jhofmann
Flags: needinfo?(tihuang)

Time to accept that I won't get to this in the near future :|

Assignee: jhofmann → nobody
Severity: normal → S3
Assignee: nobody → tihuang
Status: NEW → ASSIGNED

(Resetting the assignee that I believe was changed by the phabricator automation because :jstutte updated the review group from dom-workers-and-storage to dom-storage. I believe comment 22 accurately and then comment 23 reflect this.)

Assignee: tihuang → nobody
Status: ASSIGNED → NEW
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: