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