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