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

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

Issue 2708943002: Create the BackgroundFetchBatchManager and initiate a download. (Closed)
Patch Set: fixed nits 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_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 <map> 8 #include <map>
9 #include <string> 9 #include <string>
10 #include <unordered_map>
10 11
11 #include "base/macros.h" 12 #include "base/macros.h"
12 #include "content/browser/background_fetch/fetch_request.h" 13 #include "content/browser/background_fetch/background_fetch_job_data.h"
13 #include "content/common/content_export.h" 14 #include "content/common/content_export.h"
14 #include "url/origin.h" 15 #include "url/origin.h"
15 16
16 namespace content { 17 namespace content {
17 18
18 class BackgroundFetchContext; 19 class BackgroundFetchContext;
20 class BackgroundFetchJobInfo;
19 21
20 // The BackgroundFetchDataManager keeps track of all of the outstanding requests 22 // The BackgroundFetchDataManager keeps track of all of the outstanding requests
21 // which are in process in the DownloadManager. When Chromium restarts, it is 23 // which are in process in the DownloadManager. When Chromium restarts, it is
22 // responsibile for reconnecting all the in progress downloads with an observer 24 // responsibile for reconnecting all the in progress downloads with an observer
23 // which will keep the metadata up to date. 25 // which will keep the metadata up to date.
24 class CONTENT_EXPORT BackgroundFetchDataManager { 26 class CONTENT_EXPORT BackgroundFetchDataManager {
25 public: 27 public:
26 explicit BackgroundFetchDataManager( 28 explicit BackgroundFetchDataManager(
27 BackgroundFetchContext* background_fetch_context); 29 BackgroundFetchContext* background_fetch_context);
28 ~BackgroundFetchDataManager(); 30 ~BackgroundFetchDataManager();
29 31
30 // Called by BackgroundFetchContext when a new request is started, this will 32 // Called by BackgroundFetchContext when a new request is started, this will
31 // store all of the necessary metadata to track the request. 33 // store all of the necessary metadata to track the request. The lifetime of
32 void CreateRequest(const FetchRequest& fetch_request); 34 // the returned pointer is tied to the lifetime of the
35 // BackgroundFetchDataManager.
36 // TODO(harkness): Lifetime should be tied to the lifetime of the associated
37 // JobController once there is a JobController per request.
38 BackgroundFetchJobData* CreateRequest(
39 const BackgroundFetchJobInfo& job_info,
40 BackgroundFetchRequestInfos request_infos);
33 41
34 private: 42 private:
35 // BackgroundFetchContext owns this BackgroundFetchDataManager, so the 43 // BackgroundFetchContext owns this BackgroundFetchDataManager, so the
36 // DataManager is guaranteed to be destructed before the Context. 44 // DataManager is guaranteed to be destructed before the Context.
37 BackgroundFetchContext* background_fetch_context_; 45 BackgroundFetchContext* background_fetch_context_;
38 46
39 // Map from <sw_registration_id, tag> to the FetchRequest for that tag. 47 // Map from <sw_registration_id, tag> to the JobData for that tag.
40 using FetchIdentifier = std::pair<int64_t, std::string>; 48 using JobIdentifier = std::pair<int64_t, std::string>;
41 std::map<FetchIdentifier, FetchRequest> fetch_map_; 49 std::map<JobIdentifier, std::string> service_worker_tag_map_;
50
51 // Map of batch guid to the associated BackgroundFetchJobData object.
52 std::unordered_map<std::string, std::unique_ptr<BackgroundFetchJobData>>
53 batch_map_;
42 54
43 DISALLOW_COPY_AND_ASSIGN(BackgroundFetchDataManager); 55 DISALLOW_COPY_AND_ASSIGN(BackgroundFetchDataManager);
44 }; 56 };
45 57
46 } // namespace content 58 } // namespace content
47 59
48 #endif // CONTENT_BROWSER_BACKGROUND_FETCH_BACKGROUND_FETCH_DATA_MANAGER_H_ 60 #endif // CONTENT_BROWSER_BACKGROUND_FETCH_BACKGROUND_FETCH_DATA_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698