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 #include "components/offline_pages/background/offliner_stub.h" | |
6 | |
7 #include "base/bind.h" | |
8 #include "base/threading/thread_task_runner_handle.h" | |
9 #include "components/offline_pages/background/save_page_request.h" | |
10 | |
11 namespace offline_pages { | |
12 | |
13 OfflinerStub::OfflinerStub() | |
14 : disable_loading_(false), enable_callback_(false), cancel_called_(false) {} | |
15 | |
16 OfflinerStub::~OfflinerStub() {} | |
17 | |
18 bool OfflinerStub::LoadAndSave(const SavePageRequest& request, | |
19 const CompletionCallback& callback) { | |
20 if (disable_loading_) | |
21 return false; | |
22 | |
23 callback_ = callback; | |
24 | |
25 // Post the callback on the run loop. | |
26 if (enable_callback_) { | |
27 base::ThreadTaskRunnerHandle::Get()->PostTask( | |
28 FROM_HERE, | |
29 base::Bind(callback, request, Offliner::RequestStatus::SAVED)); | |
30 } | |
31 return true; | |
32 } | |
33 | |
34 void OfflinerStub::Cancel() { | |
35 cancel_called_ = true; | |
36 } | |
37 | |
38 } // namespace offline_pages | |
OLD | NEW |