| Index: content/browser/background_fetch/background_fetch_data_manager.h
|
| diff --git a/content/browser/background_fetch/background_fetch_data_manager.h b/content/browser/background_fetch/background_fetch_data_manager.h
|
| index a093da2dbfbe97fe8829e894b0eb7f5814a25c7f..f1b8c7ea1362191fe31dd53f36fc9818f9113365 100644
|
| --- a/content/browser/background_fetch/background_fetch_data_manager.h
|
| +++ b/content/browser/background_fetch/background_fetch_data_manager.h
|
| @@ -10,16 +10,19 @@
|
| #include <string>
|
| #include <unordered_map>
|
|
|
| +#include "base/callback_forward.h"
|
| #include "base/macros.h"
|
| -#include "content/browser/background_fetch/background_fetch_job_data.h"
|
| #include "content/browser/background_fetch/background_fetch_job_info.h"
|
| +#include "content/browser/background_fetch/background_fetch_job_response_data.h"
|
| #include "content/browser/background_fetch/background_fetch_registration_id.h"
|
| +#include "content/browser/background_fetch/background_fetch_request_info.h"
|
| #include "content/common/content_export.h"
|
| #include "url/origin.h"
|
|
|
| namespace content {
|
|
|
| -class BackgroundFetchContext;
|
| +class BrowserContext;
|
| +class BlobHandle;
|
|
|
| // The BackgroundFetchDataManager keeps track of all of the outstanding requests
|
| // which are in process in the DownloadManager. When Chromium restarts, it is
|
| @@ -27,36 +30,77 @@ class BackgroundFetchContext;
|
| // which will keep the metadata up to date.
|
| class CONTENT_EXPORT BackgroundFetchDataManager {
|
| public:
|
| - explicit BackgroundFetchDataManager(
|
| - BackgroundFetchContext* background_fetch_context);
|
| + explicit BackgroundFetchDataManager(BrowserContext* browser_context);
|
| ~BackgroundFetchDataManager();
|
|
|
| // Called by BackgroundFetchContext when a new request is started, this will
|
| // store all of the necessary metadata to track the request.
|
| - std::unique_ptr<BackgroundFetchJobData> CreateRequest(
|
| + void CreateRequest(
|
| std::unique_ptr<BackgroundFetchJobInfo> job_info,
|
| - BackgroundFetchRequestInfos request_infos);
|
| + std::vector<std::unique_ptr<BackgroundFetchRequestInfo>> request_infos);
|
|
|
| - private:
|
| - void WriteJobToStorage(std::unique_ptr<BackgroundFetchJobInfo> job_info,
|
| - BackgroundFetchRequestInfos request_infos);
|
| + // TODO(harkness): Replace the OnceClosure with a callback to return the
|
| + // response object once it is decided whether lifetime should be passed to the
|
| + // caller or stay here.
|
| + void GetJobResponse(const std::string& job_guid,
|
| + const BackgroundFetchResponseCompleteCallback& callback);
|
| +
|
| + // The following methods are called by the JobController to update job state.
|
| + // Returns a boolean indicating whether there are more requests to process.
|
| + virtual bool UpdateRequestState(const std::string& job_guid,
|
| + const std::string& request_guid,
|
| + DownloadItem::DownloadState state,
|
| + DownloadInterruptReason interrupt_reason);
|
| + virtual void UpdateRequestStorageState(const std::string& job_guid,
|
| + const std::string& request_guid,
|
| + const base::FilePath& file_path,
|
| + int64_t received_bytes);
|
| + virtual void UpdateRequestDownloadGuid(const std::string& job_guid,
|
| + const std::string& request_guid,
|
| + const std::string& download_guid);
|
|
|
| - BackgroundFetchRequestInfos& ReadRequestsFromStorage(
|
| + // Called by the JobController to get a BackgroundFetchRequestInfo to
|
| + // process.
|
| + virtual const BackgroundFetchRequestInfo& GetNextBackgroundFetchRequestInfo(
|
| const std::string& job_guid);
|
|
|
| - // BackgroundFetchContext owns this BackgroundFetchDataManager, so the
|
| - // DataManager is guaranteed to be destructed before the Context.
|
| - BackgroundFetchContext* background_fetch_context_;
|
| + // Indicates whether all requests have been handed to the JobController.
|
| + virtual bool HasRequestsRemaining(const std::string& job_guid) const;
|
| +
|
| + // Indicates whether all requests have been handed out and completed.
|
| + virtual bool IsComplete(const std::string& job_guid) const;
|
| +
|
| + private:
|
| + // Storage interface.
|
| + void WriteJobToStorage(
|
| + std::unique_ptr<BackgroundFetchJobInfo> job_info,
|
| + std::vector<std::unique_ptr<BackgroundFetchRequestInfo>> request_infos);
|
| + void WriteRequestToStorage(const std::string& job_guid,
|
| + BackgroundFetchRequestInfo* request_info);
|
| + std::unique_ptr<BackgroundFetchRequestInfo> GetRequestInfo(
|
| + const std::string& job_guid,
|
| + size_t request_index);
|
| +
|
| + void DidGetRequestResponse(const std::string& job_guid,
|
| + int request_sequence_number,
|
| + std::unique_ptr<BlobHandle> blob_handle);
|
| +
|
| + // Indirectly, this is owned by the BrowserContext.
|
| + BrowserContext* browser_context_;
|
|
|
| // Set of known background fetch registration ids.
|
| std::set<BackgroundFetchRegistrationId> known_registrations_;
|
|
|
| - // Temporary map to hold data which will be written to storage.
|
| // Map from job_guid to JobInfo.
|
| std::unordered_map<std::string, std::unique_ptr<BackgroundFetchJobInfo>>
|
| job_map_;
|
| +
|
| + // Temporary map to hold data which will be written to storage.
|
| // Map from job_guid to RequestInfos.
|
| - std::unordered_map<std::string, BackgroundFetchRequestInfos> request_map_;
|
| + std::unordered_map<std::string, std::vector<BackgroundFetchRequestInfo>>
|
| + request_map_;
|
| +
|
| + base::WeakPtrFactory<BackgroundFetchDataManager> weak_ptr_factory_;
|
|
|
| DISALLOW_COPY_AND_ASSIGN(BackgroundFetchDataManager);
|
| };
|
|
|