Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(338)

Side by Side Diff: content/browser/background_fetch/background_fetch_job_controller.h

Issue 2724783002: Make the BackgroundFetchJobController a per-job object (Closed)
Patch Set: Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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.
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(const std::string& job_guid,
28 StoragePartition* storage_partition); 28 BrowserContext* browser_context,
29 StoragePartition* storage_partition,
30 BackgroundFetchJobData* job_data);
Peter Beverloo 2017/03/08 14:27:04 nit: pass as std::unique_ptr<>
harkness 2017/03/09 13:33:25 Done.
29 ~BackgroundFetchJobController(); 31 ~BackgroundFetchJobController();
30 32
31 // Start processing on a batch of requests. Some of these may already be in 33 // Start processing on a batch of requests. Some of these may already be in
32 // progress or completed from a previous chromium instance. 34 // progress or completed from a previous chromium instance.
33 void ProcessJob(const std::string& job_guid, 35 void StartProcessing();
34 BackgroundFetchJobData* job_data); 36
37 // Called by the BackgroundFetchContext when the system is shutting down.
38 void Shutdown();
35 39
36 private: 40 private:
37 void ProcessRequest(const std::string& job_guid, 41 void ProcessRequest(const BackgroundFetchRequestInfo& request);
38 const BackgroundFetchRequestInfo& request);
39 42
40 // Pointer to the browser context. The BackgroundFetchJobController is owned 43 // Pointer to the browser context. The BackgroundFetchJobController is owned
41 // by the BrowserContext via the StoragePartition. 44 // by the BrowserContext via the StoragePartition.
42 BrowserContext* browser_context_; 45 BrowserContext* browser_context_;
43 46
44 // Pointer to the storage partition. This object is owned by the partition 47 // Pointer to the storage partition. This object is owned by the partition
45 // (through a sequence of other classes). 48 // (through a sequence of other classes).
46 StoragePartition* storage_partition_; 49 StoragePartition* storage_partition_;
47 50
48 // The fetch_map holds any requests which have been sent to the 51 // The JobData which talks to the DataManager for this job_guid.
49 // DownloadManager indexed by the job_guid. 52 std::unique_ptr<BackgroundFetchJobData> job_data_;
50 std::unordered_map<std::string, BackgroundFetchRequestInfo> fetch_map_;
51 53
52 DISALLOW_COPY_AND_ASSIGN(BackgroundFetchJobController); 54 DISALLOW_COPY_AND_ASSIGN(BackgroundFetchJobController);
53 }; 55 };
54 56
55 } // namespace content 57 } // namespace content
56 58
57 #endif // CONTENT_BROWSER_BACKGROUND_FETCH_BACKGROUND_FETCH_JOB_CONTROLLER_H_ 59 #endif // CONTENT_BROWSER_BACKGROUND_FETCH_BACKGROUND_FETCH_JOB_CONTROLLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698