Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(632)

Side by Side Diff: components/offline_pages/offline_page_test_archiver.h

Issue 1504243002: [Offline pages] Refactoring helper classes out from offline_page_model_unittest.cc (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixing gn build and addressing comments Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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 // Completes the creation of archive. Should be used with |set_delayed| set to
45 // ture.
46 void CompleteCreateArchive();
47
48 // When set to true, |CompleteCreateArchive| should be called explicitly for
49 // the process to finish.
50 void set_delayed(bool delayed) { delayed_ = delayed; }
51
52 bool create_archive_called() const { return create_archive_called_; }
53
54 private:
55 // Not owned. Outlives OfflinePageTestArchiver.
56 Observer* observer_;
57 GURL url_;
58 base::FilePath archives_dir_;
59 ArchiverResult result_;
60 int64 size_to_report_;
61 bool create_archive_called_;
62 bool delayed_;
63 CreateArchiveCallback callback_;
64 scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
65
66 DISALLOW_COPY_AND_ASSIGN(OfflinePageTestArchiver);
67 };
68
69 } // namespace offline_pages
70
71 #endif // COMPONENTS_OFFLINE_PAGES_OFFLINE_PAGE_TEST_ARCHIVER_H_
OLDNEW
« no previous file with comments | « components/offline_pages/offline_page_model_unittest.cc ('k') | components/offline_pages/offline_page_test_archiver.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698