Chromium Code Reviews| Index: content/browser/background_fetch/background_fetch_job_data.h |
| diff --git a/content/browser/background_fetch/background_fetch_job_data.h b/content/browser/background_fetch/background_fetch_job_data.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..dc4e1c570e60cf3853424d99811538077d34fa2c |
| --- /dev/null |
| +++ b/content/browser/background_fetch/background_fetch_job_data.h |
| @@ -0,0 +1,54 @@ |
| +// Copyright 2017 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef CONTENT_BROWSER_BACKGROUND_FETCH_BACKGROUND_FETCH_JOB_DATA_H_ |
| +#define CONTENT_BROWSER_BACKGROUND_FETCH_BACKGROUND_FETCH_JOB_DATA_H_ |
| + |
| +#include <string> |
| +#include <unordered_map> |
| + |
| +#include "base/macros.h" |
| +#include "content/browser/background_fetch/background_fetch_request_info.h" |
| +#include "content/common/content_export.h" |
| +#include "url/origin.h" |
| + |
| +namespace content { |
| + |
| +// The BackgroundFetchJobData class provides the interface from the |
| +// JobController to the data storage in the DataManager. It has a reference |
| +// to the DataManager and invokes calls given the stored batch_guid. |
| +class CONTENT_EXPORT BackgroundFetchJobData { |
| + public: |
| + BackgroundFetchJobData(BackgroundFetchRequestInfos& request_infos); |
|
Peter Beverloo
2017/02/28 03:32:54
explicit
harkness
2017/02/28 11:31:08
Done.
|
| + ~BackgroundFetchJobData(); |
| + |
| + // Called by the JobController to inform the JobData that the given fetch |
| + // has completed. The JobData returns a boolean indicating whether there |
| + // are more requests to process. |
| + bool BackgroundFetchRequestInfoComplete(const std::string& fetch_uid); |
| + |
| + // Called by the JobController to get a BackgroundFetchRequestInfo to |
| + // process. |
| + const BackgroundFetchRequestInfo& GetNextBackgroundFetchRequestInfo(); |
| + |
| + // Indicates whether all requests have been handed to the JobController. |
| + bool HasRequestsRemaining() const; |
| + |
| + // Indicates whether all requests have been handed out and completed. |
| + bool IsComplete() const; |
| + |
| + private: |
| + BackgroundFetchRequestInfos request_infos_; |
| + |
| + // Map from fetch_uid to index in request_infos_. Only currently |
|
Peter Beverloo
2017/02/28 03:32:54
fetch_guid
harkness
2017/02/28 11:31:08
Done.
|
| + // outstanding requests should be in this map. |
| + std::unordered_map<std::string, int> request_info_index_; |
| + size_t next_request_info_ = 0; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(BackgroundFetchJobData); |
| +}; |
| + |
| +} // namespace content |
| + |
| +#endif // CONTENT_BROWSER_BACKGROUND_FETCH_BACKGROUND_FETCH_JOB_DATA_H_ |