Chromium Code Reviews| Index: components/offline_pages/core/snapshot_controller.cc |
| diff --git a/components/offline_pages/core/snapshot_controller.cc b/components/offline_pages/core/snapshot_controller.cc |
| index c683a1a9b1056a0e039db12074f9bb48cd36c51b..3f185efb6b036b6dfd75e7666f67efde52acad81 100644 |
| --- a/components/offline_pages/core/snapshot_controller.cc |
| +++ b/components/offline_pages/core/snapshot_controller.cc |
| @@ -14,11 +14,11 @@ namespace { |
| // Default delay, in milliseconds, between the main document parsed event and |
| // snapshot. Note: this snapshot might not occur if the OnLoad event and |
| // OnLoad delay elapses first to trigger a final snapshot. |
| -const int64_t kDefaultDelayAfterDocumentAvailableMs = 7000; |
| +const int64_t kDefaultDelayAfterDocumentLoadedMs = 7000; |
| // Default delay, in milliseconds, between the main document OnLoad event and |
| // snapshot. |
| -const int64_t kDelayAfterDocumentOnLoadCompletedMs = 1000; |
| +const int64_t kDelayAfterLoadCompletedMs = 1000; |
|
Pete Williamson
2017/04/05 00:26:21
Shouldn't this be 2000?
I was thinking all along
chili
2017/04/05 00:34:33
This is the default number. Both offliners pass i
|
| // Delay for testing to keep polling times reasonable. |
| const int64_t kDelayForTests = 0; |
| @@ -32,24 +32,23 @@ SnapshotController::SnapshotController( |
| SnapshotController::Client* client) |
| : SnapshotController(task_runner, |
| client, |
| - kDefaultDelayAfterDocumentAvailableMs, |
| - kDelayAfterDocumentOnLoadCompletedMs) {} |
| + kDefaultDelayAfterDocumentLoadedMs, |
| + kDelayAfterLoadCompletedMs) {} |
| SnapshotController::SnapshotController( |
| const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, |
| SnapshotController::Client* client, |
| - int64_t delay_after_document_available_ms, |
| - int64_t delay_after_document_on_load_completed_ms) |
| + int64_t delay_after_document_loaded_ms, |
| + int64_t delay_after_load_completed_ms) |
| : task_runner_(task_runner), |
| client_(client), |
| state_(State::READY), |
| - delay_after_document_available_ms_(delay_after_document_available_ms), |
| - delay_after_document_on_load_completed_ms_( |
| - delay_after_document_on_load_completed_ms), |
| + delay_after_document_loaded_ms_(delay_after_document_loaded_ms), |
| + delay_after_load_completed_ms_(delay_after_load_completed_ms), |
| weak_ptr_factory_(this) { |
| if (offline_pages::ShouldUseTestingSnapshotDelay()) { |
| - delay_after_document_available_ms_ = kDelayForTests; |
| - delay_after_document_on_load_completed_ms_ = kDelayForTests; |
| + delay_after_document_loaded_ms_ = kDelayForTests; |
| + delay_after_load_completed_ms_ = kDelayForTests; |
| } |
| } |
| @@ -74,23 +73,34 @@ void SnapshotController::PendingSnapshotCompleted() { |
| state_ = State::READY; |
| } |
| -void SnapshotController::DocumentAvailableInMainFrame() { |
| +void SnapshotController::DocumentLoadedInMainFrame() { |
| DCHECK_EQ(PageQuality::POOR, current_page_quality_); |
| // Post a delayed task to snapshot. |
| task_runner_->PostDelayedTask( |
| - FROM_HERE, base::Bind(&SnapshotController::MaybeStartSnapshot, |
| - weak_ptr_factory_.GetWeakPtr(), |
| - PageQuality::FAIR_AND_IMPROVING), |
| - base::TimeDelta::FromMilliseconds(delay_after_document_available_ms_)); |
| + FROM_HERE, |
| + base::Bind(&SnapshotController::MaybeStartSnapshot, |
| + weak_ptr_factory_.GetWeakPtr(), |
| + PageQuality::FAIR_AND_IMPROVING), |
| + base::TimeDelta::FromMilliseconds(delay_after_document_loaded_ms_)); |
| } |
| -void SnapshotController::DocumentOnLoadCompletedInMainFrame() { |
| +void SnapshotController::DidStopLoading() { |
| // Post a delayed task to snapshot and then stop this controller. |
| task_runner_->PostDelayedTask( |
| - FROM_HERE, base::Bind(&SnapshotController::MaybeStartSnapshotThenStop, |
| - weak_ptr_factory_.GetWeakPtr()), |
| - base::TimeDelta::FromMilliseconds( |
| - delay_after_document_on_load_completed_ms_)); |
| + FROM_HERE, |
| + base::Bind(&SnapshotController::MaybeStartSnapshotThenStop, |
| + weak_ptr_factory_.GetWeakPtr()), |
| + base::TimeDelta::FromMilliseconds(delay_after_load_completed_ms_)); |
| +} |
| + |
| +void SnapshotController::DocumentAvailableInMainFrame() { |
| + // Maps to DocumentLoadedInMainFrame for now. |
| + DocumentLoadedInMainFrame(); |
| +} |
| + |
| +void SnapshotController::DocumentOnLoadCompletedInMainFrame() { |
| + // Maps to DidStopLoading for now. |
| + DidStopLoading(); |
| } |
| void SnapshotController::MaybeStartSnapshot(PageQuality updated_page_quality) { |
| @@ -107,12 +117,12 @@ void SnapshotController::MaybeStartSnapshotThenStop() { |
| Stop(); |
| } |
| -int64_t SnapshotController::GetDelayAfterDocumentAvailableForTest() { |
| - return delay_after_document_available_ms_; |
| +int64_t SnapshotController::GetDelayAfterDocumentLoadedForTest() { |
| + return delay_after_document_loaded_ms_; |
| } |
| -int64_t SnapshotController::GetDelayAfterDocumentOnLoadCompletedForTest() { |
| - return delay_after_document_on_load_completed_ms_; |
| +int64_t SnapshotController::GetDelayAfterLoadCompletedForTest() { |
| + return delay_after_load_completed_ms_; |
| } |
| } // namespace offline_pages |