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

Unified Diff: components/offline_pages/background/get_requests_task.cc

Issue 2517383008: [Offline pages] Adding GetRequestsTask to RequestQueue (Closed)
Patch Set: Addressing CR feedback Created 4 years, 1 month 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: components/offline_pages/background/get_requests_task.cc
diff --git a/components/offline_pages/background/get_requests_task.cc b/components/offline_pages/background/get_requests_task.cc
new file mode 100644
index 0000000000000000000000000000000000000000..b1f20211a7f46dbbc35318e78e7d07296a3bc8ea
--- /dev/null
+++ b/components/offline_pages/background/get_requests_task.cc
@@ -0,0 +1,36 @@
+// Copyright 2016 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 "components/offline_pages/background/get_requests_task.h"
+
+#include <vector>
+
+#include "base/bind.h"
+
+namespace offline_pages {
+
+GetRequestsTask::GetRequestsTask(
+ RequestQueueStore* store,
+ const RequestQueueStore::GetRequestsCallback& callback)
+ : store_(store), callback_(callback), weak_ptr_factory_(this) {}
+
+GetRequestsTask::~GetRequestsTask() {}
+
+void GetRequestsTask::Run() {
+ ReadRequest();
+}
+
+void GetRequestsTask::ReadRequest() {
+ store_->GetRequests(base::Bind(&GetRequestsTask::CompleteWithResult,
+ weak_ptr_factory_.GetWeakPtr()));
+}
+
+void GetRequestsTask::CompleteWithResult(
+ bool success,
+ std::vector<std::unique_ptr<SavePageRequest>> requests) {
+ callback_.Run(success, std::move(requests));
+ TaskComplete();
+}
+
+} // namespace offline_pages

Powered by Google App Engine
This is Rietveld 408576698