Chromium Code Reviews| 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_ |