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

Unified Diff: components/offline_pages/snapshot_controller.h

Issue 1936613002: Implementing recent pages snapshot capture. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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 side-by-side diff with in-line comments
Download patch
Index: components/offline_pages/snapshot_controller.h
diff --git a/components/offline_pages/snapshot_controller.h b/components/offline_pages/snapshot_controller.h
index 37f549c609339a05478bbda0c580a3ce2b66a71c..540468718950d3fe440c97876ce40768c2e171b3 100644
--- a/components/offline_pages/snapshot_controller.h
+++ b/components/offline_pages/snapshot_controller.h
@@ -21,6 +21,8 @@ namespace offline_pages {
// the new attempts to start a snapshot are ignored until it does.
// - Some signals prevent more snapshots to be taken.
// OnLoad is currently such signal.
+// - Once Reset() is called on the SnapshotController, the delayed tasks are
+// reset so no StartSnapshot calls is made 'cross-session'.
class SnapshotController {
public:
// kStateReady - listening to input, will start snapshot when needed.
@@ -36,8 +38,7 @@ class SnapshotController {
// PreviousSnapshotCompleted() before the next StatrSnapshot().
// Client should overwrite the result of previous snapshot with the new one,
// it is assumed that later snapshots are better then previous.
- // Returns true if the snapshot actually started.
- virtual bool StartSnapshot() = 0;
+ virtual void StartSnapshot() = 0;
protected:
virtual ~Client() {}
@@ -69,12 +70,15 @@ class SnapshotController {
size_t GetDelayAfterDocumentAvailableForTest();
private:
- void MaybeStartSnapshot();
+ void MaybeStartSnapshot(size_t session_id);
scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
// Client owns this class.
SnapshotController::Client* client_;
SnapshotController::State state_;
+ // Session counter. Used to check and ignore the delayed tasks from past
+ // sessions.
+ size_t session_counter_;
base::WeakPtrFactory<SnapshotController> weak_ptr_factory_;

Powered by Google App Engine
This is Rietveld 408576698