Index: content/browser/background_fetch/background_fetch_data_manager.h |
diff --git a/content/browser/background_fetch/background_fetch_data_manager.h b/content/browser/background_fetch/background_fetch_data_manager.h |
index 3244a5556bbee2716813fd61dae52e967c9a644f..e5f029cb16e94345ec425e5f94265e95a1b2d0ba 100644 |
--- a/content/browser/background_fetch/background_fetch_data_manager.h |
+++ b/content/browser/background_fetch/background_fetch_data_manager.h |
@@ -7,6 +7,8 @@ |
#include <map> |
#include <string> |
+#include <unordered_map> |
+#include <vector> |
#include "base/macros.h" |
#include "content/browser/background_fetch/fetch_request.h" |
@@ -16,6 +18,7 @@ |
namespace content { |
class BackgroundFetchContext; |
+class BatchRequest; |
// The BackgroundFetchDataManager keeps track of all of the outstanding requests |
// which are in process in the DownloadManager. When Chromium restarts, it is |
@@ -27,9 +30,33 @@ class CONTENT_EXPORT BackgroundFetchDataManager { |
BackgroundFetchContext* background_fetch_context); |
~BackgroundFetchDataManager(); |
+ // The BatchData class provides the interface from the BatchProcessor to the |
+ // data storage. |
Peter Beverloo
2017/02/24 02:05:16
This comment doesn't really mean anything to me. W
harkness
2017/02/24 11:47:11
We could do that, but I like encapsulating the pie
Peter Beverloo
2017/02/24 15:43:14
That sounds like the sort of improvements we could
|
+ class BatchData { |
+ public: |
+ using FetchRequests = std::vector<FetchRequest>; |
Peter Beverloo
2017/02/24 02:05:16
This is a source of lots of potential copies too.
harkness
2017/02/24 11:47:11
Done.
|
+ BatchData(); |
Peter Beverloo
2017/02/24 02:05:16
Please delete the argument-less constructor (it's
harkness
2017/02/24 11:47:11
Done.
|
+ BatchData(const BatchRequest& batch_request, |
+ const FetchRequests& fetch_requests); |
+ ~BatchData(); |
+ bool FetchRequestComplete(const std::string& fetch_uid); |
Peter Beverloo
2017/02/24 02:05:16
All of these are public methods, please document t
Peter Beverloo
2017/02/24 02:05:16
uid -> guid
harkness
2017/02/24 11:47:11
Sorry, I had actually done that, but it looks like
harkness
2017/02/24 11:47:11
Done.
|
+ const FetchRequest& GetNextFetchRequest(); |
+ bool IsComplete() const; |
+ bool HasRequestsRemaining() const; |
+ |
+ private: |
+ FetchRequests fetch_requests_; |
+ |
+ // Map from fetch_uid to index in fetch_requests_. Only currently |
+ // outstanding requests should be in this map. |
+ std::unordered_map<std::string, int> fetch_request_index_; |
+ unsigned long next_fetch_request_ = 0; |
Peter Beverloo
2017/02/24 02:05:16
nit: we try to avoid using unsigned types per the
harkness
2017/02/24 11:47:11
Updated to size_t.
|
+ }; |
+ |
// Called by BackgroundFetchContext when a new request is started, this will |
// store all of the necessary metadata to track the request. |
- void CreateRequest(const FetchRequest& fetch_request); |
+ BatchData* CreateRequest(const BatchRequest& batch_request, |
Peter Beverloo
2017/02/24 02:05:16
Document the memory model of the returned pointer.
harkness
2017/02/24 11:47:11
Done.
|
+ const std::vector<FetchRequest>& fetch_requests); |
private: |
// BackgroundFetchContext owns this BackgroundFetchDataManager, so the |
@@ -37,8 +64,10 @@ class CONTENT_EXPORT BackgroundFetchDataManager { |
BackgroundFetchContext* background_fetch_context_; |
// Map from <sw_registration_id, tag> to the FetchRequest for that tag. |
- using FetchIdentifier = std::pair<int64_t, std::string>; |
- std::map<FetchIdentifier, FetchRequest> fetch_map_; |
+ using BatchIdentifier = std::pair<int64_t, std::string>; |
+ std::map<BatchIdentifier, std::string> service_worker_tag_map_; |
+ |
+ std::map<std::string, BatchData*> batch_map_; |
Peter Beverloo
2017/02/24 02:05:16
This must be std::unique_ptr<BatchData>. Manual me
Peter Beverloo
2017/02/24 02:05:16
Document what the index is. Do we depend on orderi
harkness
2017/02/24 11:47:11
Done.
harkness
2017/02/24 11:47:11
Done.
|
DISALLOW_COPY_AND_ASSIGN(BackgroundFetchDataManager); |
}; |