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

Side by Side Diff: components/offline_pages/background/change_requests_state_task.h

Issue 2372043002: [Offline pages] Applying TaskQueue to RequestQueue::ChangeRequestsState (Closed)
Patch Set: Created 4 years, 2 months 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_BACKGROUND_CHANGE_REQUEST_STATE_TASK_H_
6 #define COMPONENTS_OFFLINE_PAGES_BACKGROUND_CHANGE_REQUEST_STATE_TASK_H_
7
8 #include <stdint.h>
9
10 #include <memory>
11 #include <unordered_set>
12 #include <vector>
13
14 #include "base/memory/weak_ptr.h"
15 #include "components/offline_pages/background/request_queue_store.h"
16 #include "components/offline_pages/background/save_page_request.h"
17 #include "components/offline_pages/core/task_queue.h"
18
19 namespace offline_pages {
20
21 class ChangeRequestsStateTask : public TaskQueue::Task {
Pete Williamson 2016/09/27 23:49:56 Does chrome already have a way to do this It seem
fgorski 2016/09/28 22:39:06 I wasn't able to find anything like that. I think
22 public:
23 ChangeRequestsStateTask(RequestQueueStore* store,
24 const std::vector<int64_t>& request_ids,
25 const SavePageRequest::RequestState new_state,
26 const RequestQueueStore::UpdateCallback& callback);
27 ~ChangeRequestsStateTask() override;
28
29 // TaskQueue::Task implementation.
30 // Step 1. Reading the requests.
31 void Run() override;
32
33 // Step 2. Selecting requests to be updated. Calls update.
34 void SelectItemsToUpdate(
35 bool success,
36 std::vector<std::unique_ptr<SavePageRequest>> requests);
37
38 // Step 3. Processes update result, calls callback.
39 void UpdateCompleted(std::unique_ptr<UpdateRequestsResult> update_result);
40
41 private:
42 void CompleteEarly(ItemActionStatus status);
43 void CompleteWithStatus(std::unique_ptr<UpdateRequestsResult> result,
44 ItemActionStatus status);
45
46 // Store that this task updates.
47 RequestQueueStore* store_;
48 // Request IDs to be updated.
49 // TODO(fgorski): perhaps convert to unique_ptr to a vector.
Pete Williamson 2016/09/27 23:49:56 comment out of date?
fgorski 2016/09/28 22:39:06 Done
50 std::unordered_set<int64_t> request_ids_;
51 // New state to be set on all entries.
52 SavePageRequest::RequestState new_state_;
53 // Callback to complete the task.
54 RequestQueueStore::UpdateCallback callback_;
55
56 base::WeakPtrFactory<ChangeRequestsStateTask> weak_ptr_factory_;
57
58 DISALLOW_COPY_AND_ASSIGN(ChangeRequestsStateTask);
59 };
60
61 } // namespace offline_pages
62
63 #endif // COMPONENTS_OFFLINE_PAGES_BACKGROUND_CHANGE_REQUEST_STATE_TASK_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698