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 bool HandleTimeout(int64_t request_id) override; | 28 bool HandleTimeout(int64_t request_id) override; |
29 | 29 |
| 30 void ObserveResourceTracking(const ResourceDataType type, |
| 31 int64_t started_count, |
| 32 int64_t completed_count) override; |
| 33 |
30 void disable_loading() { disable_loading_ = true; } | 34 void disable_loading() { disable_loading_ = true; } |
31 | 35 |
32 void enable_callback(bool enable) { enable_callback_ = enable; } | 36 void enable_callback(bool enable) { enable_callback_ = enable; } |
33 | 37 |
34 bool cancel_called() { return cancel_called_; } | 38 bool cancel_called() { return cancel_called_; } |
35 | 39 |
36 void reset_cancel_called() { cancel_called_ = false; } | 40 void reset_cancel_called() { cancel_called_ = false; } |
37 | 41 |
38 void enable_snapshot_on_last_retry() { snapshot_on_last_retry_ = true; } | 42 void enable_snapshot_on_last_retry() { snapshot_on_last_retry_ = true; } |
39 | 43 |
| 44 void GetResourcePercentageCounts(const ResourceDataType type, |
| 45 int64_t* started, |
| 46 int64_t* completed); |
| 47 |
40 private: | 48 private: |
41 base::Closure completion_callback_; | 49 base::Closure completion_callback_; |
42 std::unique_ptr<SavePageRequest> pending_request_; | 50 std::unique_ptr<SavePageRequest> pending_request_; |
43 bool disable_loading_; | 51 bool disable_loading_; |
44 bool enable_callback_; | 52 bool enable_callback_; |
45 bool cancel_called_; | 53 bool cancel_called_; |
46 bool snapshot_on_last_retry_; | 54 bool snapshot_on_last_retry_; |
| 55 int64_t started_count_; |
| 56 int64_t completed_count_; |
47 }; | 57 }; |
48 | 58 |
49 } // namespace offline_pages | 59 } // namespace offline_pages |
50 | 60 |
51 #endif // COMPONENTS_OFFLINE_PAGES_CORE_BACKGROUND_OFFLINER_STUB_H_ | 61 #endif // COMPONENTS_OFFLINE_PAGES_CORE_BACKGROUND_OFFLINER_STUB_H_ |
OLD | NEW |