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

Unified Diff: components/offline_pages/core/background/reconcile_task.h

Issue 2568613002: Reconcile the request queue on startup. (Closed)
Patch Set: Created 4 years 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/core/background/reconcile_task.h
diff --git a/components/offline_pages/core/background/reconcile_task.h b/components/offline_pages/core/background/reconcile_task.h
new file mode 100644
index 0000000000000000000000000000000000000000..9244f3aa1297c38610fcec230ca6b4b7576d73cf
--- /dev/null
+++ b/components/offline_pages/core/background/reconcile_task.h
@@ -0,0 +1,47 @@
+// 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.
+
+#ifndef COMPONENTS_OFFLINE_PAGES_CORE_BACKGROUND_RECONCILE_TASK_H_
+#define COMPONENTS_OFFLINE_PAGES_CORE_BACKGROUND_RECONCILE_TASK_H_
+
+#include <memory>
+#include <vector>
+
+#include "base/memory/weak_ptr.h"
+#include "components/offline_pages/core/background/request_queue_store.h"
+#include "components/offline_pages/core/background/save_page_request.h"
+#include "components/offline_pages/core/task.h"
+
+namespace offline_pages {
+
+class ReconcileTask : public Task {
dougarnett 2016/12/12 17:16:13 class comment please to state what it does
fgorski 2016/12/12 17:35:18 +1 Include information about when you expect the
Pete Williamson 2016/12/15 18:37:43 Done.
Pete Williamson 2016/12/15 18:37:43 Done.
+ public:
+ ReconcileTask(RequestQueueStore* store,
+ const RequestQueueStore::UpdateCallback& callback);
+ ~ReconcileTask() override;
+
+ // TaskQueue::Task implementation, starts the async chain
fgorski 2016/12/12 17:35:18 nit: add colon after implementation. Move the "Sta
Pete Williamson 2016/12/15 18:37:43 Done.
+ void Run() override;
+
+ private:
dougarnett 2016/12/12 17:16:13 nit - period at end of sentence here and Step 3 co
Pete Williamson 2016/12/15 18:37:43 Done.
+ // Step 1. Get results from the store
+ void GetRequests();
+
+ // Step 2. Flip OFFLINING requests to available and put back in queue.
dougarnett 2016/12/12 17:16:13 available => AVAILABLE to match style with OFFLINI
Pete Williamson 2016/12/15 18:37:43 Done.
+ void Reconcile(bool success,
+ std::vector<std::unique_ptr<SavePageRequest>> requests);
+
+ // Step 3. Processes update result
+ void UpdateCompleted(std::unique_ptr<UpdateRequestsResult> update_result);
fgorski 2016/12/12 17:35:18 nit: empty line after this.
Pete Williamson 2016/12/15 18:37:43 Done.
+ // Member variables, all pointers are not owned here.
+ RequestQueueStore* store_;
+ // Callback to complete the task.
+ RequestQueueStore::UpdateCallback callback_;
+ // Allows us to pass a weak pointer to callbacks.
+ base::WeakPtrFactory<ReconcileTask> weak_ptr_factory_;
+};
+
+} // namespace offline_pages
+
+#endif // COMPONENTS_OFFLINE_PAGES_CORE_BACKGROUND_RECONCILE_TASK_H_

Powered by Google App Engine
This is Rietveld 408576698