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

Unified Diff: content/browser/background_fetch/background_fetch_job_response_data.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_response_data.cc
diff --git a/content/browser/background_fetch/background_fetch_job_response_data.cc b/content/browser/background_fetch/background_fetch_job_response_data.cc
new file mode 100644
index 0000000000000000000000000000000000000000..939d80a956c852beb5e9fbe3cde99eb405a06c20
--- /dev/null
+++ b/content/browser/background_fetch/background_fetch_job_response_data.cc
@@ -0,0 +1,33 @@
+// 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.
+
+#include "content/browser/background_fetch/background_fetch_job_response_data.h"
+
+namespace content {
+
+BackgroundFetchJobResponseData::BackgroundFetchJobResponseData(
+ size_t num_requests,
+ const BackgroundFetchResponseCompleteCallback& completion_callback)
+ : blobs_(num_requests),
+ num_requests_(num_requests),
+ completion_callback_(std::move(completion_callback)) {}
+
+BackgroundFetchJobResponseData::~BackgroundFetchJobResponseData() {}
+
+void BackgroundFetchJobResponseData::AddResponse(
+ int request_num,
+ std::unique_ptr<BlobHandle> response) {
+ blobs_[request_num] = std::move(response);
+ completed_requests_++;
+
+ if (completed_requests_ == num_requests_) {
+ std::move(completion_callback_).Run(std::move(blobs_));
+ }
+}
+
+bool BackgroundFetchJobResponseData::IsComplete() {
+ return completed_requests_ == num_requests_;
+}
+
+} // namespace content

Powered by Google App Engine
This is Rietveld 408576698