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

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

Issue 2655273003: Adds a first integration test for the Recent Tabs feature. (Closed)
Patch Set: Fix wrapping of comment text. Created 3 years, 10 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_CORE_SNAPSHOT_CONTROLLER_H_ 5 #ifndef COMPONENTS_OFFLINE_PAGES_CORE_SNAPSHOT_CONTROLLER_H_
6 #define COMPONENTS_OFFLINE_PAGES_CORE_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"
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 protected: 59 protected:
60 virtual ~Client() {} 60 virtual ~Client() {}
61 }; 61 };
62 62
63 SnapshotController( 63 SnapshotController(
64 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, 64 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner,
65 SnapshotController::Client* client); 65 SnapshotController::Client* client);
66 SnapshotController( 66 SnapshotController(
67 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, 67 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner,
68 SnapshotController::Client* client, 68 SnapshotController::Client* client,
69 size_t delay_after_document_available_ms, 69 int64_t delay_after_document_available_ms,
70 size_t delay_after_document_on_load_completed_ms); 70 int64_t delay_after_document_on_load_completed_ms);
71 virtual ~SnapshotController(); 71 virtual ~SnapshotController();
72 72
73 // Resets the 'session', returning controller to initial state. 73 // Resets the 'session', returning controller to initial state.
74 void Reset(); 74 void Reset();
75 75
76 // Stops current session, no more Client::StartSnapshot calls will be 76 // Stops current session, no more Client::StartSnapshot calls will be
77 // invoked from the SnapshotController until current session is Reset(). 77 // invoked from the SnapshotController until current session is Reset().
78 // Called by Client, for example when it encounters an error loading the page. 78 // Called by Client, for example when it encounters an error loading the page.
79 void Stop(); 79 void Stop();
80 80
81 // The way for Client to report that previously started snapshot is 81 // The way for Client to report that previously started snapshot is
82 // now completed (so the next one can be started). 82 // now completed (so the next one can be started).
83 void PendingSnapshotCompleted(); 83 void PendingSnapshotCompleted();
84 84
85 // Invoked from WebContentObserver::DocumentAvailableInMainFrame 85 // Invoked from WebContentObserver::DocumentAvailableInMainFrame
86 void DocumentAvailableInMainFrame(); 86 void DocumentAvailableInMainFrame();
87 87
88 // Invoked from WebContentObserver::DocumentOnLoadCompletedInMainFrame 88 // Invoked from WebContentObserver::DocumentOnLoadCompletedInMainFrame
89 void DocumentOnLoadCompletedInMainFrame(); 89 void DocumentOnLoadCompletedInMainFrame();
90 90
91 size_t GetDelayAfterDocumentAvailableForTest(); 91 int64_t GetDelayAfterDocumentAvailableForTest();
92 size_t GetDelayAfterDocumentOnLoadCompletedForTest(); 92 int64_t GetDelayAfterDocumentOnLoadCompletedForTest();
93 93
94 PageQuality current_page_quality() const { return current_page_quality_; } 94 PageQuality current_page_quality() const { return current_page_quality_; }
95 95
96 private: 96 private:
97 void MaybeStartSnapshot(PageQuality updated_page_quality); 97 void MaybeStartSnapshot(PageQuality updated_page_quality);
98 void MaybeStartSnapshotThenStop(); 98 void MaybeStartSnapshotThenStop();
99 99
100 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; 100 scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
101 // Client owns this class. 101 // Client owns this class.
102 SnapshotController::Client* client_; 102 SnapshotController::Client* client_;
103 SnapshotController::State state_; 103 SnapshotController::State state_;
104 size_t delay_after_document_available_ms_; 104 int64_t delay_after_document_available_ms_;
105 size_t delay_after_document_on_load_completed_ms_; 105 int64_t delay_after_document_on_load_completed_ms_;
106 106
107 // The expected quality of a snapshot taken at the moment this value is 107 // The expected quality of a snapshot taken at the moment this value is
108 // queried. 108 // queried.
109 PageQuality current_page_quality_ = PageQuality::POOR; 109 PageQuality current_page_quality_ = PageQuality::POOR;
110 110
111 base::WeakPtrFactory<SnapshotController> weak_ptr_factory_; 111 base::WeakPtrFactory<SnapshotController> weak_ptr_factory_;
112 112
113 DISALLOW_COPY_AND_ASSIGN(SnapshotController); 113 DISALLOW_COPY_AND_ASSIGN(SnapshotController);
114 }; 114 };
115 115
116 } // namespace offline_pages 116 } // namespace offline_pages
117 117
118 #endif // COMPONENTS_OFFLINE_PAGES_CORE_SNAPSHOT_CONTROLLER_H_ 118 #endif // COMPONENTS_OFFLINE_PAGES_CORE_SNAPSHOT_CONTROLLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698