Chromium Code Reviews| Index: content/browser/background_fetch/background_fetch_job_info.h |
| diff --git a/content/browser/background_fetch/background_fetch_job_info.h b/content/browser/background_fetch/background_fetch_job_info.h |
| index aba5bd8fa89a22e4590e3e88890c6b2cc35aede1..5c5d85ef142d756825a0b4238e4f3e107c61add4 100644 |
| --- a/content/browser/background_fetch/background_fetch_job_info.h |
| +++ b/content/browser/background_fetch/background_fetch_job_info.h |
| @@ -5,9 +5,11 @@ |
| #ifndef CONTENT_BROWSER_BACKGROUND_FETCH_BACKGROUND_FETCH_JOB_INFO_H |
| #define CONTENT_BROWSER_BACKGROUND_FETCH_BACKGROUND_FETCH_JOB_INFO_H |
| +#include <memory> |
| #include <string> |
| #include <vector> |
| +#include "base/containers/flat_set.h" |
| #include "base/macros.h" |
| #include "content/common/content_export.h" |
| #include "content/common/service_worker/service_worker_types.h" |
| @@ -15,6 +17,9 @@ |
| namespace content { |
| +class BackgroundFetchJobResponseData; |
| +class BackgroundFetchRequestInfo; |
| + |
| // Class to encapsulate a batch of FetchRequests into a single grouping which is |
| // what the developer requested. |
| class CONTENT_EXPORT BackgroundFetchJobInfo { |
| @@ -35,6 +40,26 @@ class CONTENT_EXPORT BackgroundFetchJobInfo { |
| return request_guids_; |
| } |
| + // The |job_response_data| holds information to build a response object to |
| + // return to the Mojo service. |
| + void set_job_response_data( |
| + std::unique_ptr<BackgroundFetchJobResponseData> job_response_data); |
| + BackgroundFetchJobResponseData* job_response_data() const { |
| + return job_response_data_.get(); |
| + } |
| + |
| + // The following methods are used to track currently in progress requests. |
| + void set_num_requests(size_t num_requests) { num_requests_ = num_requests; } |
| + size_t num_requests() const { return num_requests_; } |
| + bool IsComplete() const; |
| + bool HasRequestsRemaining() const; |
| + size_t next_request_index() const { return next_request_index_; } |
|
Peter Beverloo
2017/03/25 03:38:50
Instead of maintaining this here, have you conside
harkness
2017/03/26 16:13:18
Fundamentally, the class that says "ok, I just fin
Peter Beverloo
2017/03/26 22:32:39
Yes, but why does the JobController need to know *
harkness
2017/03/27 07:32:38
I don't think the JobController should know anythi
|
| + |
| + void AddActiveRequest(std::unique_ptr<BackgroundFetchRequestInfo> request); |
| + BackgroundFetchRequestInfo* GetActiveRequest( |
| + const std::string& request_guid) const; |
| + void RemoveActiveRequest(const std::string& request_guid); |
| + |
| private: |
| std::string guid_; |
| std::string tag_; |
| @@ -42,11 +67,20 @@ class CONTENT_EXPORT BackgroundFetchJobInfo { |
| int64_t service_worker_registration_id_ = kInvalidServiceWorkerRegistrationId; |
| std::vector<std::string> request_guids_; |
| + // Tracking information for currently executing requests. |
| + base::flat_set<std::unique_ptr<BackgroundFetchRequestInfo>> active_requests_; |
| + size_t num_requests_ = INT_MAX; |
| + size_t next_request_index_ = 0; |
| + |
| // TODO(harkness): Other things this class should track: estimated download |
| // size, current download size, total number of files, number of complete |
| // files, (possibly) data to show the notification, (possibly) list of in |
| // progress FetchRequests. |
| + // This value will be non-null only when the job is complete and the response |
| + // to the caller is being assembled. |
| + std::unique_ptr<BackgroundFetchJobResponseData> job_response_data_; |
| + |
| DISALLOW_COPY_AND_ASSIGN(BackgroundFetchJobInfo); |
| }; |