| 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_MARK_ATTEMPT_STARTED_TASK_H_ | 5 #ifndef COMPONENTS_OFFLINE_PAGES_BACKGROUND_MARK_ATTEMPT_STARTED_TASK_H_ |
| 6 #define COMPONENTS_OFFLINE_PAGES_BACKGROUND_MARK_ATTEMPT_STARTED_TASK_H_ | 6 #define COMPONENTS_OFFLINE_PAGES_BACKGROUND_MARK_ATTEMPT_STARTED_TASK_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 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" | 10 #include "components/offline_pages/background/request_queue_store.h" |
| 16 #include "components/offline_pages/background/save_page_request.h" | 11 #include "components/offline_pages/background/update_request_task.h" |
| 17 #include "components/offline_pages/core/task.h" | 12 #include "components/offline_pages/core/task.h" |
| 18 | 13 |
| 19 namespace offline_pages { | 14 namespace offline_pages { |
| 20 | 15 |
| 21 class MarkAttemptStartedTask : public Task { | 16 class MarkAttemptStartedTask : public UpdateRequestTask { |
| 22 public: | 17 public: |
| 23 MarkAttemptStartedTask(RequestQueueStore* store, | 18 MarkAttemptStartedTask(RequestQueueStore* store, |
| 24 int64_t request_id, | 19 int64_t request_id, |
| 25 const RequestQueueStore::UpdateCallback& callback); | 20 const RequestQueueStore::UpdateCallback& callback); |
| 26 ~MarkAttemptStartedTask() override; | 21 ~MarkAttemptStartedTask() override; |
| 27 | 22 |
| 28 // TaskQueue::Task implementation. | 23 protected: |
| 29 void Run() override; | 24 // UpdateRequestTask implementation: |
| 30 | 25 void UpdateRequestImpl(std::unique_ptr<UpdateRequestsResult> result) override; |
| 31 private: | |
| 32 // Step 1. Reading the requests. | |
| 33 void ReadRequest(); | |
| 34 // Step 2. Verifies item exists, marks started and saves. | |
| 35 void MarkAttemptStarted(std::unique_ptr<UpdateRequestsResult> result); | |
| 36 // Step 3. Completes once update is done. | |
| 37 void CompleteWithResult(std::unique_ptr<UpdateRequestsResult> result); | |
| 38 | |
| 39 // Store that this task updates. Not owned. | |
| 40 RequestQueueStore* store_; | |
| 41 // Request ID of the request to be started. | |
| 42 int64_t request_id_; | |
| 43 // Callback to complete the task. | |
| 44 RequestQueueStore::UpdateCallback callback_; | |
| 45 | |
| 46 base::WeakPtrFactory<MarkAttemptStartedTask> weak_ptr_factory_; | |
| 47 DISALLOW_COPY_AND_ASSIGN(MarkAttemptStartedTask); | |
| 48 }; | 26 }; |
| 49 | 27 |
| 50 } // namespace offline_pages | 28 } // namespace offline_pages |
| 51 | 29 |
| 52 #endif // COMPONENTS_OFFLINE_PAGES_BACKGROUND_MARK_ATTEMPT_STARTED_TASK_H_ | 30 #endif // COMPONENTS_OFFLINE_PAGES_BACKGROUND_MARK_ATTEMPT_STARTED_TASK_H_ |
| OLD | NEW |