| Index: content/browser/background_fetch/background_fetch_context.h
|
| diff --git a/content/browser/background_fetch/background_fetch_context.h b/content/browser/background_fetch/background_fetch_context.h
|
| index 2ed7e50f0e8a6375ef3037e01456c3ce36f13635..110a4b693e5c0df6a66e4fd421fe683a3f6671d5 100644
|
| --- a/content/browser/background_fetch/background_fetch_context.h
|
| +++ b/content/browser/background_fetch/background_fetch_context.h
|
| @@ -5,6 +5,8 @@
|
| #ifndef CONTENT_BROWSER_BACKGROUND_FETCH_BACKGROUND_FETCH_CONTEXT_H_
|
| #define CONTENT_BROWSER_BACKGROUND_FETCH_BACKGROUND_FETCH_CONTEXT_H_
|
|
|
| +#include <string>
|
| +#include <vector>
|
| #include <unordered_map>
|
|
|
| #include "base/macros.h"
|
| @@ -13,13 +15,21 @@
|
| #include "content/browser/background_fetch/background_fetch_job_controller.h"
|
| #include "content/common/content_export.h"
|
| #include "content/public/browser/browser_thread.h"
|
| +#include "third_party/WebKit/public/platform/modules/background_fetch/background_fetch.mojom.h"
|
| +
|
| +namespace url {
|
| +class Origin;
|
| +}
|
|
|
| namespace content {
|
|
|
| class BackgroundFetchJobInfo;
|
| +struct BackgroundFetchOptions;
|
| +class BackgroundFetchRegistrationId;
|
| class BackgroundFetchRequestInfo;
|
| class BrowserContext;
|
| class ServiceWorkerContextWrapper;
|
| +struct ServiceWorkerFetchRequest;
|
|
|
| // The BackgroundFetchContext is the central moderator of ongoing background
|
| // fetch requests from the Mojo service and from other callers.
|
| @@ -36,13 +46,24 @@ class CONTENT_EXPORT BackgroundFetchContext
|
| StoragePartition* storage_partition,
|
| const scoped_refptr<ServiceWorkerContextWrapper>& context);
|
|
|
| - // Init and Shutdown are for use on the UI thread when the StoragePartition is
|
| - // being setup and torn down.
|
| - void Init();
|
| -
|
| // Shutdown must be called before deleting this. Call on the UI thread.
|
| void Shutdown();
|
|
|
| + // Starts a Background Fetch for the |registration_id|. The |requests| will be
|
| + // asynchronously fetched. The |callback| will be invoked when the fetch has
|
| + // been registered, or an error occurred that avoids it from doing so.
|
| + void StartFetch(
|
| + const BackgroundFetchRegistrationId& registration_id,
|
| + const std::vector<ServiceWorkerFetchRequest>& requests,
|
| + const BackgroundFetchOptions& options,
|
| + const blink::mojom::BackgroundFetchService::FetchCallback& callback);
|
| +
|
| + // Returns the active Background Fetch job for the |registration_id|. Will
|
| + // return a nullptr when there is no such job. The value returned from this
|
| + // method should not be cached for later use.
|
| + BackgroundFetchJobController* GetActiveJobForRegistrationId(
|
| + const BackgroundFetchRegistrationId& registration_id) const;
|
| +
|
| BackgroundFetchDataManager* GetDataManagerForTesting() {
|
| return &background_fetch_data_manager_;
|
| }
|
| @@ -55,8 +76,13 @@ class CONTENT_EXPORT BackgroundFetchContext
|
|
|
| ~BackgroundFetchContext();
|
|
|
| - void CreateRequest(std::unique_ptr<BackgroundFetchJobInfo> job_info,
|
| - std::vector<BackgroundFetchRequestInfo>& request_infos);
|
| + // Called when a new registration has been created by the data manager.
|
| + void DidCreateCreateRegistration(
|
| + const BackgroundFetchRegistrationId& registration_id,
|
| + const BackgroundFetchOptions& options,
|
| + const blink::mojom::BackgroundFetchService::FetchCallback& callback,
|
| + blink::mojom::BackgroundFetchError error,
|
| + std::unique_ptr<BackgroundFetchJobData> job_data);
|
|
|
| // Callback for the JobController when the job is complete.
|
| void DidCompleteJob(const std::string& job_guid);
|
| @@ -70,8 +96,7 @@ class CONTENT_EXPORT BackgroundFetchContext
|
| scoped_refptr<ServiceWorkerContextWrapper> service_worker_context_;
|
| BackgroundFetchDataManager background_fetch_data_manager_;
|
|
|
| - std::unordered_map<std::string, std::unique_ptr<BackgroundFetchJobController>>
|
| - job_map_;
|
| + std::vector<std::unique_ptr<BackgroundFetchJobController>> controllers_;
|
|
|
| DISALLOW_COPY_AND_ASSIGN(BackgroundFetchContext);
|
| };
|
|
|