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_ADD_REQUEST_TASK_H_ | |
6 #define COMPONENTS_OFFLINE_PAGES_BACKGROUND_ADD_REQUEST_TASK_H_ | |
7 | |
8 #include <memory> | |
9 #include <vector> | |
10 | |
11 #include "base/memory/weak_ptr.h" | |
12 #include "components/offline_pages/background/request_queue_store.h" | |
13 #include "components/offline_pages/core/task.h" | |
14 | |
15 namespace offline_pages { | |
16 | |
17 class AddRequestTask : public Task { | |
18 public: | |
19 AddRequestTask(RequestQueueStore* store, | |
20 const SavePageRequest& request, | |
21 const RequestQueueStore::AddCallback& callback); | |
22 ~AddRequestTask() override; | |
23 | |
24 // Task implementation: | |
25 void Run() override; | |
26 | |
27 private: | |
28 // Step 1: Add the request to the store. | |
29 void AddRequest(); | |
30 // Step 2: Calls the callback with result, completes the task. | |
31 void CompleteWithResult(ItemActionStatus status); | |
32 | |
33 // Store from which requests will be read. | |
34 RequestQueueStore* store_; | |
35 // Request to be added. | |
36 SavePageRequest request_; | |
37 // Callback used to return the read results. | |
38 RequestQueueStore::AddCallback callback_; | |
39 | |
40 base::WeakPtrFactory<AddRequestTask> weak_ptr_factory_; | |
41 DISALLOW_COPY_AND_ASSIGN(AddRequestTask); | |
42 }; | |
43 | |
44 } // namespace offline_pages | |
45 | |
46 #endif // COMPONENTS_OFFLINE_PAGES_BACKGROUND_ADD_REQUEST_TASK_H_ | |
OLD | NEW |