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_DATA_MANAGER_H_ | 5 #ifndef CONTENT_BROWSER_BACKGROUND_FETCH_BACKGROUND_FETCH_DATA_MANAGER_H_ |
6 #define CONTENT_BROWSER_BACKGROUND_FETCH_BACKGROUND_FETCH_DATA_MANAGER_H_ | 6 #define CONTENT_BROWSER_BACKGROUND_FETCH_BACKGROUND_FETCH_DATA_MANAGER_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 #include <set> | 9 #include <set> |
10 #include <string> | 10 #include <string> |
11 #include <unordered_map> | 11 #include <unordered_map> |
12 | 12 |
13 #include "base/callback_forward.h" | 13 #include "base/callback_forward.h" |
14 #include "base/macros.h" | 14 #include "base/macros.h" |
15 #include "content/browser/background_fetch/background_fetch_job_info.h" | 15 #include "content/browser/background_fetch/background_fetch_job_info.h" |
16 #include "content/browser/background_fetch/background_fetch_job_response_data.h" | 16 #include "content/browser/background_fetch/background_fetch_job_response_data.h" |
17 #include "content/browser/background_fetch/background_fetch_registration_id.h" | 17 #include "content/browser/background_fetch/background_fetch_registration_id.h" |
18 #include "content/browser/background_fetch/background_fetch_request_info.h" | 18 #include "content/browser/background_fetch/background_fetch_request_info.h" |
19 #include "content/common/content_export.h" | 19 #include "content/common/content_export.h" |
20 #include "url/origin.h" | 20 #include "url/origin.h" |
21 | 21 |
22 namespace content { | 22 namespace content { |
23 | 23 |
24 class BrowserContext; | 24 class BrowserContext; |
25 class BlobHandle; | 25 class ChromeBlobStorageContext; |
26 | 26 |
27 // The BackgroundFetchDataManager keeps track of all of the outstanding requests | 27 // The BackgroundFetchDataManager keeps track of all of the outstanding requests |
28 // which are in process in the DownloadManager. When Chromium restarts, it is | 28 // which are in process in the DownloadManager. When Chromium restarts, it is |
29 // responsibile for reconnecting all the in progress downloads with an observer | 29 // responsibile for reconnecting all the in progress downloads with an observer |
30 // which will keep the metadata up to date. | 30 // which will keep the metadata up to date. |
31 class CONTENT_EXPORT BackgroundFetchDataManager { | 31 class CONTENT_EXPORT BackgroundFetchDataManager { |
32 public: | 32 public: |
33 explicit BackgroundFetchDataManager(BrowserContext* browser_context); | 33 explicit BackgroundFetchDataManager(BrowserContext* browser_context); |
34 ~BackgroundFetchDataManager(); | 34 ~BackgroundFetchDataManager(); |
35 | 35 |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 // Storage interface. | 74 // Storage interface. |
75 void WriteJobToStorage( | 75 void WriteJobToStorage( |
76 std::unique_ptr<BackgroundFetchJobInfo> job_info, | 76 std::unique_ptr<BackgroundFetchJobInfo> job_info, |
77 std::vector<std::unique_ptr<BackgroundFetchRequestInfo>> request_infos); | 77 std::vector<std::unique_ptr<BackgroundFetchRequestInfo>> request_infos); |
78 void WriteRequestToStorage(const std::string& job_guid, | 78 void WriteRequestToStorage(const std::string& job_guid, |
79 BackgroundFetchRequestInfo* request_info); | 79 BackgroundFetchRequestInfo* request_info); |
80 std::unique_ptr<BackgroundFetchRequestInfo> GetRequestInfo( | 80 std::unique_ptr<BackgroundFetchRequestInfo> GetRequestInfo( |
81 const std::string& job_guid, | 81 const std::string& job_guid, |
82 size_t request_index); | 82 size_t request_index); |
83 | 83 |
84 void DidGetRequestResponse(const std::string& job_guid, | 84 void DidGetBlobStorageContext( |
85 int request_sequence_number, | 85 const std::string& job_guid, |
86 std::unique_ptr<BlobHandle> blob_handle); | 86 const BackgroundFetchResponseCompleteCallback& callback, |
| 87 ChromeBlobStorageContext* blob_context); |
87 | 88 |
88 // Indirectly, this is owned by the BrowserContext. | 89 // Indirectly, this is owned by the BrowserContext. |
89 BrowserContext* browser_context_; | 90 BrowserContext* browser_context_; |
90 | 91 |
91 // Set of known background fetch registration ids. | 92 // Set of known background fetch registration ids. |
92 std::set<BackgroundFetchRegistrationId> known_registrations_; | 93 std::set<BackgroundFetchRegistrationId> known_registrations_; |
93 | 94 |
94 // Map from job_guid to JobInfo. | 95 // Map from job_guid to JobInfo. |
95 std::unordered_map<std::string, std::unique_ptr<BackgroundFetchJobInfo>> | 96 std::unordered_map<std::string, std::unique_ptr<BackgroundFetchJobInfo>> |
96 job_map_; | 97 job_map_; |
97 | 98 |
98 // Temporary map to hold data which will be written to storage. | 99 // Temporary map to hold data which will be written to storage. |
99 // Map from job_guid to RequestInfos. | 100 // Map from job_guid to RequestInfos. |
100 std::unordered_map<std::string, std::vector<BackgroundFetchRequestInfo>> | 101 std::unordered_map<std::string, std::vector<BackgroundFetchRequestInfo>> |
101 request_map_; | 102 request_map_; |
102 | 103 |
103 base::WeakPtrFactory<BackgroundFetchDataManager> weak_ptr_factory_; | 104 base::WeakPtrFactory<BackgroundFetchDataManager> weak_ptr_factory_; |
104 | 105 |
105 DISALLOW_COPY_AND_ASSIGN(BackgroundFetchDataManager); | 106 DISALLOW_COPY_AND_ASSIGN(BackgroundFetchDataManager); |
106 }; | 107 }; |
107 | 108 |
108 } // namespace content | 109 } // namespace content |
109 | 110 |
110 #endif // CONTENT_BROWSER_BACKGROUND_FETCH_BACKGROUND_FETCH_DATA_MANAGER_H_ | 111 #endif // CONTENT_BROWSER_BACKGROUND_FETCH_BACKGROUND_FETCH_DATA_MANAGER_H_ |
OLD | NEW |