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

Side by Side Diff: components/offline_pages/core/snapshot_controller.h

Issue 2489443002: Move all components/offline_pages/ files into component/offline_pages/core (Closed)
Patch Set: rebase Created 4 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
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_SNAPSHOT_CONTROLLER_H_ 5 #ifndef COMPONENTS_OFFLINE_PAGES_CORE_SNAPSHOT_CONTROLLER_H_
6 #define COMPONENTS_OFFLINE_PAGES_SNAPSHOT_CONTROLLER_H_ 6 #define COMPONENTS_OFFLINE_PAGES_CORE_SNAPSHOT_CONTROLLER_H_
7 7
8 #include "base/memory/ref_counted.h" 8 #include "base/memory/ref_counted.h"
9 #include "base/memory/weak_ptr.h" 9 #include "base/memory/weak_ptr.h"
10 #include "base/single_thread_task_runner.h" 10 #include "base/single_thread_task_runner.h"
11 11
12 namespace offline_pages { 12 namespace offline_pages {
13 13
14 // Takes various signals and produces StartSnapshot calls following a specific 14 // Takes various signals and produces StartSnapshot calls following a specific
15 // policy. Can request snapshots multiple times per 'session'. Session can be 15 // policy. Can request snapshots multiple times per 'session'. Session can be
16 // ended and another one started by calling Reset(). 16 // ended and another one started by calling Reset().
17 // Main invariants: 17 // Main invariants:
18 // - It never starts overlapping snapshots, Client reports when previous 18 // - It never starts overlapping snapshots, Client reports when previous
19 // snapshot is done. 19 // snapshot is done.
20 // - The currently worked on (pending) snapshot is always allowed to complete, 20 // - The currently worked on (pending) snapshot is always allowed to complete,
21 // the new attempts to start a snapshot are ignored until it does. 21 // the new attempts to start a snapshot are ignored until it does.
22 // - Some signals prevent more snapshots to be taken. 22 // - Some signals prevent more snapshots to be taken.
23 // OnLoad is currently such signal. 23 // OnLoad is currently such signal.
24 // - Once Reset() is called on the SnapshotController, the delayed tasks are 24 // - Once Reset() is called on the SnapshotController, the delayed tasks are
25 // reset so no StartSnapshot calls is made 'cross-session'. 25 // reset so no StartSnapshot calls is made 'cross-session'.
26 class SnapshotController { 26 class SnapshotController {
27 public: 27 public:
28 enum class State { 28 enum class State {
29 READY, // Listening to input, will start snapshot when needed. 29 READY, // Listening to input, will start snapshot when needed.
30 SNAPSHOT_PENDING, // Snapshot is in progress, don't start another. 30 SNAPSHOT_PENDING, // Snapshot is in progress, don't start another.
31 STOPPED, // Terminal state, no snapshots until reset. 31 STOPPED, // Terminal state, no snapshots until reset.
32 }; 32 };
33 33
34 // Client of the SnapshotController. 34 // Client of the SnapshotController.
35 class Client { 35 class Client {
36 public: 36 public:
37 // Invoked at a good moment to start a snapshot. May be invoked multiple 37 // Invoked at a good moment to start a snapshot. May be invoked multiple
38 // times, but not in overlapping manner - waits until 38 // times, but not in overlapping manner - waits until
39 // PreviousSnapshotCompleted() before the next StatrSnapshot(). 39 // PreviousSnapshotCompleted() before the next StatrSnapshot().
40 // Client should overwrite the result of previous snapshot with the new one, 40 // Client should overwrite the result of previous snapshot with the new one,
41 // it is assumed that later snapshots are better then previous. 41 // it is assumed that later snapshots are better then previous.
42 virtual void StartSnapshot() = 0; 42 virtual void StartSnapshot() = 0;
43 43
44 protected: 44 protected:
45 virtual ~Client() {} 45 virtual ~Client() {}
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 size_t delay_after_document_available_ms_; 87 size_t delay_after_document_available_ms_;
88 size_t delay_after_document_on_load_completed_ms_; 88 size_t delay_after_document_on_load_completed_ms_;
89 89
90 base::WeakPtrFactory<SnapshotController> weak_ptr_factory_; 90 base::WeakPtrFactory<SnapshotController> weak_ptr_factory_;
91 91
92 DISALLOW_COPY_AND_ASSIGN(SnapshotController); 92 DISALLOW_COPY_AND_ASSIGN(SnapshotController);
93 }; 93 };
94 94
95 } // namespace offline_pages 95 } // namespace offline_pages
96 96
97 #endif // COMPONENTS_OFFLINE_PAGES_SNAPSHOT_CONTROLLER_H_ 97 #endif // COMPONENTS_OFFLINE_PAGES_CORE_SNAPSHOT_CONTROLLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698