| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef COMPONENTS_OFFLINE_PAGES_BACKGROUND_CHANGE_REQUESTS_STATE_TASK_H_ | 5 #ifndef COMPONENTS_OFFLINE_PAGES_BACKGROUND_CHANGE_REQUESTS_STATE_TASK_H_ |
| 6 #define COMPONENTS_OFFLINE_PAGES_BACKGROUND_CHANGE_REQUESTS_STATE_TASK_H_ | 6 #define COMPONENTS_OFFLINE_PAGES_BACKGROUND_CHANGE_REQUESTS_STATE_TASK_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 const SavePageRequest::RequestState new_state, | 25 const SavePageRequest::RequestState new_state, |
| 26 const RequestQueueStore::UpdateCallback& callback); | 26 const RequestQueueStore::UpdateCallback& callback); |
| 27 ~ChangeRequestsStateTask() override; | 27 ~ChangeRequestsStateTask() override; |
| 28 | 28 |
| 29 // TaskQueue::Task implementation. | 29 // TaskQueue::Task implementation. |
| 30 void Run() override; | 30 void Run() override; |
| 31 | 31 |
| 32 private: | 32 private: |
| 33 // Step 1. Reading the requests. | 33 // Step 1. Reading the requests. |
| 34 void ReadRequests(); | 34 void ReadRequests(); |
| 35 // Step 2. Selecting requests to be updated. Calls update. | 35 // Step 2. Updates available requests. |
| 36 void SelectItemsToUpdate( | 36 void UpdateRequests(std::unique_ptr<UpdateRequestsResult> read_result); |
| 37 bool success, | |
| 38 std::vector<std::unique_ptr<SavePageRequest>> requests); | |
| 39 // Step 3. Processes update result, calls callback. | 37 // Step 3. Processes update result, calls callback. |
| 40 void UpdateCompleted(std::unique_ptr<UpdateRequestsResult> update_result); | 38 void UpdateCompleted(std::unique_ptr<UpdateRequestsResult> update_result); |
| 41 | 39 |
| 42 // Completions. | |
| 43 void CompleteEarly(ItemActionStatus status); | |
| 44 void CompleteWithStatus(std::unique_ptr<UpdateRequestsResult> result, | |
| 45 ItemActionStatus status); | |
| 46 | |
| 47 // Store that this task updates. | 40 // Store that this task updates. |
| 48 RequestQueueStore* store_; | 41 RequestQueueStore* store_; |
| 49 // Request IDs to be updated. | 42 // Request IDs to be updated. Kept as a set to remove duplicates and simplify |
| 43 // the look up of requests that are not found in step 3. |
| 50 std::unordered_set<int64_t> request_ids_; | 44 std::unordered_set<int64_t> request_ids_; |
| 51 // New state to be set on all entries. | 45 // New state to be set on all entries. |
| 52 SavePageRequest::RequestState new_state_; | 46 SavePageRequest::RequestState new_state_; |
| 53 // Callback to complete the task. | 47 // Callback to complete the task. |
| 54 RequestQueueStore::UpdateCallback callback_; | 48 RequestQueueStore::UpdateCallback callback_; |
| 55 | 49 |
| 56 base::WeakPtrFactory<ChangeRequestsStateTask> weak_ptr_factory_; | 50 base::WeakPtrFactory<ChangeRequestsStateTask> weak_ptr_factory_; |
| 57 | 51 |
| 58 DISALLOW_COPY_AND_ASSIGN(ChangeRequestsStateTask); | 52 DISALLOW_COPY_AND_ASSIGN(ChangeRequestsStateTask); |
| 59 }; | 53 }; |
| 60 | 54 |
| 61 } // namespace offline_pages | 55 } // namespace offline_pages |
| 62 | 56 |
| 63 #endif // COMPONENTS_OFFLINE_PAGES_BACKGROUND_CHANGE_REQUESTS_STATE_TASK_H_ | 57 #endif // COMPONENTS_OFFLINE_PAGES_BACKGROUND_CHANGE_REQUESTS_STATE_TASK_H_ |
| OLD | NEW |