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

Side by Side Diff: components/offline_pages/core/background/reconcile_task.h

Issue 2568613002: Reconcile the request queue on startup. (Closed)
Patch Set: compile fix 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 unified diff | Download patch
OLDNEW
(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 offlining when chrome died, and change the state back to
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_
OLDNEW
« no previous file with comments | « components/offline_pages/core/background/cleanup_task.cc ('k') | components/offline_pages/core/background/reconcile_task.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698