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