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

Unified Diff: content/browser/background_fetch/background_fetch_job_info.h

Issue 2767373002: Implement GetJobResponse and merge JobData into DataManager. (Closed)
Patch Set: Removed typedef and added DISALLOW_COPY_AND_ASSIGN 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 side-by-side diff with in-line comments
Download patch
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_; }
+
+ 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);
};

Powered by Google App Engine
This is Rietveld 408576698