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_BACKGROUND_REMOVE_REQUESTS_TASK_H_ | |
6 #define COMPONENTS_OFFLINE_PAGES_BACKGROUND_REMOVE_REQUESTS_TASK_H_ | |
7 | |
8 #include <stdint.h> | |
9 | |
10 #include <memory> | |
11 #include <vector> | |
12 | |
13 #include "base/memory/weak_ptr.h" | |
14 #include "components/offline_pages/background/request_queue_store.h" | |
15 #include "components/offline_pages/background/save_page_request.h" | |
16 #include "components/offline_pages/core/task.h" | |
17 | |
18 namespace offline_pages { | |
19 | |
20 class RemoveRequestsTask : public Task { | |
21 public: | |
22 RemoveRequestsTask(RequestQueueStore* store, | |
23 const std::vector<int64_t>& request_ids, | |
24 const RequestQueueStore::UpdateCallback& callback); | |
25 ~RemoveRequestsTask() override; | |
26 | |
27 // TaskQueue::Task implementation. | |
28 void Run() override; | |
29 | |
30 private: | |
31 // Step 1. Removes requests from the store. | |
32 void RemoveRequests(); | |
33 // Step for early termination, that builds failure result. | |
34 void CompleteEarly(ItemActionStatus status); | |
35 // Step 2. Processes update result, calls callback. | |
36 void CompleteWithResult(std::unique_ptr<UpdateRequestsResult> result); | |
37 | |
38 // Store that this task updates. | |
39 RequestQueueStore* store_; | |
40 // Request IDs to be updated. | |
41 // TODO(fgorski): perhaps convert to unique_ptr to a vector. | |
42 std::vector<int64_t> request_ids_; | |
43 // Callback to complete the task. | |
44 RequestQueueStore::UpdateCallback callback_; | |
45 | |
46 base::WeakPtrFactory<RemoveRequestsTask> weak_ptr_factory_; | |
47 | |
48 DISALLOW_COPY_AND_ASSIGN(RemoveRequestsTask); | |
49 }; | |
50 | |
51 } // namespace offline_pages | |
52 | |
53 #endif // COMPONENTS_OFFLINE_PAGES_BACKGROUND_REMOVE_REQUESTS_TASK_H_ | |
OLD | NEW |