OLD | NEW |
(Empty) | |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CONTENT_BROWSER_BACKGROUND_FETCH_BACKGROUND_FETCH_JOB_CONTROLLER_H_ |
| 6 #define CONTENT_BROWSER_BACKGROUND_FETCH_BACKGROUND_FETCH_JOB_CONTROLLER_H_ |
| 7 |
| 8 #include <string> |
| 9 #include <unordered_map> |
| 10 #include <vector> |
| 11 |
| 12 #include "content/browser/background_fetch/background_fetch_data_manager.h" |
| 13 #include "content/browser/background_fetch/background_fetch_request_info.h" |
| 14 #include "content/common/content_export.h" |
| 15 |
| 16 namespace content { |
| 17 |
| 18 class BrowserContext; |
| 19 class StoragePartition; |
| 20 |
| 21 // The JobController will be responsible for coordinating communication with the |
| 22 // DownloadManager. It will get requests from the JobData and dispatch them to |
| 23 // the DownloadManager. |
| 24 // TODO(harkness): The JobController should also observe downloads. |
| 25 class CONTENT_EXPORT BackgroundFetchJobController { |
| 26 public: |
| 27 BackgroundFetchJobController(BrowserContext* browser_context, |
| 28 StoragePartition* storage_partition); |
| 29 ~BackgroundFetchJobController(); |
| 30 |
| 31 // Start processing on a batch of requests. Some of these may already be in |
| 32 // progress or completed from a previous chromium instance. |
| 33 void ProcessJob(const std::string& job_guid, |
| 34 BackgroundFetchJobData* job_data); |
| 35 |
| 36 private: |
| 37 void ProcessRequest(const std::string& job_guid, |
| 38 const BackgroundFetchRequestInfo& request); |
| 39 |
| 40 // Pointer to the browser context. The BackgroundFetchJobController is owned |
| 41 // by the BrowserContext via the StoragePartition. |
| 42 BrowserContext* browser_context_; |
| 43 |
| 44 // Pointer to the storage partition. This object is owned by the partition |
| 45 // (through a sequence of other classes). |
| 46 StoragePartition* storage_partition_; |
| 47 |
| 48 // The fetch_map holds any requests which have been sent to the |
| 49 // DownloadManager indexed by the job_guid. |
| 50 std::unordered_map<std::string, BackgroundFetchRequestInfo> fetch_map_; |
| 51 |
| 52 DISALLOW_COPY_AND_ASSIGN(BackgroundFetchJobController); |
| 53 }; |
| 54 |
| 55 } // namespace content |
| 56 |
| 57 #endif // CONTENT_BROWSER_BACKGROUND_FETCH_BACKGROUND_FETCH_JOB_CONTROLLER_H_ |
OLD | NEW |