OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CONTENT_BROWSER_BACKGROUND_FETCH_BACKGROUND_FETCH_JOB_DATA_H_ |
| 6 #define CONTENT_BROWSER_BACKGROUND_FETCH_BACKGROUND_FETCH_JOB_DATA_H_ |
| 7 |
| 8 #include <string> |
| 9 #include <unordered_map> |
| 10 |
| 11 #include "base/macros.h" |
| 12 #include "content/browser/background_fetch/background_fetch_request_info.h" |
| 13 #include "content/common/content_export.h" |
| 14 #include "url/origin.h" |
| 15 |
| 16 namespace content { |
| 17 |
| 18 // The BackgroundFetchJobData class provides the interface from the |
| 19 // JobController to the data storage in the DataManager. It has a reference |
| 20 // to the DataManager and invokes calls given the stored batch_guid. |
| 21 class CONTENT_EXPORT BackgroundFetchJobData { |
| 22 public: |
| 23 explicit BackgroundFetchJobData(BackgroundFetchRequestInfos request_infos); |
| 24 ~BackgroundFetchJobData(); |
| 25 |
| 26 // Called by the JobController to inform the JobData that the given fetch |
| 27 // has completed. The JobData returns a boolean indicating whether there |
| 28 // are more requests to process. |
| 29 bool BackgroundFetchRequestInfoComplete(const std::string& fetch_guid); |
| 30 |
| 31 // Called by the JobController to get a BackgroundFetchRequestInfo to |
| 32 // process. |
| 33 const BackgroundFetchRequestInfo& GetNextBackgroundFetchRequestInfo(); |
| 34 |
| 35 // Indicates whether all requests have been handed to the JobController. |
| 36 bool HasRequestsRemaining() const; |
| 37 |
| 38 // Indicates whether all requests have been handed out and completed. |
| 39 bool IsComplete() const; |
| 40 |
| 41 private: |
| 42 BackgroundFetchRequestInfos request_infos_; |
| 43 |
| 44 // Map from fetch_guid to index in request_infos_. Only currently |
| 45 // outstanding requests should be in this map. |
| 46 std::unordered_map<std::string, int> request_info_index_; |
| 47 size_t next_request_info_ = 0; |
| 48 |
| 49 DISALLOW_COPY_AND_ASSIGN(BackgroundFetchJobData); |
| 50 }; |
| 51 |
| 52 } // namespace content |
| 53 |
| 54 #endif // CONTENT_BROWSER_BACKGROUND_FETCH_BACKGROUND_FETCH_JOB_DATA_H_ |
OLD | NEW |