| 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 #ifndef COMPONENTS_OFFLINE_PAGES_CORE_BACKGROUND_OFFLINER_STUB_H_ | 5 #ifndef COMPONENTS_OFFLINE_PAGES_CORE_BACKGROUND_OFFLINER_STUB_H_ |
| 6 #define COMPONENTS_OFFLINE_PAGES_CORE_BACKGROUND_OFFLINER_STUB_H_ | 6 #define COMPONENTS_OFFLINE_PAGES_CORE_BACKGROUND_OFFLINER_STUB_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 | 9 |
| 10 #include "base/callback_forward.h" | 10 #include "base/callback_forward.h" |
| 11 #include "components/offline_pages/core/background/offliner.h" | 11 #include "components/offline_pages/core/background/offliner.h" |
| 12 | 12 |
| 13 namespace offline_pages { | 13 namespace offline_pages { |
| 14 | 14 |
| 15 // Test class stubbing out the functionality of Offliner. | 15 // Test class stubbing out the functionality of Offliner. |
| 16 // It is only used for test support. | 16 // It is only used for test support. |
| 17 class OfflinerStub : public Offliner { | 17 class OfflinerStub : public Offliner { |
| 18 public: | 18 public: |
| 19 OfflinerStub(); | 19 OfflinerStub(); |
| 20 ~OfflinerStub() override; | 20 ~OfflinerStub() override; |
| 21 | 21 |
| 22 bool LoadAndSave(const SavePageRequest& request, | 22 bool LoadAndSave(const SavePageRequest& request, |
| 23 const CompletionCallback& completion_callback, | 23 const CompletionCallback& completion_callback, |
| 24 const ProgressCallback& progress_callback) override; | 24 const ProgressCallback& progress_callback) override; |
| 25 | 25 |
| 26 bool Cancel(const CancelCallback& callback) override; | 26 bool Cancel(const CancelCallback& callback) override; |
| 27 | 27 |
| 28 void TerminateLoadIfInProgress() override; |
| 29 |
| 28 bool HandleTimeout(int64_t request_id) override; | 30 bool HandleTimeout(int64_t request_id) override; |
| 29 | 31 |
| 30 void disable_loading() { disable_loading_ = true; } | 32 void disable_loading() { disable_loading_ = true; } |
| 31 | 33 |
| 32 void enable_callback(bool enable) { enable_callback_ = enable; } | 34 void enable_callback(bool enable) { enable_callback_ = enable; } |
| 33 | 35 |
| 34 bool cancel_called() { return cancel_called_; } | 36 bool cancel_called() { return cancel_called_; } |
| 35 | 37 |
| 36 void reset_cancel_called() { cancel_called_ = false; } | 38 void reset_cancel_called() { cancel_called_ = false; } |
| 37 | 39 |
| 38 void enable_snapshot_on_last_retry() { snapshot_on_last_retry_ = true; } | 40 void enable_snapshot_on_last_retry() { snapshot_on_last_retry_ = true; } |
| 39 | 41 |
| 40 private: | 42 private: |
| 41 base::Closure completion_callback_; | 43 CompletionCallback completion_callback_; |
| 42 std::unique_ptr<SavePageRequest> pending_request_; | 44 std::unique_ptr<SavePageRequest> pending_request_; |
| 43 bool disable_loading_; | 45 bool disable_loading_; |
| 44 bool enable_callback_; | 46 bool enable_callback_; |
| 45 bool cancel_called_; | 47 bool cancel_called_; |
| 46 bool snapshot_on_last_retry_; | 48 bool snapshot_on_last_retry_; |
| 47 }; | 49 }; |
| 48 | 50 |
| 49 } // namespace offline_pages | 51 } // namespace offline_pages |
| 50 | 52 |
| 51 #endif // COMPONENTS_OFFLINE_PAGES_CORE_BACKGROUND_OFFLINER_STUB_H_ | 53 #endif // COMPONENTS_OFFLINE_PAGES_CORE_BACKGROUND_OFFLINER_STUB_H_ |
| OLD | NEW |