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

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

Issue 2063533002: Rewrite enum in MACRO_STYLE (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Change enum name to match ios convention Created 4 years, 6 months 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_SNAPSHOT_CONTROLLER_H_
6 #define COMPONENTS_OFFLINE_PAGES_SNAPSHOT_CONTROLLER_H_ 6 #define COMPONENTS_OFFLINE_PAGES_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 // kStateReady - listening to input, will start snapshot when needed. 28 enum class State {
29 // kStateSnapshotPending - snapshot is in progress, don't start another. 29 READY, // Listening to input, will start snapshot when needed.
30 // kStateStopped - terminal state, no snapshots until reset. 30 SNAPSHOT_PENDING, // Snapshot is in progress, don't start another.
31 enum class State { kReady, kSnapshotPending, kStopped }; 31 STOPPED, // Terminal state, no snapshots until reset.
32 };
32 33
33 // Client of the SnapshotController. 34 // Client of the SnapshotController.
34 class Client { 35 class Client {
35 public: 36 public:
36 // 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
37 // times, but not in overlapping manner - waits until 38 // times, but not in overlapping manner - waits until
38 // PreviousSnapshotCompleted() before the next StatrSnapshot(). 39 // PreviousSnapshotCompleted() before the next StatrSnapshot().
39 // 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,
40 // it is assumed that later snapshots are better then previous. 41 // it is assumed that later snapshots are better then previous.
41 virtual void StartSnapshot() = 0; 42 virtual void StartSnapshot() = 0;
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 SnapshotController::State state_; 79 SnapshotController::State state_;
79 80
80 base::WeakPtrFactory<SnapshotController> weak_ptr_factory_; 81 base::WeakPtrFactory<SnapshotController> weak_ptr_factory_;
81 82
82 DISALLOW_COPY_AND_ASSIGN(SnapshotController); 83 DISALLOW_COPY_AND_ASSIGN(SnapshotController);
83 }; 84 };
84 85
85 } // namespace offline_pages 86 } // namespace offline_pages
86 87
87 #endif // COMPONENTS_OFFLINE_PAGES_SNAPSHOT_CONTROLLER_H_ 88 #endif // COMPONENTS_OFFLINE_PAGES_SNAPSHOT_CONTROLLER_H_
OLDNEW
« no previous file with comments | « components/offline_pages/background/save_page_request_unittest.cc ('k') | components/offline_pages/snapshot_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698