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

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: 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 // READY - listening to input, will start snapshot when needed.
29 // kStateSnapshotPending - snapshot is in progress, don't start another. 29 // SNAPSHOT_PENDING- snapshot is in progress, don't start another.
30 // kStateStopped - terminal state, no snapshots until reset. 30 // STOPPED - terminal state, no snapshots until reset.
31 enum class State { kReady, kSnapshotPending, kStopped }; 31 enum class State {
32 READY,
fgorski 2016/06/11 16:25:06 Put documentation after the definition of the enum
Vivian 2016/06/13 17:07:04 Done.
33 SNAPSHOT_PENDING,
34 STOPPED,
35 };
32 36
33 // Client of the SnapshotController. 37 // Client of the SnapshotController.
34 class Client { 38 class Client {
35 public: 39 public:
36 // Invoked at a good moment to start a snapshot. May be invoked multiple 40 // Invoked at a good moment to start a snapshot. May be invoked multiple
37 // times, but not in overlapping manner - waits until 41 // times, but not in overlapping manner - waits until
38 // PreviousSnapshotCompleted() before the next StatrSnapshot(). 42 // PreviousSnapshotCompleted() before the next StatrSnapshot().
39 // Client should overwrite the result of previous snapshot with the new one, 43 // Client should overwrite the result of previous snapshot with the new one,
40 // it is assumed that later snapshots are better then previous. 44 // it is assumed that later snapshots are better then previous.
41 virtual void StartSnapshot() = 0; 45 virtual void StartSnapshot() = 0;
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 SnapshotController::State state_; 82 SnapshotController::State state_;
79 83
80 base::WeakPtrFactory<SnapshotController> weak_ptr_factory_; 84 base::WeakPtrFactory<SnapshotController> weak_ptr_factory_;
81 85
82 DISALLOW_COPY_AND_ASSIGN(SnapshotController); 86 DISALLOW_COPY_AND_ASSIGN(SnapshotController);
83 }; 87 };
84 88
85 } // namespace offline_pages 89 } // namespace offline_pages
86 90
87 #endif // COMPONENTS_OFFLINE_PAGES_SNAPSHOT_CONTROLLER_H_ 91 #endif // COMPONENTS_OFFLINE_PAGES_SNAPSHOT_CONTROLLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698