| 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/core/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/core/background/save_page_request.h" | 9 #include "components/offline_pages/core/background/save_page_request.h" |
| 10 | 10 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 | 27 |
| 28 // Post the callback on the run loop. | 28 // Post the callback on the run loop. |
| 29 if (enable_callback_) { | 29 if (enable_callback_) { |
| 30 base::ThreadTaskRunnerHandle::Get()->PostTask( | 30 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 31 FROM_HERE, | 31 FROM_HERE, |
| 32 base::Bind(callback, request, Offliner::RequestStatus::SAVED)); | 32 base::Bind(callback, request, Offliner::RequestStatus::SAVED)); |
| 33 } | 33 } |
| 34 return true; | 34 return true; |
| 35 } | 35 } |
| 36 | 36 |
| 37 void OfflinerStub::Cancel() { | 37 void OfflinerStub::Cancel(const CancelCallback& callback) { |
| 38 cancel_called_ = true; | 38 cancel_called_ = true; |
| 39 callback.Run(0LL); |
| 39 } | 40 } |
| 40 | 41 |
| 41 bool OfflinerStub::HandleTimeout(const SavePageRequest& request) { | 42 bool OfflinerStub::HandleTimeout(const SavePageRequest& request) { |
| 42 if (snapshot_on_last_retry_) { | 43 if (snapshot_on_last_retry_) { |
| 43 base::ThreadTaskRunnerHandle::Get()->PostTask( | 44 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 44 FROM_HERE, | 45 FROM_HERE, |
| 45 base::Bind(callback_, request, Offliner::RequestStatus::SAVED)); | 46 base::Bind(callback_, request, Offliner::RequestStatus::SAVED)); |
| 46 return true; | 47 return true; |
| 47 } | 48 } |
| 48 return false; | 49 return false; |
| 49 } | 50 } |
| 50 | 51 |
| 51 } // namespace offline_pages | 52 } // namespace offline_pages |
| OLD | NEW |