New issue
Advanced search Search tips

Issue 757760 link

Starred by 3 users

Issue metadata

Status: Fixed
Owner:
Closed: Sep 25
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: All
Pri: 2
Type: Feature

Blocked on:
issue 741609
issue 826257

Blocking:
issue 679300



Sign in to add a comment

Add persistent storage to Background Fetch

Project Member Reported by joh...@chromium.org, Aug 22 2017

Issue description

The Background Fetch API needs to persistently store pending and active fetches so they can be resumed after a browser restart. It'll also need to temporarily store completed fetches that haven't yet been delivered to the Service Worker.

The current proposal involves storing these values in the Service Worker Database as UserData:
https://docs.google.com/document/d/1-WPPTP909Gb5PnaBOKP58tPVLw2Fq0Ln-u1EBviIBns/edit
 

Comment 1 by joh...@chromium.org, Aug 22 2017

Blocking: 679300
Project Member

Comment 2 by bugdroid1@chromium.org, Aug 25 2017

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/4018b9b80ad2b060c42eb7f0e4b4173e174c129c

commit 4018b9b80ad2b060c42eb7f0e4b4173e174c129c
Author: John Mellor <johnme@chromium.org>
Date: Fri Aug 25 16:36:27 2017

[Background Fetch] Start adding persistent storage of registrations

When features::kBackgroundFetchPersistence is enabled,
BackgroundFetchDataManager::CreateRegistration and DeleteRegistration
will now read and write from the Service Worker database, rather than
the temporary in-memory |registrations_| map.

This skeleton can be extended to add persistence for the rest of
Background Fetch.

Bug:  757760 
Change-Id: I8c41509df990fa7d8d69d65be99526673c9fb7a0
Reviewed-on: https://chromium-review.googlesource.com/625964
Commit-Queue: John Mellor <johnme@chromium.org>
Reviewed-by: Camille Lamy <clamy@chromium.org>
Reviewed-by: Mike West <mkwst@chromium.org>
Reviewed-by: Peter Beverloo <peter@chromium.org>
Cr-Commit-Position: refs/heads/master@{#497438}
[modify] https://crrev.com/4018b9b80ad2b060c42eb7f0e4b4173e174c129c/content/browser/background_fetch/background_fetch_context.cc
[modify] https://crrev.com/4018b9b80ad2b060c42eb7f0e4b4173e174c129c/content/browser/background_fetch/background_fetch_context.h
[modify] https://crrev.com/4018b9b80ad2b060c42eb7f0e4b4173e174c129c/content/browser/background_fetch/background_fetch_data_manager.cc
[modify] https://crrev.com/4018b9b80ad2b060c42eb7f0e4b4173e174c129c/content/browser/background_fetch/background_fetch_data_manager.h
[modify] https://crrev.com/4018b9b80ad2b060c42eb7f0e4b4173e174c129c/content/browser/background_fetch/background_fetch_data_manager_unittest.cc
[modify] https://crrev.com/4018b9b80ad2b060c42eb7f0e4b4173e174c129c/content/browser/background_fetch/background_fetch_event_dispatcher.cc
[modify] https://crrev.com/4018b9b80ad2b060c42eb7f0e4b4173e174c129c/content/browser/background_fetch/background_fetch_event_dispatcher.h
[modify] https://crrev.com/4018b9b80ad2b060c42eb7f0e4b4173e174c129c/content/browser/background_fetch/background_fetch_job_controller_unittest.cc
[modify] https://crrev.com/4018b9b80ad2b060c42eb7f0e4b4173e174c129c/content/public/common/content_switches.cc
[modify] https://crrev.com/4018b9b80ad2b060c42eb7f0e4b4173e174c129c/content/public/common/content_switches.h
[modify] https://crrev.com/4018b9b80ad2b060c42eb7f0e4b4173e174c129c/third_party/WebKit/Source/modules/background_fetch/BackgroundFetchManager.cpp
[modify] https://crrev.com/4018b9b80ad2b060c42eb7f0e4b4173e174c129c/third_party/WebKit/Source/modules/background_fetch/BackgroundFetchRegistration.cpp
[modify] https://crrev.com/4018b9b80ad2b060c42eb7f0e4b4173e174c129c/third_party/WebKit/Source/modules/background_fetch/BackgroundFetchedEvent.cpp
[modify] https://crrev.com/4018b9b80ad2b060c42eb7f0e4b4173e174c129c/third_party/WebKit/public/platform/modules/background_fetch/background_fetch.mojom

Project Member

Comment 3 by bugdroid1@chromium.org, Sep 4 2017

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/6f60c9967a9f58359fc55c87de91a8dbeecaf691

commit 6f60c9967a9f58359fc55c87de91a8dbeecaf691
Author: John Mellor <johnme@chromium.org>
Date: Mon Sep 04 16:31:40 2017

[Background Fetch] Start persisting requests

Starts persisting individual requests that are part of a Background
Fetch registration (still behind kEnableBackgroundFetchPersistence).

Adds |ClearRegistrationUserDataByKeyPrefixes| functionality to the
Service Worker database's UserData storage, to allow atomically deleting
UserData keys for one or more key prefixes.

Depends on: https://chromium-review.googlesource.com/625964

Bug:  757760 
Change-Id: Ic5b13ac5d0da747ca071c303929b1415526442dc
Reviewed-on: https://chromium-review.googlesource.com/641751
Commit-Queue: John Mellor <johnme@chromium.org>
Reviewed-by: Matt Falkenhagen <falken@chromium.org>
Reviewed-by: Hiroki Nakagawa <nhiroki@chromium.org>
Reviewed-by: Peter Beverloo <peter@chromium.org>
Cr-Commit-Position: refs/heads/master@{#499510}
[modify] https://crrev.com/6f60c9967a9f58359fc55c87de91a8dbeecaf691/content/browser/background_fetch/background_fetch_data_manager.cc
[modify] https://crrev.com/6f60c9967a9f58359fc55c87de91a8dbeecaf691/content/browser/background_fetch/background_fetch_data_manager_unittest.cc
[modify] https://crrev.com/6f60c9967a9f58359fc55c87de91a8dbeecaf691/content/browser/service_worker/service_worker_context_wrapper.cc
[modify] https://crrev.com/6f60c9967a9f58359fc55c87de91a8dbeecaf691/content/browser/service_worker/service_worker_context_wrapper.h
[modify] https://crrev.com/6f60c9967a9f58359fc55c87de91a8dbeecaf691/content/browser/service_worker/service_worker_database.cc
[modify] https://crrev.com/6f60c9967a9f58359fc55c87de91a8dbeecaf691/content/browser/service_worker/service_worker_database.h
[modify] https://crrev.com/6f60c9967a9f58359fc55c87de91a8dbeecaf691/content/browser/service_worker/service_worker_database_unittest.cc
[modify] https://crrev.com/6f60c9967a9f58359fc55c87de91a8dbeecaf691/content/browser/service_worker/service_worker_storage.cc
[modify] https://crrev.com/6f60c9967a9f58359fc55c87de91a8dbeecaf691/content/browser/service_worker/service_worker_storage.h
[modify] https://crrev.com/6f60c9967a9f58359fc55c87de91a8dbeecaf691/content/browser/service_worker/service_worker_storage_unittest.cc

Project Member

Comment 4 by bugdroid1@chromium.org, Sep 6 2017

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/e8df348094bf23fcebe36e1b3e5af0e146356499

commit e8df348094bf23fcebe36e1b3e5af0e146356499
Author: John Mellor <johnme@chromium.org>
Date: Wed Sep 06 19:00:58 2017

[Background Fetch] Persist pending request keys

Marks pending requests stored in the Service Worker UserData DB with a
special "bgfetch_pending_request_" key. Unlike the other keys stored for
Background Fetch, all of which are prefixed with the registration_id,
these keys are prefixed with the registration creation timestamp, which
will allow efficiently querying the Service Worker DB for only the
oldest (highest priority in FIFO order) pending requests (querying will
be implemented in a subsequent patch).

A protobuf file is also created, which will be used for serializing
and deserializing the values stored to the Service Worker DB (whose
UserData feature only accepts std::strings).

Bug:  757760 
Change-Id: I0b07343f4ad8365e9480540d5415f0eaf290b7c5
Reviewed-on: https://chromium-review.googlesource.com/649607
Commit-Queue: John Mellor <johnme@chromium.org>
Reviewed-by: Peter Beverloo <peter@chromium.org>
Reviewed-by: Avi Drissman <avi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#500027}
[modify] https://crrev.com/e8df348094bf23fcebe36e1b3e5af0e146356499/content/browser/BUILD.gn
[add] https://crrev.com/e8df348094bf23fcebe36e1b3e5af0e146356499/content/browser/background_fetch/BUILD.gn
[add] https://crrev.com/e8df348094bf23fcebe36e1b3e5af0e146356499/content/browser/background_fetch/background_fetch.proto
[modify] https://crrev.com/e8df348094bf23fcebe36e1b3e5af0e146356499/content/browser/background_fetch/background_fetch_data_manager.cc
[modify] https://crrev.com/e8df348094bf23fcebe36e1b3e5af0e146356499/content/browser/background_fetch/background_fetch_data_manager.h
[modify] https://crrev.com/e8df348094bf23fcebe36e1b3e5af0e146356499/content/browser/background_fetch/background_fetch_data_manager_unittest.cc

Comment 5 by joh...@chromium.org, Sep 15 2017

Blockedon: 741609
Project Member

Comment 6 by bugdroid1@chromium.org, Sep 18 2017

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/4119fed53216c3cd573d35ef8f7cb22744f554b1

commit 4119fed53216c3cd573d35ef8f7cb22744f554b1
Author: John Mellor <johnme@chromium.org>
Date: Mon Sep 18 20:20:53 2017

[Background Fetch] Remove assumptions that all registrations are loaded

Currently all Background Fetch registrations have a corresponding
instance of JobController stored in RAM within the
BackgroundFetchContext's active_fetches_ map.

This will stop being true once we move to persistent storage and only
load Background Fetch registrations into RAM when strictly necessary.

This patch removes many of the usages of the active_fetches_ map,
specifically those used to implement:
- BackgroundFetchServiceImpl::UpdateUI
- BackgroundFetchServiceImpl::GetRegistration
- BackgroundFetchServiceImpl::GetIds

For UpdateUI, it makes the DataManager the single source of truth, and
lets the JobController listen for changes to the UI data. This prevents
the race conditions that would occur if UpdateUI were called directly on
the JobController, then asynchronously written to the DataManager, as
with that approach a new JobController might be initialized in between
using the stale UI data from the DataManager, then never updated.

The remaining usages of active_fetches_ (Abort, DeleteRegistration,
CreateController, and DidCompleteJob) will be addressed in a follow-up.

Bug:  757760 
Change-Id: I0eef1900c53291cf4b73b34a169ec6d365297dd4
Reviewed-on: https://chromium-review.googlesource.com/668541
Reviewed-by: Mike West <mkwst@chromium.org>
Reviewed-by: Peter Beverloo <peter@chromium.org>
Reviewed-by: Dan Elphick <delphick@chromium.org>
Commit-Queue: John Mellor <johnme@chromium.org>
Cr-Commit-Position: refs/heads/master@{#502658}
[modify] https://crrev.com/4119fed53216c3cd573d35ef8f7cb22744f554b1/content/browser/background_fetch/background_fetch_context.cc
[modify] https://crrev.com/4119fed53216c3cd573d35ef8f7cb22744f554b1/content/browser/background_fetch/background_fetch_context.h
[modify] https://crrev.com/4119fed53216c3cd573d35ef8f7cb22744f554b1/content/browser/background_fetch/background_fetch_data_manager.cc
[modify] https://crrev.com/4119fed53216c3cd573d35ef8f7cb22744f554b1/content/browser/background_fetch/background_fetch_data_manager.h
[modify] https://crrev.com/4119fed53216c3cd573d35ef8f7cb22744f554b1/content/browser/background_fetch/background_fetch_job_controller.cc
[modify] https://crrev.com/4119fed53216c3cd573d35ef8f7cb22744f554b1/content/browser/background_fetch/background_fetch_job_controller.h
[modify] https://crrev.com/4119fed53216c3cd573d35ef8f7cb22744f554b1/content/browser/background_fetch/background_fetch_service_impl.cc
[modify] https://crrev.com/4119fed53216c3cd573d35ef8f7cb22744f554b1/content/browser/background_fetch/background_fetch_service_unittest.cc
[modify] https://crrev.com/4119fed53216c3cd573d35ef8f7cb22744f554b1/third_party/WebKit/public/platform/modules/background_fetch/background_fetch.mojom

Project Member

Comment 7 by bugdroid1@chromium.org, Oct 7 2017

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/d5e912d98b0eaa553d4e4c3f4d02ad52c157f1c8

commit d5e912d98b0eaa553d4e4c3f4d02ad52c157f1c8
Author: John Mellor <johnme@chromium.org>
Date: Sat Oct 07 17:55:34 2017

[Background Fetch] Introduce |unique_id| to distinguish registrations.

Developers pass in an DOMString "id" when creating or getting a
Background Fetch registration, henceforth referred to as |developer_id|.

Unfortunately, these |developer_id|s can't easily be relied on as
primary keys, since it's possible for JS to abort a
BackgroundFetchRegistration (or wait for it to complete) then create
another one with the same |developer_id|, whilst holding onto a
reference to the previous BackgroundFetchRegistration (or ActiveFetches
or SettledFetches) objects.

The methods on all of these objects must continue to work, i.e. stale
data must not be deleted until the last object that refers to it is
garbage collected, and aborting an old BackgroundFetchRegistration must
not abort a newer one with the same |developer_id|, etc.

So instead, this patch generates a globally unique |unique_id| string
for every Background Fetch registration, and uses that as our primary
key throughout the Background Fetch code (from the Blink
BackgroundFetchRegistration objects which internally store their
|unique_id| to disambiguate stale vs active ones, through the persistent
storage layer, all the way to the Delegate that talks to the
DownloadService and will eventually group notifications according to
their |unique_id|).

This will ultimately make the code a lot simpler, as consistently using
these |unique_id|s also removes various race conditions between
Background Fetch registrations completing/aborting and new ones being
created with the same |developer_id|.

(And if we ever moved to global storage instead of or in addition to
per-ServiceWorkerRegistration storage in the SWDB, |unique_id|s would
have the added benefit of being globally unique, so we wouldn't need to
concatenate them with the profile ID and service_worker_registration_id
in order to use them as keys in a global map).

Bug:  757760 
Change-Id: I33ddf6f42fcc04de3cfcf8e60c286b6072182274
Reviewed-on: https://chromium-review.googlesource.com/693099
Commit-Queue: John Mellor <johnme@chromium.org>
Reviewed-by: Matt Falkenhagen <falken@chromium.org>
Reviewed-by: Avi Drissman <avi@chromium.org>
Reviewed-by: Chris Palmer <palmer@chromium.org>
Reviewed-by: Peter Beverloo <peter@chromium.org>
Cr-Commit-Position: refs/heads/master@{#507299}
[modify] https://crrev.com/d5e912d98b0eaa553d4e4c3f4d02ad52c157f1c8/content/browser/background_fetch/background_fetch_context.cc
[modify] https://crrev.com/d5e912d98b0eaa553d4e4c3f4d02ad52c157f1c8/content/browser/background_fetch/background_fetch_context.h
[modify] https://crrev.com/d5e912d98b0eaa553d4e4c3f4d02ad52c157f1c8/content/browser/background_fetch/background_fetch_data_manager.cc
[modify] https://crrev.com/d5e912d98b0eaa553d4e4c3f4d02ad52c157f1c8/content/browser/background_fetch/background_fetch_data_manager.h
[modify] https://crrev.com/d5e912d98b0eaa553d4e4c3f4d02ad52c157f1c8/content/browser/background_fetch/background_fetch_data_manager_unittest.cc
[modify] https://crrev.com/d5e912d98b0eaa553d4e4c3f4d02ad52c157f1c8/content/browser/background_fetch/background_fetch_embedded_worker_test_helper.cc
[modify] https://crrev.com/d5e912d98b0eaa553d4e4c3f4d02ad52c157f1c8/content/browser/background_fetch/background_fetch_embedded_worker_test_helper.h
[modify] https://crrev.com/d5e912d98b0eaa553d4e4c3f4d02ad52c157f1c8/content/browser/background_fetch/background_fetch_event_dispatcher.cc
[modify] https://crrev.com/d5e912d98b0eaa553d4e4c3f4d02ad52c157f1c8/content/browser/background_fetch/background_fetch_event_dispatcher.h
[modify] https://crrev.com/d5e912d98b0eaa553d4e4c3f4d02ad52c157f1c8/content/browser/background_fetch/background_fetch_event_dispatcher_unittest.cc
[modify] https://crrev.com/d5e912d98b0eaa553d4e4c3f4d02ad52c157f1c8/content/browser/background_fetch/background_fetch_job_controller_unittest.cc
[modify] https://crrev.com/d5e912d98b0eaa553d4e4c3f4d02ad52c157f1c8/content/browser/background_fetch/background_fetch_registration_id.cc
[modify] https://crrev.com/d5e912d98b0eaa553d4e4c3f4d02ad52c157f1c8/content/browser/background_fetch/background_fetch_registration_id.h
[modify] https://crrev.com/d5e912d98b0eaa553d4e4c3f4d02ad52c157f1c8/content/browser/background_fetch/background_fetch_service_impl.cc
[modify] https://crrev.com/d5e912d98b0eaa553d4e4c3f4d02ad52c157f1c8/content/browser/background_fetch/background_fetch_service_impl.h
[modify] https://crrev.com/d5e912d98b0eaa553d4e4c3f4d02ad52c157f1c8/content/browser/background_fetch/background_fetch_service_unittest.cc
[modify] https://crrev.com/d5e912d98b0eaa553d4e4c3f4d02ad52c157f1c8/content/browser/background_fetch/background_fetch_test_base.cc
[modify] https://crrev.com/d5e912d98b0eaa553d4e4c3f4d02ad52c157f1c8/content/browser/background_fetch/background_fetch_test_base.h
[modify] https://crrev.com/d5e912d98b0eaa553d4e4c3f4d02ad52c157f1c8/content/browser/background_fetch/mock_background_fetch_delegate.cc
[modify] https://crrev.com/d5e912d98b0eaa553d4e4c3f4d02ad52c157f1c8/content/browser/bad_message.h
[modify] https://crrev.com/d5e912d98b0eaa553d4e4c3f4d02ad52c157f1c8/content/browser/service_worker/embedded_worker_test_helper.cc
[modify] https://crrev.com/d5e912d98b0eaa553d4e4c3f4d02ad52c157f1c8/content/browser/service_worker/embedded_worker_test_helper.h
[modify] https://crrev.com/d5e912d98b0eaa553d4e4c3f4d02ad52c157f1c8/content/common/background_fetch/background_fetch_struct_traits.cc
[modify] https://crrev.com/d5e912d98b0eaa553d4e4c3f4d02ad52c157f1c8/content/common/background_fetch/background_fetch_struct_traits.h
[modify] https://crrev.com/d5e912d98b0eaa553d4e4c3f4d02ad52c157f1c8/content/common/background_fetch/background_fetch_struct_traits_unittest.cc
[modify] https://crrev.com/d5e912d98b0eaa553d4e4c3f4d02ad52c157f1c8/content/common/background_fetch/background_fetch_types.h
[modify] https://crrev.com/d5e912d98b0eaa553d4e4c3f4d02ad52c157f1c8/content/common/service_worker/service_worker_event_dispatcher.mojom
[modify] https://crrev.com/d5e912d98b0eaa553d4e4c3f4d02ad52c157f1c8/content/renderer/service_worker/service_worker_context_client.cc
[modify] https://crrev.com/d5e912d98b0eaa553d4e4c3f4d02ad52c157f1c8/content/renderer/service_worker/service_worker_context_client.h
[modify] https://crrev.com/d5e912d98b0eaa553d4e4c3f4d02ad52c157f1c8/third_party/WebKit/Source/modules/background_fetch/BackgroundFetchBridge.cpp
[modify] https://crrev.com/d5e912d98b0eaa553d4e4c3f4d02ad52c157f1c8/third_party/WebKit/Source/modules/background_fetch/BackgroundFetchBridge.h
[modify] https://crrev.com/d5e912d98b0eaa553d4e4c3f4d02ad52c157f1c8/third_party/WebKit/Source/modules/background_fetch/BackgroundFetchEvent.cpp
[modify] https://crrev.com/d5e912d98b0eaa553d4e4c3f4d02ad52c157f1c8/third_party/WebKit/Source/modules/background_fetch/BackgroundFetchEvent.h
[modify] https://crrev.com/d5e912d98b0eaa553d4e4c3f4d02ad52c157f1c8/third_party/WebKit/Source/modules/background_fetch/BackgroundFetchManager.cpp
[modify] https://crrev.com/d5e912d98b0eaa553d4e4c3f4d02ad52c157f1c8/third_party/WebKit/Source/modules/background_fetch/BackgroundFetchManager.h
[modify] https://crrev.com/d5e912d98b0eaa553d4e4c3f4d02ad52c157f1c8/third_party/WebKit/Source/modules/background_fetch/BackgroundFetchRegistration.cpp
[modify] https://crrev.com/d5e912d98b0eaa553d4e4c3f4d02ad52c157f1c8/third_party/WebKit/Source/modules/background_fetch/BackgroundFetchRegistration.h
[modify] https://crrev.com/d5e912d98b0eaa553d4e4c3f4d02ad52c157f1c8/third_party/WebKit/Source/modules/background_fetch/BackgroundFetchTypeConverters.cpp
[modify] https://crrev.com/d5e912d98b0eaa553d4e4c3f4d02ad52c157f1c8/third_party/WebKit/Source/modules/background_fetch/BackgroundFetchedEvent.cpp
[modify] https://crrev.com/d5e912d98b0eaa553d4e4c3f4d02ad52c157f1c8/third_party/WebKit/Source/modules/background_fetch/BackgroundFetchedEvent.h
[modify] https://crrev.com/d5e912d98b0eaa553d4e4c3f4d02ad52c157f1c8/third_party/WebKit/Source/modules/serviceworkers/ServiceWorkerGlobalScopeProxy.cpp
[modify] https://crrev.com/d5e912d98b0eaa553d4e4c3f4d02ad52c157f1c8/third_party/WebKit/Source/modules/serviceworkers/ServiceWorkerGlobalScopeProxy.h
[modify] https://crrev.com/d5e912d98b0eaa553d4e4c3f4d02ad52c157f1c8/third_party/WebKit/public/platform/modules/background_fetch/background_fetch.mojom
[modify] https://crrev.com/d5e912d98b0eaa553d4e4c3f4d02ad52c157f1c8/third_party/WebKit/public/web/modules/serviceworker/WebServiceWorkerContextProxy.h
[modify] https://crrev.com/d5e912d98b0eaa553d4e4c3f4d02ad52c157f1c8/tools/metrics/histograms/enums.xml

Project Member

Comment 8 by bugdroid1@chromium.org, Oct 26 2017

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/553789d2cbfa5a45a3b1e138fa95f01bac4665ac

commit 553789d2cbfa5a45a3b1e138fa95f01bac4665ac
Author: Dan Elphick <delphick@chromium.org>
Date: Thu Oct 26 22:36:38 2017

[Background Fetch] Decouple storage lifetime from active jobs

(Taken over from johnme@'s
https://chromium-review.googlesource.com/c/chromium/src/+/723306).

Previously, 1) marking a registration as no longer active (i.e.
completed, failed or aborted), 2) deleting its JobController, and 3)
deleting the registration from the DataManager, were all tightly coupled
and happened simultaneously.

This made it impossible to support the spec's requirement that
registration data continue to be stored (and gettable) for as long as a
reference is kept to one or more JavaScript BackgroundFetchRegistration
objects, even if that registration has become inactive and another
registration has been made in the meantime with the same |developer_id|.

This patch decouples marking a registration as no longer active (aka.
marking for deletion) from both deleting the JobController and deleting
the registration data.

Now marking the registration as no longer active is always the first
step, and failure here is used to avoid race conditions between a) jobs
completing/failing, b) jobs being aborted by the user, and c) jobs being
aborted by the developer: now the first of these to mark it as inactive
wins.

Next, the JobController is deleted, but only once it's no longer
necessary, so for the completed/failed events we have to wait until the
event's waitUntil promise has been resolved.

Finally, there are two ways the registration data can be deleted.

1. Once JavaScript BackgroundFetchRegistration objects can no longer be
obtained for a registration, and all existing ones have been garbage
collected (we can count them since they each register a mojo observer
with the RegistrationNotifier), the registration data will be deleted.
(This doesn't work completely yet, but will be fixed in a follow-up
change).

2. After every browser restart, it is safe to delete registrations
marked for deletion, since JavaScript can no longer have references to
them. So the DataManager runs a Cleanup task with PostAfterStartupTask.

Bug:  757760 
Change-Id: I6cfe1d32c9405c79afbd826839479548a9878514
Reviewed-on: https://chromium-review.googlesource.com/735600
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Reviewed-by: Peter Beverloo <peter@chromium.org>
Commit-Queue: Dan Elphick <delphick@chromium.org>
Cr-Commit-Position: refs/heads/master@{#511990}
[modify] https://crrev.com/553789d2cbfa5a45a3b1e138fa95f01bac4665ac/content/browser/background_fetch/background_fetch.proto
[modify] https://crrev.com/553789d2cbfa5a45a3b1e138fa95f01bac4665ac/content/browser/background_fetch/background_fetch_context.cc
[modify] https://crrev.com/553789d2cbfa5a45a3b1e138fa95f01bac4665ac/content/browser/background_fetch/background_fetch_context.h
[modify] https://crrev.com/553789d2cbfa5a45a3b1e138fa95f01bac4665ac/content/browser/background_fetch/background_fetch_data_manager.cc
[modify] https://crrev.com/553789d2cbfa5a45a3b1e138fa95f01bac4665ac/content/browser/background_fetch/background_fetch_data_manager.h
[modify] https://crrev.com/553789d2cbfa5a45a3b1e138fa95f01bac4665ac/content/browser/background_fetch/background_fetch_data_manager_unittest.cc
[modify] https://crrev.com/553789d2cbfa5a45a3b1e138fa95f01bac4665ac/content/browser/background_fetch/background_fetch_delegate_proxy.cc
[modify] https://crrev.com/553789d2cbfa5a45a3b1e138fa95f01bac4665ac/content/browser/background_fetch/background_fetch_delegate_proxy.h
[modify] https://crrev.com/553789d2cbfa5a45a3b1e138fa95f01bac4665ac/content/browser/background_fetch/background_fetch_delegate_proxy_unittest.cc
[modify] https://crrev.com/553789d2cbfa5a45a3b1e138fa95f01bac4665ac/content/browser/background_fetch/background_fetch_job_controller.cc
[modify] https://crrev.com/553789d2cbfa5a45a3b1e138fa95f01bac4665ac/content/browser/background_fetch/background_fetch_job_controller.h
[modify] https://crrev.com/553789d2cbfa5a45a3b1e138fa95f01bac4665ac/content/browser/background_fetch/background_fetch_job_controller_unittest.cc
[modify] https://crrev.com/553789d2cbfa5a45a3b1e138fa95f01bac4665ac/content/browser/background_fetch/background_fetch_registration_notifier.cc
[modify] https://crrev.com/553789d2cbfa5a45a3b1e138fa95f01bac4665ac/content/browser/background_fetch/background_fetch_registration_notifier.h
[modify] https://crrev.com/553789d2cbfa5a45a3b1e138fa95f01bac4665ac/content/browser/background_fetch/background_fetch_registration_notifier_unittest.cc
[modify] https://crrev.com/553789d2cbfa5a45a3b1e138fa95f01bac4665ac/content/browser/background_fetch/background_fetch_service_impl.cc
[modify] https://crrev.com/553789d2cbfa5a45a3b1e138fa95f01bac4665ac/content/browser/background_fetch/background_fetch_service_impl.h
[modify] https://crrev.com/553789d2cbfa5a45a3b1e138fa95f01bac4665ac/content/browser/background_fetch/background_fetch_service_unittest.cc
[modify] https://crrev.com/553789d2cbfa5a45a3b1e138fa95f01bac4665ac/content/browser/background_fetch/background_fetch_test_base.cc
[modify] https://crrev.com/553789d2cbfa5a45a3b1e138fa95f01bac4665ac/third_party/WebKit/Source/modules/background_fetch/BackgroundFetchBridge.cpp
[modify] https://crrev.com/553789d2cbfa5a45a3b1e138fa95f01bac4665ac/third_party/WebKit/public/platform/modules/background_fetch/background_fetch.mojom

Owner: delph...@chromium.org
Project Member

Comment 10 by bugdroid1@chromium.org, Oct 30 2017

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/6c30676f695b8f7556e02d331bec91ac433404d8

commit 6c30676f695b8f7556e02d331bec91ac433404d8
Author: Dan Elphick <delphick@chromium.org>
Date: Mon Oct 30 12:26:53 2017

Allow asynchronous initialization of JobController

Add InitializeRequestStatus method to
BackgroundFetchDataManager::Controller, which should be called once the
current download status is loaded from the database, giving the total
number of downloads, the number completed so far and any GUIDs for
downloads that are still in progress.

Currently the method is still called almost immediately by the
DataManager in SetController, but this will change when the downloads
are properly persisted.

Bug:  757760 
Change-Id: I0b2382464b729bae842848dc9e6b212813f085f2
Reviewed-on: https://chromium-review.googlesource.com/743522
Reviewed-by: Peter Beverloo <peter@chromium.org>
Commit-Queue: Dan Elphick <delphick@chromium.org>
Cr-Commit-Position: refs/heads/master@{#512477}
[modify] https://crrev.com/6c30676f695b8f7556e02d331bec91ac433404d8/content/browser/background_fetch/background_fetch_context.cc
[modify] https://crrev.com/6c30676f695b8f7556e02d331bec91ac433404d8/content/browser/background_fetch/background_fetch_data_manager.cc
[modify] https://crrev.com/6c30676f695b8f7556e02d331bec91ac433404d8/content/browser/background_fetch/background_fetch_data_manager.h
[modify] https://crrev.com/6c30676f695b8f7556e02d331bec91ac433404d8/content/browser/background_fetch/background_fetch_job_controller.cc
[modify] https://crrev.com/6c30676f695b8f7556e02d331bec91ac433404d8/content/browser/background_fetch/background_fetch_job_controller.h
[modify] https://crrev.com/6c30676f695b8f7556e02d331bec91ac433404d8/content/browser/background_fetch/background_fetch_job_controller_unittest.cc

Project Member

Comment 11 by bugdroid1@chromium.org, Oct 30 2017

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/16fe31b0cd89d1072a87f68740e037255089046a

commit 16fe31b0cd89d1072a87f68740e037255089046a
Author: Dan Elphick <delphick@chromium.org>
Date: Mon Oct 30 14:18:45 2017

Move download GUID initialization into DataManager

Since active downloads need to be persisted across browser restarts and
the DownloadService will identify these downloads using the GUID, these
GUIDs must be stored in BackgroundFetchDataManager.

To that end, this CL generates the GUIDs in BackgroundFetchDataManager,
when a download moves from the pending queue to the active queue and
stores it BackgroundFetchRequestInfo. BackgroundFetchDelegateProxy will
now use this GUID rather than generating its own for each fresh
download.

Bug:  757760 
Change-Id: Iada6d803a47a5d75e0256f7f4e5edd18195606d5
Reviewed-on: https://chromium-review.googlesource.com/741718
Commit-Queue: Dan Elphick <delphick@chromium.org>
Reviewed-by: Peter Beverloo <peter@chromium.org>
Cr-Commit-Position: refs/heads/master@{#512489}
[modify] https://crrev.com/16fe31b0cd89d1072a87f68740e037255089046a/content/browser/background_fetch/background_fetch_data_manager.cc
[modify] https://crrev.com/16fe31b0cd89d1072a87f68740e037255089046a/content/browser/background_fetch/background_fetch_delegate_proxy.cc
[modify] https://crrev.com/16fe31b0cd89d1072a87f68740e037255089046a/content/browser/background_fetch/background_fetch_delegate_proxy_unittest.cc
[modify] https://crrev.com/16fe31b0cd89d1072a87f68740e037255089046a/content/browser/background_fetch/background_fetch_request_info.cc
[modify] https://crrev.com/16fe31b0cd89d1072a87f68740e037255089046a/content/browser/background_fetch/background_fetch_request_info.h

Project Member

Comment 12 by bugdroid1@chromium.org, Nov 2 2017

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/260f3f60d57dc82476e4f78a695e981f4cb007b8

commit 260f3f60d57dc82476e4f78a695e981f4cb007b8
Author: Dan Elphick <delphick@chromium.org>
Date: Thu Nov 02 15:21:41 2017

BackgroundFetch: Pull out DatabaseTask and subclasses

Move DatabaseTask and each of its subclasses into
content/browser/background_fetch/storage and put them in the
background_fetch namespace.

To prevent circular dependencies move
and rename it to BackgroundFetchDatabaseClient.

BackgroundFetchDataManager: :Controller out of BackgroundFetchDataManager
Change-Id: I4c1fb87f5ee41fb09d31c8354d3a57f0d90f5d26
Bug:  757760 
Reviewed-on: https://chromium-review.googlesource.com/746703
Reviewed-by: Avi Drissman <avi@chromium.org>
Reviewed-by: Peter Beverloo <peter@chromium.org>
Commit-Queue: Dan Elphick <delphick@chromium.org>
Cr-Commit-Position: refs/heads/master@{#513495}
[modify] https://crrev.com/260f3f60d57dc82476e4f78a695e981f4cb007b8/content/browser/BUILD.gn
[modify] https://crrev.com/260f3f60d57dc82476e4f78a695e981f4cb007b8/content/browser/background_fetch/background_fetch_data_manager.cc
[modify] https://crrev.com/260f3f60d57dc82476e4f78a695e981f4cb007b8/content/browser/background_fetch/background_fetch_data_manager.h
[modify] https://crrev.com/260f3f60d57dc82476e4f78a695e981f4cb007b8/content/browser/background_fetch/background_fetch_job_controller.cc
[modify] https://crrev.com/260f3f60d57dc82476e4f78a695e981f4cb007b8/content/browser/background_fetch/background_fetch_job_controller.h
[add] https://crrev.com/260f3f60d57dc82476e4f78a695e981f4cb007b8/content/browser/background_fetch/storage/README.md
[add] https://crrev.com/260f3f60d57dc82476e4f78a695e981f4cb007b8/content/browser/background_fetch/storage/cleanup_task.cc
[add] https://crrev.com/260f3f60d57dc82476e4f78a695e981f4cb007b8/content/browser/background_fetch/storage/cleanup_task.h
[add] https://crrev.com/260f3f60d57dc82476e4f78a695e981f4cb007b8/content/browser/background_fetch/storage/create_registration_task.cc
[add] https://crrev.com/260f3f60d57dc82476e4f78a695e981f4cb007b8/content/browser/background_fetch/storage/create_registration_task.h
[add] https://crrev.com/260f3f60d57dc82476e4f78a695e981f4cb007b8/content/browser/background_fetch/storage/database_helpers.cc
[add] https://crrev.com/260f3f60d57dc82476e4f78a695e981f4cb007b8/content/browser/background_fetch/storage/database_helpers.h
[add] https://crrev.com/260f3f60d57dc82476e4f78a695e981f4cb007b8/content/browser/background_fetch/storage/database_task.cc
[add] https://crrev.com/260f3f60d57dc82476e4f78a695e981f4cb007b8/content/browser/background_fetch/storage/database_task.h
[add] https://crrev.com/260f3f60d57dc82476e4f78a695e981f4cb007b8/content/browser/background_fetch/storage/delete_registration_task.cc
[add] https://crrev.com/260f3f60d57dc82476e4f78a695e981f4cb007b8/content/browser/background_fetch/storage/delete_registration_task.h
[add] https://crrev.com/260f3f60d57dc82476e4f78a695e981f4cb007b8/content/browser/background_fetch/storage/mark_registration_for_deletion_task.cc
[add] https://crrev.com/260f3f60d57dc82476e4f78a695e981f4cb007b8/content/browser/background_fetch/storage/mark_registration_for_deletion_task.h

Project Member

Comment 13 by bugdroid1@chromium.org, Nov 2 2017

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/5841079ecf34a4fef86b430d930496c29017626f

commit 5841079ecf34a4fef86b430d930496c29017626f
Author: Dan Elphick <delphick@chromium.org>
Date: Thu Nov 02 18:44:15 2017

Background Fetch: DataManager no longer aborts jobs

BackgroundFetchContext now aborts the jobs itself once
BackgroundFetchDataManager calls back to it.

This removes one method from BackgroundFetchDatabaseClient as part of a
long term goal to delete it completely and remove the tight coupling
between the DataManager and JobController.

Bug:  757760 
Change-Id: I9792d7d433ff14a74a9b55485fdfb94e9fca4288
Reviewed-on: https://chromium-review.googlesource.com/751505
Commit-Queue: Dan Elphick <delphick@chromium.org>
Commit-Queue: Peter Beverloo <peter@chromium.org>
Reviewed-by: Peter Beverloo <peter@chromium.org>
Cr-Commit-Position: refs/heads/master@{#513563}
[modify] https://crrev.com/5841079ecf34a4fef86b430d930496c29017626f/content/browser/background_fetch/background_fetch_context.cc
[modify] https://crrev.com/5841079ecf34a4fef86b430d930496c29017626f/content/browser/background_fetch/background_fetch_data_manager.cc
[modify] https://crrev.com/5841079ecf34a4fef86b430d930496c29017626f/content/browser/background_fetch/background_fetch_data_manager.h
[modify] https://crrev.com/5841079ecf34a4fef86b430d930496c29017626f/content/browser/background_fetch/background_fetch_data_manager_unittest.cc
[modify] https://crrev.com/5841079ecf34a4fef86b430d930496c29017626f/content/browser/background_fetch/background_fetch_job_controller.h
[modify] https://crrev.com/5841079ecf34a4fef86b430d930496c29017626f/content/browser/background_fetch/storage/mark_registration_for_deletion_task.cc
[modify] https://crrev.com/5841079ecf34a4fef86b430d930496c29017626f/content/browser/background_fetch/storage/mark_registration_for_deletion_task.h

Project Member

Comment 14 by bugdroid1@chromium.org, Nov 3 2017

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/bfd47f021b011a79fbbf034ea5790789f4b45278

commit bfd47f021b011a79fbbf034ea5790789f4b45278
Author: Dan Elphick <delphick@chromium.org>
Date: Fri Nov 03 15:43:34 2017

Update titles in JobController from BackgroundFetchContext

Previously BackgroundFetchService would reach into DataManager to
update the title for a job. The DataManager would then call into the
JobController via the DatabaseClient interface.

To reduce coupling:
* BackgroundFetchService now calls into the BackgroundFetchContext.
* The BFContext then calls into the DataManager to update the database
with the title change.
* And finally when the previous completes, the BFContext updates the
JobController itself.

Bug:  757760 
Change-Id: If393c2937107722b96a7b5d97f37c3eb897d5568
Reviewed-on: https://chromium-review.googlesource.com/753482
Commit-Queue: Dan Elphick <delphick@chromium.org>
Reviewed-by: Peter Beverloo <peter@chromium.org>
Reviewed-by: Anita Woodruff <awdf@chromium.org>
Cr-Commit-Position: refs/heads/master@{#513791}
[modify] https://crrev.com/bfd47f021b011a79fbbf034ea5790789f4b45278/content/browser/background_fetch/background_fetch_context.cc
[modify] https://crrev.com/bfd47f021b011a79fbbf034ea5790789f4b45278/content/browser/background_fetch/background_fetch_context.h
[modify] https://crrev.com/bfd47f021b011a79fbbf034ea5790789f4b45278/content/browser/background_fetch/background_fetch_data_manager.cc
[modify] https://crrev.com/bfd47f021b011a79fbbf034ea5790789f4b45278/content/browser/background_fetch/background_fetch_data_manager.h
[modify] https://crrev.com/bfd47f021b011a79fbbf034ea5790789f4b45278/content/browser/background_fetch/background_fetch_delegate_proxy.cc
[modify] https://crrev.com/bfd47f021b011a79fbbf034ea5790789f4b45278/content/browser/background_fetch/background_fetch_delegate_proxy.h
[modify] https://crrev.com/bfd47f021b011a79fbbf034ea5790789f4b45278/content/browser/background_fetch/background_fetch_job_controller.cc
[modify] https://crrev.com/bfd47f021b011a79fbbf034ea5790789f4b45278/content/browser/background_fetch/background_fetch_job_controller.h
[modify] https://crrev.com/bfd47f021b011a79fbbf034ea5790789f4b45278/content/browser/background_fetch/background_fetch_service_impl.cc

Project Member

Comment 15 by bugdroid1@chromium.org, Nov 6 2017

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/746a67f04cd1540a88ed42193910d2765df0721e

commit 746a67f04cd1540a88ed42193910d2765df0721e
Author: Dan Elphick <delphick@chromium.org>
Date: Mon Nov 06 14:57:07 2017

Further decouple BackgroundFetchJobController from BFDataManager

BackgroundFetchServiceImpl now performs GetRegistration tasks through
the BackgroundFetchContext rather than reaching into the
BackgroundFetchDataManager.

Remove the GetInProgressDownloadedBytes method from
BackgroundFetchDatabaseClient. Instead now BackgroundFetchDataManager
doesn't know anything about the size of in-flight downloads. The
BackgroundFetchContext retrieves the number of bytes in completed
downloads from the DataManager and adds that to the number of in-flight
downloaded bytes from the JobController.

Bug:  757760 
Change-Id: I79fc903c4cd316100d4123a6f9705057777b6e8b
Reviewed-on: https://chromium-review.googlesource.com/754604
Commit-Queue: Dan Elphick <delphick@chromium.org>
Reviewed-by: Anita Woodruff <awdf@chromium.org>
Cr-Commit-Position: refs/heads/master@{#514127}
[modify] https://crrev.com/746a67f04cd1540a88ed42193910d2765df0721e/content/browser/background_fetch/background_fetch_context.cc
[modify] https://crrev.com/746a67f04cd1540a88ed42193910d2765df0721e/content/browser/background_fetch/background_fetch_context.h
[modify] https://crrev.com/746a67f04cd1540a88ed42193910d2765df0721e/content/browser/background_fetch/background_fetch_data_manager.cc
[modify] https://crrev.com/746a67f04cd1540a88ed42193910d2765df0721e/content/browser/background_fetch/background_fetch_data_manager.h
[modify] https://crrev.com/746a67f04cd1540a88ed42193910d2765df0721e/content/browser/background_fetch/background_fetch_data_manager_unittest.cc
[modify] https://crrev.com/746a67f04cd1540a88ed42193910d2765df0721e/content/browser/background_fetch/background_fetch_job_controller.h
[modify] https://crrev.com/746a67f04cd1540a88ed42193910d2765df0721e/content/browser/background_fetch/background_fetch_job_controller_unittest.cc
[modify] https://crrev.com/746a67f04cd1540a88ed42193910d2765df0721e/content/browser/background_fetch/background_fetch_service_impl.cc
[modify] https://crrev.com/746a67f04cd1540a88ed42193910d2765df0721e/content/browser/background_fetch/storage/create_registration_task.cc
[modify] https://crrev.com/746a67f04cd1540a88ed42193910d2765df0721e/content/browser/background_fetch/storage/create_registration_task.h

Project Member

Comment 16 by bugdroid1@chromium.org, Nov 6 2017

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/e11715ada88b9e8d51e8c10dacf087fed95e9893

commit e11715ada88b9e8d51e8c10dacf087fed95e9893
Author: Dan Elphick <delphick@chromium.org>
Date: Mon Nov 06 15:59:49 2017

Revert function names in BackgroundFetchContext and others

Change the UpdateJobTitles back to UpdateUI back to match the names in
the .mojom and Web API.

The original CL is
https://chromium-review.googlesource.com/c/chromium/src/+/753482

Bug:  757760 
Change-Id: I1718c25747cf017c099907eb5ecf4cad1821b146
Reviewed-on: https://chromium-review.googlesource.com/753387
Commit-Queue: Dan Elphick <delphick@chromium.org>
Reviewed-by: Peter Beverloo <peter@chromium.org>
Cr-Commit-Position: refs/heads/master@{#514141}
[modify] https://crrev.com/e11715ada88b9e8d51e8c10dacf087fed95e9893/content/browser/background_fetch/background_fetch_context.cc
[modify] https://crrev.com/e11715ada88b9e8d51e8c10dacf087fed95e9893/content/browser/background_fetch/background_fetch_context.h
[modify] https://crrev.com/e11715ada88b9e8d51e8c10dacf087fed95e9893/content/browser/background_fetch/background_fetch_delegate_proxy.cc
[modify] https://crrev.com/e11715ada88b9e8d51e8c10dacf087fed95e9893/content/browser/background_fetch/background_fetch_delegate_proxy.h
[modify] https://crrev.com/e11715ada88b9e8d51e8c10dacf087fed95e9893/content/browser/background_fetch/background_fetch_job_controller.cc
[modify] https://crrev.com/e11715ada88b9e8d51e8c10dacf087fed95e9893/content/browser/background_fetch/background_fetch_job_controller.h
[modify] https://crrev.com/e11715ada88b9e8d51e8c10dacf087fed95e9893/content/browser/background_fetch/background_fetch_service_impl.cc

Project Member

Comment 17 by bugdroid1@chromium.org, Nov 7 2017

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/cad92f5491a589dbb436e0bafb2162a77fd9ee21

commit cad92f5491a589dbb436e0bafb2162a77fd9ee21
Author: Dan Elphick <delphick@chromium.org>
Date: Tue Nov 07 07:15:50 2017

Remove BackgroundFetchDatabaseClient interface

Remove the final method InitializeRequestStatus from the DatabaseClient
interface and instead call the method directly from the
BackgroundFetchContext. This requires adding a method to DataManager to
return the total number of fetches in the registration.

Bug:  757760 
Change-Id: I8bab10fa1862c2e7f152df33d77963a1942ed6c1
Reviewed-on: https://chromium-review.googlesource.com/755716
Reviewed-by: Peter Beverloo <peter@chromium.org>
Commit-Queue: Dan Elphick <delphick@chromium.org>
Cr-Commit-Position: refs/heads/master@{#514418}
[modify] https://crrev.com/cad92f5491a589dbb436e0bafb2162a77fd9ee21/content/browser/background_fetch/background_fetch_context.cc
[modify] https://crrev.com/cad92f5491a589dbb436e0bafb2162a77fd9ee21/content/browser/background_fetch/background_fetch_data_manager.cc
[modify] https://crrev.com/cad92f5491a589dbb436e0bafb2162a77fd9ee21/content/browser/background_fetch/background_fetch_data_manager.h
[modify] https://crrev.com/cad92f5491a589dbb436e0bafb2162a77fd9ee21/content/browser/background_fetch/background_fetch_job_controller.cc
[modify] https://crrev.com/cad92f5491a589dbb436e0bafb2162a77fd9ee21/content/browser/background_fetch/background_fetch_job_controller.h
[modify] https://crrev.com/cad92f5491a589dbb436e0bafb2162a77fd9ee21/content/browser/background_fetch/background_fetch_job_controller_unittest.cc
[modify] https://crrev.com/cad92f5491a589dbb436e0bafb2162a77fd9ee21/content/browser/background_fetch/storage/database_task.cc
[modify] https://crrev.com/cad92f5491a589dbb436e0bafb2162a77fd9ee21/content/browser/background_fetch/storage/database_task.h

Project Member

Comment 18 by bugdroid1@chromium.org, Nov 7 2017

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/d28d18aaff64af61bd0c22a25f33ffeb8685d7dd

commit d28d18aaff64af61bd0c22a25f33ffeb8685d7dd
Author: Dan Elphick <delphick@chromium.org>
Date: Tue Nov 07 14:26:37 2017

Factor out RequestManager from BackgroundFetchDataManager

RequestManager is a small interface containing all the methods that
JobController calls on DataManager. These methods are all to do with
getting requests off the queue and updating their status. This means
that BackgroundFetchJobController now has no dependency on DataManager.

Also removes the final usage of DataManager in
BackgroundFetchServiceImpl by adding the method to
BackgroundFetchContext instead. As a result the data_manager() getter
can be removed from BackgroundFetchContext.

DataManager is now only used directly by the Context class and the
Database tasks in storage.

TBR=avi@chromium.org

Bug:  757760 
Change-Id: I959ae0855fe2b9d8c5951f676252404f61aa123c
Reviewed-on: https://chromium-review.googlesource.com/756746
Commit-Queue: Dan Elphick <delphick@chromium.org>
Reviewed-by: Anita Woodruff <awdf@chromium.org>
Reviewed-by: Peter Beverloo <peter@chromium.org>
Cr-Commit-Position: refs/heads/master@{#514464}
[modify] https://crrev.com/d28d18aaff64af61bd0c22a25f33ffeb8685d7dd/content/browser/BUILD.gn
[modify] https://crrev.com/d28d18aaff64af61bd0c22a25f33ffeb8685d7dd/content/browser/background_fetch/background_fetch_context.cc
[modify] https://crrev.com/d28d18aaff64af61bd0c22a25f33ffeb8685d7dd/content/browser/background_fetch/background_fetch_context.h
[modify] https://crrev.com/d28d18aaff64af61bd0c22a25f33ffeb8685d7dd/content/browser/background_fetch/background_fetch_data_manager.cc
[modify] https://crrev.com/d28d18aaff64af61bd0c22a25f33ffeb8685d7dd/content/browser/background_fetch/background_fetch_data_manager.h
[modify] https://crrev.com/d28d18aaff64af61bd0c22a25f33ffeb8685d7dd/content/browser/background_fetch/background_fetch_job_controller.cc
[modify] https://crrev.com/d28d18aaff64af61bd0c22a25f33ffeb8685d7dd/content/browser/background_fetch/background_fetch_job_controller.h
[add] https://crrev.com/d28d18aaff64af61bd0c22a25f33ffeb8685d7dd/content/browser/background_fetch/background_fetch_request_manager.h
[modify] https://crrev.com/d28d18aaff64af61bd0c22a25f33ffeb8685d7dd/content/browser/background_fetch/background_fetch_service_impl.cc
[modify] https://crrev.com/d28d18aaff64af61bd0c22a25f33ffeb8685d7dd/content/browser/background_fetch/background_fetch_service_unittest.cc

Project Member

Comment 19 by bugdroid1@chromium.org, Nov 8 2017

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/7e9641fa23646607d3349d5386aceafefc805d6d

commit 7e9641fa23646607d3349d5386aceafefc805d6d
Author: Dan Elphick <delphick@chromium.org>
Date: Wed Nov 08 10:26:26 2017

Simplify BackgroundFetchDelegateProxy::Controller

Remove redundant guid parameter from the
BackgroundFetchDelegateProxy::Controller interface since it already
exists in the BackgroundFetchRequestInfo object.

Also tighten up GUID check in BackgroundFetchServiceImpl to ensure that
the GUID is a valid output string.

R=peter@chromium.org

Bug:  757760 
Change-Id: I8e07f9bfe2732e3ee0631f5a617dfd0084571e63
Reviewed-on: https://chromium-review.googlesource.com/757142
Commit-Queue: Dan Elphick <delphick@chromium.org>
Reviewed-by: Peter Beverloo <peter@chromium.org>
Cr-Commit-Position: refs/heads/master@{#514792}
[modify] https://crrev.com/7e9641fa23646607d3349d5386aceafefc805d6d/content/browser/background_fetch/background_fetch_delegate_proxy.cc
[modify] https://crrev.com/7e9641fa23646607d3349d5386aceafefc805d6d/content/browser/background_fetch/background_fetch_delegate_proxy.h
[modify] https://crrev.com/7e9641fa23646607d3349d5386aceafefc805d6d/content/browser/background_fetch/background_fetch_delegate_proxy_unittest.cc
[modify] https://crrev.com/7e9641fa23646607d3349d5386aceafefc805d6d/content/browser/background_fetch/background_fetch_job_controller.cc
[modify] https://crrev.com/7e9641fa23646607d3349d5386aceafefc805d6d/content/browser/background_fetch/background_fetch_job_controller.h
[modify] https://crrev.com/7e9641fa23646607d3349d5386aceafefc805d6d/content/browser/background_fetch/background_fetch_service_impl.cc

Project Member

Comment 20 by bugdroid1@chromium.org, Nov 10 2017

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/34c5fc9754cca3eedd4c2d576e4c85742fab2713

commit 34c5fc9754cca3eedd4c2d576e4c85742fab2713
Author: Dan Elphick <delphick@chromium.org>
Date: Fri Nov 10 07:45:16 2017

Make GetRegistration work with persistent storage

Add a new GetRegistrationTask to be used by BackgroundFetchDataManager
when the persistent storage flag is enabled.

Adds the origin to the proto stored in the database and check it
matches when retrieving a registration, otherwise trigger a storage
error.

Make BackgroundFetchDataManagerTest parameterized by persistence, which
turns on the command line flag. Now all tests run (and pass) with or
without persistence although the Cleanup test doesn't test much yet
since there's no way yet to interact with a non-active fetch.

Bug:  757760 
Change-Id: I3aa29e17f9112f282f5672366e52522e549f32d0
Reviewed-on: https://chromium-review.googlesource.com/758762
Reviewed-by: Avi Drissman <avi@chromium.org>
Reviewed-by: Peter Beverloo <peter@chromium.org>
Commit-Queue: Dan Elphick <delphick@chromium.org>
Cr-Commit-Position: refs/heads/master@{#515498}
[modify] https://crrev.com/34c5fc9754cca3eedd4c2d576e4c85742fab2713/content/browser/BUILD.gn
[modify] https://crrev.com/34c5fc9754cca3eedd4c2d576e4c85742fab2713/content/browser/background_fetch/background_fetch.proto
[modify] https://crrev.com/34c5fc9754cca3eedd4c2d576e4c85742fab2713/content/browser/background_fetch/background_fetch_data_manager.cc
[modify] https://crrev.com/34c5fc9754cca3eedd4c2d576e4c85742fab2713/content/browser/background_fetch/background_fetch_data_manager_unittest.cc
[modify] https://crrev.com/34c5fc9754cca3eedd4c2d576e4c85742fab2713/content/browser/background_fetch/storage/create_registration_task.cc
[modify] https://crrev.com/34c5fc9754cca3eedd4c2d576e4c85742fab2713/content/browser/background_fetch/storage/create_registration_task.h
[add] https://crrev.com/34c5fc9754cca3eedd4c2d576e4c85742fab2713/content/browser/background_fetch/storage/get_registration_task.cc
[add] https://crrev.com/34c5fc9754cca3eedd4c2d576e4c85742fab2713/content/browser/background_fetch/storage/get_registration_task.h

Project Member

Comment 21 by bugdroid1@chromium.org, Nov 14 2017

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/a26d0f7b02d91f6770e682c96b8857c4c2b2839c

commit a26d0f7b02d91f6770e682c96b8857c4c2b2839c
Author: Dan Elphick <delphick@chromium.org>
Date: Tue Nov 14 13:31:59 2017

Background Fetch: Add persistence to GetDeveloperIds

Add a new DatabaseTask, GetDeveloperIdsTask which reads the
developer_ids from the database.

To avoid multiple database look ups or hacks like encoding the key into
the data, add a new method to ServiceWorkerContextWrapper,
GetRegistrationUserKeysAndDataByKeyPrefix, that returns a map of the
keys and their values.

Also fix method description for ReadUserDataByKeyPrefix to say it
returns STATUS_OK if no records are found in an otherwise successful
read since that's what the code does. Add a unit test for
ReadUserDataByKeyPrefix that verifies that the above comment change is
correct.

Bug:  757760 
Change-Id: I40baa5e1a9997cd2c7ed7b7f0094156b515127cd
Reviewed-on: https://chromium-review.googlesource.com/764127
Commit-Queue: Dan Elphick <delphick@chromium.org>
Reviewed-by: Matt Falkenhagen <falken@chromium.org>
Reviewed-by: Hiroki Nakagawa <nhiroki@chromium.org>
Reviewed-by: Avi Drissman <avi@chromium.org>
Reviewed-by: Peter Beverloo <peter@chromium.org>
Cr-Commit-Position: refs/heads/master@{#516287}
[modify] https://crrev.com/a26d0f7b02d91f6770e682c96b8857c4c2b2839c/content/browser/BUILD.gn
[modify] https://crrev.com/a26d0f7b02d91f6770e682c96b8857c4c2b2839c/content/browser/background_fetch/background_fetch_data_manager.cc
[modify] https://crrev.com/a26d0f7b02d91f6770e682c96b8857c4c2b2839c/content/browser/background_fetch/background_fetch_data_manager_unittest.cc
[add] https://crrev.com/a26d0f7b02d91f6770e682c96b8857c4c2b2839c/content/browser/background_fetch/storage/get_developer_ids_task.cc
[add] https://crrev.com/a26d0f7b02d91f6770e682c96b8857c4c2b2839c/content/browser/background_fetch/storage/get_developer_ids_task.h
[modify] https://crrev.com/a26d0f7b02d91f6770e682c96b8857c4c2b2839c/content/browser/service_worker/service_worker_context_wrapper.cc
[modify] https://crrev.com/a26d0f7b02d91f6770e682c96b8857c4c2b2839c/content/browser/service_worker/service_worker_context_wrapper.h
[modify] https://crrev.com/a26d0f7b02d91f6770e682c96b8857c4c2b2839c/content/browser/service_worker/service_worker_database.cc
[modify] https://crrev.com/a26d0f7b02d91f6770e682c96b8857c4c2b2839c/content/browser/service_worker/service_worker_database.h
[modify] https://crrev.com/a26d0f7b02d91f6770e682c96b8857c4c2b2839c/content/browser/service_worker/service_worker_database_unittest.cc
[modify] https://crrev.com/a26d0f7b02d91f6770e682c96b8857c4c2b2839c/content/browser/service_worker/service_worker_storage.cc
[modify] https://crrev.com/a26d0f7b02d91f6770e682c96b8857c4c2b2839c/content/browser/service_worker/service_worker_storage.h

Project Member

Comment 22 by bugdroid1@chromium.org, Jan 4 2018

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/14655855f937778a1f28b203ebeafb88102a86e2

commit 14655855f937778a1f28b203ebeafb88102a86e2
Author: Dan Elphick <delphick@chromium.org>
Date: Thu Jan 04 10:06:29 2018

Add global scheduling to Background Fetch

The scheduler is now responsible for choosing which
BackgroundFetchJobController runs next. It round-robins through the
list of job controllers launching at most one download from each at a
time. Previously each JobController would get a new request from the
DataManager as soon it completed one, meaning that there would be as
many active downloads as there are JobControllers. The new scheduler
limits downloads globally and so will prevent too many downloads from
happening concurrently.

BackgroundFetchScheduler gets requests from a RequestManager
(implemented by BackgroundFetchDataManager) and delivers them to a
Controller (implemented by BackgroundFetchJobController).

Also eliminates MarkRequestAsStarted and related functions as we don't
do anything with the info.

Bug:  757760 
Change-Id: I59f68347e93d278285c83351cbe4e1dd22b91b1b
Reviewed-on: https://chromium-review.googlesource.com/776666
Commit-Queue: Dan Elphick <delphick@chromium.org>
Reviewed-by: Avi Drissman <avi@chromium.org>
Reviewed-by: Peter Beverloo <peter@chromium.org>
Cr-Commit-Position: refs/heads/master@{#526950}
[modify] https://crrev.com/14655855f937778a1f28b203ebeafb88102a86e2/content/browser/BUILD.gn
[modify] https://crrev.com/14655855f937778a1f28b203ebeafb88102a86e2/content/browser/background_fetch/background_fetch_context.cc
[modify] https://crrev.com/14655855f937778a1f28b203ebeafb88102a86e2/content/browser/background_fetch/background_fetch_context.h
[modify] https://crrev.com/14655855f937778a1f28b203ebeafb88102a86e2/content/browser/background_fetch/background_fetch_data_manager.cc
[modify] https://crrev.com/14655855f937778a1f28b203ebeafb88102a86e2/content/browser/background_fetch/background_fetch_data_manager.h
[modify] https://crrev.com/14655855f937778a1f28b203ebeafb88102a86e2/content/browser/background_fetch/background_fetch_job_controller.cc
[modify] https://crrev.com/14655855f937778a1f28b203ebeafb88102a86e2/content/browser/background_fetch/background_fetch_job_controller.h
[modify] https://crrev.com/14655855f937778a1f28b203ebeafb88102a86e2/content/browser/background_fetch/background_fetch_job_controller_unittest.cc
[modify] https://crrev.com/14655855f937778a1f28b203ebeafb88102a86e2/content/browser/background_fetch/background_fetch_request_manager.h
[add] https://crrev.com/14655855f937778a1f28b203ebeafb88102a86e2/content/browser/background_fetch/background_fetch_scheduler.cc
[add] https://crrev.com/14655855f937778a1f28b203ebeafb88102a86e2/content/browser/background_fetch/background_fetch_scheduler.h
[add] https://crrev.com/14655855f937778a1f28b203ebeafb88102a86e2/content/browser/background_fetch/background_fetch_scheduler_unittest.cc
[modify] https://crrev.com/14655855f937778a1f28b203ebeafb88102a86e2/content/test/BUILD.gn

Owner: peter@chromium.org
Over to you Peter...
Blockedon: 826257
Project Member

Comment 25 by bugdroid1@chromium.org, Apr 3 2018

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/78f882f3c6925783cd11d9e0978f9a5d55c75185

commit 78f882f3c6925783cd11d9e0978f9a5d55c75185
Author: Rayan Kanso <rayankans@chromium.org>
Date: Tue Apr 03 11:25:45 2018

[Background Fetch] Create Metadata proto for persistent storage.

The metadata will store additional developer-provided fields that will
help retain & recover the state of the background fetch.
Create/Get/Update registration database tasks are updated to support
the new metadata proto.

Bug:  826257 ,  757760 
Change-Id: I5b97638d3ab90e482911fb50479e5b8c312b4331
Reviewed-on: https://chromium-review.googlesource.com/984356
Commit-Queue: Rayan Kanso <rayankans@chromium.org>
Reviewed-by: Dan Elphick <delphick@chromium.org>
Cr-Commit-Position: refs/heads/master@{#547669}
[modify] https://crrev.com/78f882f3c6925783cd11d9e0978f9a5d55c75185/content/browser/background_fetch/background_fetch.proto
[modify] https://crrev.com/78f882f3c6925783cd11d9e0978f9a5d55c75185/content/browser/background_fetch/storage/README.md
[modify] https://crrev.com/78f882f3c6925783cd11d9e0978f9a5d55c75185/content/browser/background_fetch/storage/cleanup_task.cc
[modify] https://crrev.com/78f882f3c6925783cd11d9e0978f9a5d55c75185/content/browser/background_fetch/storage/create_registration_task.cc
[modify] https://crrev.com/78f882f3c6925783cd11d9e0978f9a5d55c75185/content/browser/background_fetch/storage/create_registration_task.h
[modify] https://crrev.com/78f882f3c6925783cd11d9e0978f9a5d55c75185/content/browser/background_fetch/storage/delete_registration_task.cc
[modify] https://crrev.com/78f882f3c6925783cd11d9e0978f9a5d55c75185/content/browser/background_fetch/storage/get_registration_task.cc
[modify] https://crrev.com/78f882f3c6925783cd11d9e0978f9a5d55c75185/content/browser/background_fetch/storage/get_registration_task.h
[modify] https://crrev.com/78f882f3c6925783cd11d9e0978f9a5d55c75185/content/browser/background_fetch/storage/mark_registration_for_deletion_task.cc
[modify] https://crrev.com/78f882f3c6925783cd11d9e0978f9a5d55c75185/content/browser/background_fetch/storage/update_registration_ui_task.cc
[modify] https://crrev.com/78f882f3c6925783cd11d9e0978f9a5d55c75185/content/browser/background_fetch/storage/update_registration_ui_task.h

Project Member

Comment 26 by bugdroid1@chromium.org, Apr 24 2018

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/ef95594f6d0712329bbe3348707454a5d2ed47c9

commit ef95594f6d0712329bbe3348707454a5d2ed47c9
Author: Rayan Kanso <rayankans@chromium.org>
Date: Tue Apr 24 13:26:17 2018

[Background Fetch] Update metadata stored upon registration.

Serialize the ServiceWorkerFetchRequests and store them with the metadata.
Store Pending Requests (all requests are pending initially), and add
util functions to query pending/active requests.

Design doc: https://docs.google.com/document/d/1zk6WSUb063I_07ct1EP8krOsDKXai1v4nJchvpQeAio/

Bug:  826257 ,  757760 
Change-Id: Ic3aa98106583e9273e5f93b53123b2e2f1067cd9
Reviewed-on: https://chromium-review.googlesource.com/1017101
Commit-Queue: Rayan Kanso <rayankans@chromium.org>
Reviewed-by: Peter Beverloo <peter@chromium.org>
Cr-Commit-Position: refs/heads/master@{#553069}
[modify] https://crrev.com/ef95594f6d0712329bbe3348707454a5d2ed47c9/content/browser/background_fetch/background_fetch.proto
[modify] https://crrev.com/ef95594f6d0712329bbe3348707454a5d2ed47c9/content/browser/background_fetch/background_fetch_data_manager_unittest.cc
[modify] https://crrev.com/ef95594f6d0712329bbe3348707454a5d2ed47c9/content/browser/background_fetch/storage/README.md
[modify] https://crrev.com/ef95594f6d0712329bbe3348707454a5d2ed47c9/content/browser/background_fetch/storage/create_metadata_task.cc
[modify] https://crrev.com/ef95594f6d0712329bbe3348707454a5d2ed47c9/content/browser/background_fetch/storage/create_metadata_task.h
[modify] https://crrev.com/ef95594f6d0712329bbe3348707454a5d2ed47c9/content/browser/background_fetch/storage/database_helpers.cc
[modify] https://crrev.com/ef95594f6d0712329bbe3348707454a5d2ed47c9/content/browser/background_fetch/storage/database_helpers.h
[modify] https://crrev.com/ef95594f6d0712329bbe3348707454a5d2ed47c9/content/browser/background_fetch/storage/delete_registration_task.cc
[modify] https://crrev.com/ef95594f6d0712329bbe3348707454a5d2ed47c9/content/browser/background_fetch/storage/mark_registration_for_deletion_task.cc

Labels: BlocksMVP
Status: Fixed (was: Started)

Sign in to add a comment