Commit b32ae119 authored by Collin Baker's avatar Collin Baker Committed by Commit Bot

Don't recapture thumbnails on fully loaded pages

The thumbnail scheduler implementation introduced a bug: each time a
ThumbnailImage is observed, ThumbnailCaptureDriver will recapture the
thumbnail even though it already has a good final capture.

This CL fixes the regression.

Fixed: 1136247
Change-Id: I825632157802eda70656f9fdb4376942b5febe15
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2459627
Auto-Submit: Collin Baker <collinbaker@chromium.org>
Reviewed-by: default avatarDana Fried <dfried@chromium.org>
Commit-Queue: Collin Baker <collinbaker@chromium.org>
Cr-Commit-Position: refs/heads/master@{#815299}
parent 5a13a730
......@@ -56,7 +56,10 @@ void ThumbnailCaptureDriver::SetCapturePermittedByScheduler(bool scheduled) {
void ThumbnailCaptureDriver::UpdateCaptureState() {
if (!scheduled_) {
client_->StopCapture();
capture_state_ = CaptureState::kNoCapture;
if (capture_state_ < CaptureState::kHaveFinalCapture)
capture_state_ = CaptureState::kNoCapture;
return;
}
......
......@@ -486,3 +486,43 @@ TEST_F(ThumbnailCaptureDriverTest, StopsCaptureAtRetryLimit) {
EXPECT_EQ(scheduler_.priority(),
ThumbnailScheduler::TabCapturePriority::kNone);
}
TEST_F(ThumbnailCaptureDriverTest, DoesNotReCaptureAfterFinalThumbnail) {
{
InSequence s;
EXPECT_CALL(mock_client_, StopCapture()).Times(AnyNumber());
EXPECT_CALL(mock_client_, RequestCapture());
EXPECT_CALL(mock_client_, StartCapture());
EXPECT_CALL(mock_client_, StopCapture()).Times(AnyNumber());
}
capture_driver_.UpdateThumbnailVisibility(true);
capture_driver_.UpdatePageVisibility(false);
capture_driver_.UpdatePageReadiness(
ThumbnailReadinessTracker::Readiness::kNotReady);
capture_driver_.UpdatePageReadiness(
ThumbnailReadinessTracker::Readiness::kReadyForInitialCapture);
capture_driver_.SetCapturePermittedByScheduler(true);
capture_driver_.SetCanCapture(true);
capture_driver_.UpdatePageReadiness(
ThumbnailReadinessTracker::Readiness::kReadyForFinalCapture);
EXPECT_EQ(scheduler_.priority(),
ThumbnailScheduler::TabCapturePriority::kHigh);
capture_driver_.SetCapturePermittedByScheduler(true);
capture_driver_.GotFrame();
task_environment_.FastForwardBy(ThumbnailCaptureDriver::kCooldownDelay);
EXPECT_EQ(scheduler_.priority(),
ThumbnailScheduler::TabCapturePriority::kNone);
capture_driver_.SetCapturePermittedByScheduler(false);
capture_driver_.UpdateThumbnailVisibility(false);
EXPECT_EQ(scheduler_.priority(),
ThumbnailScheduler::TabCapturePriority::kNone);
capture_driver_.UpdateThumbnailVisibility(true);
EXPECT_EQ(scheduler_.priority(),
ThumbnailScheduler::TabCapturePriority::kNone);
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment