Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef COMPONENTS_OFFLINE_PAGES_CORE_BACKGROUND_RECONCILE_TASK_H_ | |
| 6 #define COMPONENTS_OFFLINE_PAGES_CORE_BACKGROUND_RECONCILE_TASK_H_ | |
| 7 | |
| 8 #include <memory> | |
| 9 #include <vector> | |
| 10 | |
| 11 #include "base/memory/weak_ptr.h" | |
| 12 #include "components/offline_pages/core/background/request_queue_store.h" | |
| 13 #include "components/offline_pages/core/background/save_page_request.h" | |
| 14 #include "components/offline_pages/core/task.h" | |
| 15 | |
| 16 namespace offline_pages { | |
| 17 | |
| 18 // The reconcile task should be run at request coordinator startup to find any | |
| 19 // tasks that were prerendering when chrome died, and change the state back to | |
|
dougarnett
2016/12/15 20:30:09
prerendering => offlining
Pete Williamson
2016/12/15 20:50:24
Done.
| |
| 20 // available. | |
| 21 class ReconcileTask : public Task { | |
| 22 public: | |
| 23 ReconcileTask(RequestQueueStore* store, | |
| 24 const RequestQueueStore::UpdateCallback& callback); | |
| 25 ~ReconcileTask() override; | |
| 26 | |
| 27 // TaskQueue::Task implementation: | |
| 28 // Starts the async chain. | |
| 29 void Run() override; | |
| 30 | |
| 31 private: | |
| 32 // Step 1. Get results from the store. | |
| 33 void GetRequests(); | |
| 34 | |
| 35 // Step 2. Flip OFFLINING requests to AVAILABLE and put back in queue. | |
| 36 void Reconcile(bool success, | |
| 37 std::vector<std::unique_ptr<SavePageRequest>> requests); | |
| 38 | |
| 39 // Step 3. Processes update result. | |
| 40 void UpdateCompleted(std::unique_ptr<UpdateRequestsResult> update_result); | |
| 41 | |
| 42 // Member variables, all pointers are not owned here. | |
| 43 RequestQueueStore* store_; | |
| 44 // Callback to complete the task. | |
| 45 RequestQueueStore::UpdateCallback callback_; | |
| 46 // Allows us to pass a weak pointer to callbacks. | |
| 47 base::WeakPtrFactory<ReconcileTask> weak_ptr_factory_; | |
| 48 }; | |
| 49 | |
| 50 } // namespace offline_pages | |
| 51 | |
| 52 #endif // COMPONENTS_OFFLINE_PAGES_CORE_BACKGROUND_RECONCILE_TASK_H_ | |
| OLD | NEW |