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

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

Issue 2489443002: Move all components/offline_pages/ files into component/offline_pages/core (Closed)
Patch Set: update Created 4 years, 1 month 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_REQUESTS_STATE_TASK_H_
6 #define COMPONENTS_OFFLINE_PAGES_BACKGROUND_CHANGE_REQUESTS_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.h"
18
19 namespace offline_pages {
20
21 class ChangeRequestsStateTask : public Task {
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 void Run() override;
31
32 private:
33 // Step 1. Reading the requests.
34 void ReadRequests();
35 // Step 2. Selecting requests to be updated. Calls update.
36 void SelectItemsToUpdate(
37 bool success,
38 std::vector<std::unique_ptr<SavePageRequest>> requests);
39 // Step 3. Processes update result, calls callback.
40 void UpdateCompleted(std::unique_ptr<UpdateRequestsResult> update_result);
41
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.
48 RequestQueueStore* store_;
49 // Request IDs to be updated.
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_REQUESTS_STATE_TASK_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698