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

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

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.cc
diff --git a/content/browser/background_fetch/background_fetch_job_info.cc b/content/browser/background_fetch/background_fetch_job_info.cc
index 71c33ab5158799a1a6321243b29ceacf6539c85a..5cb1e7cb63e9a91672a16090501a181e5d14c600 100644
--- a/content/browser/background_fetch/background_fetch_job_info.cc
+++ b/content/browser/background_fetch/background_fetch_job_info.cc
@@ -6,6 +6,9 @@
#include "base/guid.h"
+#include "content/browser/background_fetch/background_fetch_job_response_data.h"
+#include "content/browser/background_fetch/background_fetch_request_info.h"
+
namespace content {
BackgroundFetchJobInfo::BackgroundFetchJobInfo(
@@ -19,4 +22,43 @@ BackgroundFetchJobInfo::BackgroundFetchJobInfo(
BackgroundFetchJobInfo::~BackgroundFetchJobInfo() = default;
+void BackgroundFetchJobInfo::set_job_response_data(
+ std::unique_ptr<BackgroundFetchJobResponseData> job_response_data) {
+ job_response_data_ = std::move(job_response_data);
+}
+
+bool BackgroundFetchJobInfo::IsComplete() const {
+ return !HasRequestsRemaining() && active_requests_.empty();
+}
+
+bool BackgroundFetchJobInfo::HasRequestsRemaining() const {
+ return next_request_index_ != num_requests_;
+}
+
+void BackgroundFetchJobInfo::AddActiveRequest(
+ std::unique_ptr<BackgroundFetchRequestInfo> request) {
+ active_requests_.insert(std::move(request));
+ next_request_index_++;
+}
+
+BackgroundFetchRequestInfo* BackgroundFetchJobInfo::GetActiveRequest(
+ const std::string& request_guid) const {
+ for (auto& request : active_requests_) {
+ if (request->guid() == request_guid)
+ return request.get();
+ }
+ return nullptr;
+}
+
+void BackgroundFetchJobInfo::RemoveActiveRequest(
+ const std::string& request_guid) {
+ // active_requests_.erase(request_guid);
+ for (const auto& request : active_requests_) {
+ if (request->guid() == request_guid) {
+ active_requests_.erase(request);
+ return;
+ }
+ }
+}
+
} // namespace content

Powered by Google App Engine
This is Rietveld 408576698