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

Side by Side Diff: components/offline_pages/background/update_request_task.cc

Issue 2489443002: Move all components/offline_pages/ files into component/offline_pages/core (Closed)
Patch Set: more rebase Created 4 years 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 #include "components/offline_pages/background/update_request_task.h"
6
7 #include <vector>
8
9 #include "base/bind.h"
10 #include "base/time/time.h"
11
12 namespace offline_pages {
13
14 UpdateRequestTask::UpdateRequestTask(
15 RequestQueueStore* store,
16 int64_t request_id,
17 const RequestQueueStore::UpdateCallback& callback)
18 : store_(store),
19 request_id_(request_id),
20 callback_(callback),
21 weak_ptr_factory_(this) {}
22
23 UpdateRequestTask::~UpdateRequestTask() {}
24
25 void UpdateRequestTask::Run() {
26 ReadRequest();
27 }
28
29 void UpdateRequestTask::ReadRequest() {
30 std::vector<int64_t> request_ids{request_id_};
31 store_->GetRequestsByIds(request_ids,
32 base::Bind(&UpdateRequestTask::UpdateRequestImpl,
33 weak_ptr_factory_.GetWeakPtr()));
34 }
35
36 void UpdateRequestTask::CompleteWithResult(
37 std::unique_ptr<UpdateRequestsResult> result) {
38 callback_.Run(std::move(result));
39 TaskComplete();
40 }
41
42 bool UpdateRequestTask::ValidateReadResult(UpdateRequestsResult* result) {
43 return result->store_state == StoreState::LOADED &&
44 result->item_statuses.at(0).first == request_id() &&
45 result->item_statuses.at(0).second == ItemActionStatus::SUCCESS &&
46 result->updated_items.size() == 1 &&
47 result->updated_items.at(0).request_id() == request_id();
48 }
49
50 } // namespace offline_pages
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698