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

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

Issue 2753583002: Add the JobComplete callback and error/interrupt information (Closed)
Patch Set: added argument name 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 <memory>
9 #include <string> 9 #include <string>
10 #include <unordered_map> 10 #include <unordered_map>
11 11
12 #include "base/callback.h"
12 #include "base/macros.h" 13 #include "base/macros.h"
13 #include "base/memory/weak_ptr.h" 14 #include "base/memory/weak_ptr.h"
14 #include "content/common/content_export.h" 15 #include "content/common/content_export.h"
15 #include "content/public/browser/download_item.h" 16 #include "content/public/browser/download_item.h"
16 17
17 namespace content { 18 namespace content {
18 19
19 class BackgroundFetchJobData; 20 class BackgroundFetchJobData;
20 class BackgroundFetchRequestInfo; 21 class BackgroundFetchRequestInfo;
21 class BrowserContext; 22 class BrowserContext;
22 class StoragePartition; 23 class StoragePartition;
23 24
24 // The JobController will be responsible for coordinating communication with the 25 // The JobController will be responsible for coordinating communication with the
25 // DownloadManager. It will get requests from the JobData and dispatch them to 26 // DownloadManager. It will get requests from the JobData and dispatch them to
26 // the DownloadManager. It lives entirely on the IO thread. 27 // the DownloadManager. It lives entirely on the IO thread.
27 class CONTENT_EXPORT BackgroundFetchJobController 28 class CONTENT_EXPORT BackgroundFetchJobController
28 : public DownloadItem::Observer { 29 : public DownloadItem::Observer {
29 public: 30 public:
30 BackgroundFetchJobController( 31 BackgroundFetchJobController(const std::string& job_guid,
31 const std::string& job_guid, 32 BrowserContext* browser_context,
32 BrowserContext* browser_context, 33 StoragePartition* storage_partition,
33 StoragePartition* storage_partition, 34 std::unique_ptr<BackgroundFetchJobData> job_data,
34 std::unique_ptr<BackgroundFetchJobData> job_data); 35 base::OnceClosure completed_closure);
35 ~BackgroundFetchJobController() override; 36 ~BackgroundFetchJobController() override;
36 37
37 // Start processing on a batch of requests. Some of these may already be in 38 // Start processing on a batch of requests. Some of these may already be in
38 // progress or completed from a previous chromium instance. 39 // progress or completed from a previous chromium instance.
39 void StartProcessing(); 40 void StartProcessing();
40 41
41 // Called by the BackgroundFetchContext when the system is shutting down. 42 // Called by the BackgroundFetchContext when the system is shutting down.
42 void Shutdown(); 43 void Shutdown();
43 44
44 private: 45 private:
(...skipping 15 matching lines...) Expand all
60 // Investigate whether the DownloadManager should be passed instead. 61 // Investigate whether the DownloadManager should be passed instead.
61 BrowserContext* browser_context_; 62 BrowserContext* browser_context_;
62 63
63 // Pointer to the storage partition. This object is owned by the partition 64 // Pointer to the storage partition. This object is owned by the partition
64 // (through a sequence of other classes). 65 // (through a sequence of other classes).
65 StoragePartition* storage_partition_; 66 StoragePartition* storage_partition_;
66 67
67 // The JobData which talks to the DataManager for this job_guid. 68 // The JobData which talks to the DataManager for this job_guid.
68 std::unique_ptr<BackgroundFetchJobData> job_data_; 69 std::unique_ptr<BackgroundFetchJobData> job_data_;
69 70
71 // Callback for when all fetches have been completed.
72 base::OnceClosure completed_closure_;
73
70 // Map from the GUID assigned by the DownloadManager to the request_guid. 74 // Map from the GUID assigned by the DownloadManager to the request_guid.
71 std::unordered_map<std::string, std::string> download_guid_map_; 75 std::unordered_map<std::string, std::string> download_guid_map_;
72 76
73 base::WeakPtrFactory<BackgroundFetchJobController> weak_ptr_factory_; 77 base::WeakPtrFactory<BackgroundFetchJobController> weak_ptr_factory_;
74 78
75 DISALLOW_COPY_AND_ASSIGN(BackgroundFetchJobController); 79 DISALLOW_COPY_AND_ASSIGN(BackgroundFetchJobController);
76 }; 80 };
77 81
78 } // namespace content 82 } // namespace content
79 83
80 #endif // CONTENT_BROWSER_BACKGROUND_FETCH_BACKGROUND_FETCH_JOB_CONTROLLER_H_ 84 #endif // CONTENT_BROWSER_BACKGROUND_FETCH_BACKGROUND_FETCH_JOB_CONTROLLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698