Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef COMPONENTS_OFFLINE_PAGES_OFFLINE_PAGE_TEST_ARCHIVER_H_ | |
| 6 #define COMPONENTS_OFFLINE_PAGES_OFFLINE_PAGE_TEST_ARCHIVER_H_ | |
| 7 | |
| 8 #include "base/macros.h" | |
| 9 #include "base/memory/ref_counted.h" | |
| 10 #include "base/single_thread_task_runner.h" | |
| 11 #include "components/offline_pages/offline_page_archiver.h" | |
| 12 | |
| 13 class GURL; | |
| 14 | |
| 15 namespace base { | |
| 16 class FilePath; | |
| 17 } // namespace | |
| 18 | |
| 19 namespace offline_pages { | |
| 20 | |
| 21 // A test archiver class, which allows for testing offline pages without a need | |
| 22 // for an actual web contents. | |
| 23 class OfflinePageTestArchiver : public OfflinePageArchiver { | |
| 24 public: | |
| 25 class Observer { | |
| 26 public: | |
| 27 virtual ~Observer() {} | |
| 28 virtual void SetLastPathCreatedByArchiver( | |
| 29 const base::FilePath& file_path) = 0; | |
| 30 }; | |
| 31 | |
| 32 OfflinePageTestArchiver( | |
| 33 Observer* observer, | |
| 34 const GURL& url, | |
| 35 ArchiverResult result, | |
| 36 int64 size_to_report, | |
| 37 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner); | |
| 38 ~OfflinePageTestArchiver() override; | |
| 39 | |
| 40 // OfflinePageArchiver implementation: | |
| 41 void CreateArchive(const base::FilePath& archives_dir, | |
| 42 const CreateArchiveCallback& callback) override; | |
| 43 | |
| 44 void CompleteCreateArchive(); | |
| 45 | |
| 46 void set_delayed(bool delayed) { delayed_ = delayed; } | |
|
jianli
2015/12/07 23:19:01
Please comment on what this is meant.
fgorski
2015/12/08 00:33:56
Done.
| |
| 47 | |
| 48 bool create_archive_called() const { return create_archive_called_; } | |
| 49 | |
| 50 private: | |
| 51 // Not owned. Outlives OfflinePageTestArchiver. | |
| 52 Observer* observer_; | |
| 53 GURL url_; | |
| 54 base::FilePath archives_dir_; | |
| 55 ArchiverResult result_; | |
| 56 int64 size_to_report_; | |
| 57 bool create_archive_called_; | |
| 58 bool delayed_; | |
| 59 CreateArchiveCallback callback_; | |
| 60 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; | |
|
jianli
2015/12/07 23:19:01
nit: add empty line
fgorski
2015/12/08 00:33:55
Done.
| |
| 61 DISALLOW_COPY_AND_ASSIGN(OfflinePageTestArchiver); | |
| 62 }; | |
| 63 | |
| 64 } // namespace offline_pages | |
| 65 | |
| 66 #endif // COMPONENTS_OFFLINE_PAGES_OFFLINE_PAGE_TEST_ARCHIVER_H_ | |
| OLD | NEW |