OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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_OFFLINE_PAGE_TEST_ARCHIVER_H_ | 5 #ifndef COMPONENTS_OFFLINE_PAGES_OFFLINE_PAGE_TEST_ARCHIVER_H_ |
6 #define COMPONENTS_OFFLINE_PAGES_OFFLINE_PAGE_TEST_ARCHIVER_H_ | 6 #define COMPONENTS_OFFLINE_PAGES_OFFLINE_PAGE_TEST_ARCHIVER_H_ |
7 | 7 |
| 8 #include <stddef.h> |
| 9 #include <stdint.h> |
| 10 |
8 #include "base/macros.h" | 11 #include "base/macros.h" |
9 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
10 #include "base/single_thread_task_runner.h" | 13 #include "base/single_thread_task_runner.h" |
11 #include "components/offline_pages/offline_page_archiver.h" | 14 #include "components/offline_pages/offline_page_archiver.h" |
12 | 15 |
13 class GURL; | 16 class GURL; |
14 | 17 |
15 namespace base { | 18 namespace base { |
16 class FilePath; | 19 class FilePath; |
17 } // namespace | 20 } // namespace |
(...skipping 10 matching lines...) Expand all Loading... |
28 public: | 31 public: |
29 virtual ~Observer() {} | 32 virtual ~Observer() {} |
30 virtual void SetLastPathCreatedByArchiver( | 33 virtual void SetLastPathCreatedByArchiver( |
31 const base::FilePath& file_path) = 0; | 34 const base::FilePath& file_path) = 0; |
32 }; | 35 }; |
33 | 36 |
34 OfflinePageTestArchiver( | 37 OfflinePageTestArchiver( |
35 Observer* observer, | 38 Observer* observer, |
36 const GURL& url, | 39 const GURL& url, |
37 ArchiverResult result, | 40 ArchiverResult result, |
38 int64 size_to_report, | 41 int64_t size_to_report, |
39 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner); | 42 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner); |
40 ~OfflinePageTestArchiver() override; | 43 ~OfflinePageTestArchiver() override; |
41 | 44 |
42 // OfflinePageArchiver implementation: | 45 // OfflinePageArchiver implementation: |
43 void CreateArchive(const base::FilePath& archives_dir, | 46 void CreateArchive(const base::FilePath& archives_dir, |
44 const CreateArchiveCallback& callback) override; | 47 const CreateArchiveCallback& callback) override; |
45 | 48 |
46 // Completes the creation of archive. Should be used with |set_delayed| set to | 49 // Completes the creation of archive. Should be used with |set_delayed| set to |
47 // ture. | 50 // ture. |
48 void CompleteCreateArchive(); | 51 void CompleteCreateArchive(); |
49 | 52 |
50 // When set to true, |CompleteCreateArchive| should be called explicitly for | 53 // When set to true, |CompleteCreateArchive| should be called explicitly for |
51 // the process to finish. | 54 // the process to finish. |
52 // TODO(fgorski): See if we can move this to the constructor. | 55 // TODO(fgorski): See if we can move this to the constructor. |
53 void set_delayed(bool delayed) { delayed_ = delayed; } | 56 void set_delayed(bool delayed) { delayed_ = delayed; } |
54 | 57 |
55 // Allows to explicitly specify a file name for the tests. | 58 // Allows to explicitly specify a file name for the tests. |
56 // TODO(fgorski): See if we can move this to the constructor. | 59 // TODO(fgorski): See if we can move this to the constructor. |
57 void set_filename(const base::FilePath& filename) { filename_ = filename; } | 60 void set_filename(const base::FilePath& filename) { filename_ = filename; } |
58 | 61 |
59 bool create_archive_called() const { return create_archive_called_; } | 62 bool create_archive_called() const { return create_archive_called_; } |
60 | 63 |
61 private: | 64 private: |
62 // Not owned. Outlives OfflinePageTestArchiver. | 65 // Not owned. Outlives OfflinePageTestArchiver. |
63 Observer* observer_; | 66 Observer* observer_; |
64 GURL url_; | 67 GURL url_; |
65 base::FilePath archives_dir_; | 68 base::FilePath archives_dir_; |
66 base::FilePath filename_; | 69 base::FilePath filename_; |
67 ArchiverResult result_; | 70 ArchiverResult result_; |
68 int64 size_to_report_; | 71 int64_t size_to_report_; |
69 bool create_archive_called_; | 72 bool create_archive_called_; |
70 bool delayed_; | 73 bool delayed_; |
71 CreateArchiveCallback callback_; | 74 CreateArchiveCallback callback_; |
72 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; | 75 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; |
73 | 76 |
74 DISALLOW_COPY_AND_ASSIGN(OfflinePageTestArchiver); | 77 DISALLOW_COPY_AND_ASSIGN(OfflinePageTestArchiver); |
75 }; | 78 }; |
76 | 79 |
77 } // namespace offline_pages | 80 } // namespace offline_pages |
78 | 81 |
79 #endif // COMPONENTS_OFFLINE_PAGES_OFFLINE_PAGE_TEST_ARCHIVER_H_ | 82 #endif // COMPONENTS_OFFLINE_PAGES_OFFLINE_PAGE_TEST_ARCHIVER_H_ |
OLD | NEW |