Prerendering: Fire WebContentsObserver::LoadProgressChanged only on activation
This CL delays firing LoadProgressChanged for prerender frame tree and
dispatches the notification only on activation during calls to
DidStartLoading and DidStopLoading which invoked on activation.
Why?
This is done to ensure that WebContentsObserver::LoadProgressChanged is
per-WebContents i.e., it is not affected by navigations in the
prerendering frame tree.
Now the observers don't use LoadProgressChanged to dispatch show UI
visible changes and other events on an inactive RenderFrameHost.
Document explaining load events and prerendering:
https://docs.google.com/document/d/1WqzPSpWtJ9bqaaecYWTWvg6h2Q1UMh7kVB8C61o8QL4/edit?usp=sharing&resourcekey=0-q9YIhsh5LS-ZfBXcBQCOew
Bug: 1199682
Change-Id: I638d319802a6b6e77748af4057835dc47461fa5f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2993855
Commit-Queue: Sreeja Kamishetty <sreejakshetty@chromium.org>
Reviewed-by: Matt Falkenhagen <falken@chromium.org>
Reviewed-by: Alexander Timin <altimin@chromium.org>
Reviewed-by: Hiroki Nakagawa <nhiroki@chromium.org>
Cr-Commit-Position: refs/heads/master@{#911364}
diff --git a/content/browser/prerender/prerender_browsertest.cc b/content/browser/prerender/prerender_browsertest.cc
index ab135633..a183d27 100644
--- a/content/browser/prerender/prerender_browsertest.cc
+++ b/content/browser/prerender/prerender_browsertest.cc
@@ -77,6 +77,7 @@
#include "testing/gmock/include/gmock/gmock.h"
#include "third_party/abseil-cpp/absl/types/optional.h"
#include "third_party/blink/public/common/features.h"
+#include "third_party/blink/public/common/loader/loader_constants.h"
#include "third_party/blink/public/mojom/browser_interface_broker.mojom.h"
#include "ui/shell_dialogs/select_file_dialog.h"
#include "ui/shell_dialogs/select_file_dialog_factory.h"
@@ -3388,6 +3389,63 @@
EXPECT_EQ(web_contents()->GetURL(), kPrerenderingUrl);
}
+// Test that WebContentsObserver::LoadProgressChanged is not invoked when the
+// page gets loaded while prerendering but is invoked on prerender activation.
+// Check that LoadProgressChanged is only called once for
+// blink::kFinalLoadProgress if the prerender page completes loading on
+// activation.
+IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest,
+ LoadProgressChangedInvokedOnActivation) {
+ const GURL kInitialUrl = GetUrl("/empty.html");
+ const GURL kPrerenderingUrl = GetUrl("/simple_page.html");
+
+ web_contents_impl()->set_minimum_delay_between_loading_updates_for_testing(
+ base::TimeDelta::FromMilliseconds(0));
+
+ // Navigate to an initial page.
+ ASSERT_TRUE(NavigateToURL(shell(), kInitialUrl));
+
+ // Initialize a MockWebContentsObserver and ensure that LoadProgressChanged is
+ // not invoked while prerendering.
+ testing::NiceMock<MockWebContentsObserver> observer(shell()->web_contents());
+ testing::InSequence s;
+ EXPECT_CALL(observer, LoadProgressChanged(testing::_)).Times(0);
+
+ // Start a prerender.
+ int prerender_host_id = AddPrerender(kPrerenderingUrl);
+ ASSERT_NE(prerender_host_id, RenderFrameHost::kNoFrameTreeNodeId);
+ RenderFrameHostImpl* prerender_frame_host =
+ GetPrerenderedMainFrameHost(prerender_host_id);
+
+ // Verify and clear all expectations on the mock observer before setting new
+ // ones.
+ testing::Mock::VerifyAndClearExpectations(&observer);
+
+ // Activate the prerendered page. This should result in invoking
+ // LoadProgressChanged for the following cases:
+ {
+ // 1) During DidStartLoading LoadProgressChanged is invoked with
+ // kInitialLoadProgress value.
+ EXPECT_CALL(observer, LoadProgressChanged(blink::kInitialLoadProgress));
+
+ // Verify that DidFinishNavigation is invoked before final load progress
+ // notification.
+ EXPECT_CALL(observer, DidFinishNavigation(testing::_));
+
+ // 2) During DidStopLoading LoadProgressChanged is invoked with
+ // kFinalLoadProgress.
+ EXPECT_CALL(observer, LoadProgressChanged(blink::kFinalLoadProgress))
+ .Times(1);
+ }
+
+ // Set the prerender load progress value to blink::kFinalLoadProgress, this
+ // should result in invoking LoadProgressChanged(blink::kFinalLoadProgress)
+ // only once on activation during call to DidStopLoading.
+ prerender_frame_host->GetPage().set_load_progress(blink::kFinalLoadProgress);
+ NavigatePrimaryPage(kPrerenderingUrl);
+ EXPECT_EQ(web_contents()->GetURL(), kPrerenderingUrl);
+}
+
// Test the dispatch order of various load events on prerender activation.
IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, OrderingOfDifferentLoadEvents) {
const GURL kInitialUrl = GetUrl("/empty.html");
diff --git a/content/browser/prerender/prerender_host_unittest.cc b/content/browser/prerender/prerender_host_unittest.cc
index 1c0943ba..fd33733 100644
--- a/content/browser/prerender/prerender_host_unittest.cc
+++ b/content/browser/prerender/prerender_host_unittest.cc
@@ -7,6 +7,7 @@
#include "base/test/scoped_feature_list.h"
#include "content/browser/prerender/prerender_host_registry.h"
#include "content/browser/site_instance_impl.h"
+#include "content/public/test/mock_web_contents_observer.h"
#include "content/public/test/navigation_simulator.h"
#include "content/public/test/test_browser_context.h"
#include "content/test/mock_commit_deferring_condition.h"
@@ -14,11 +15,16 @@
#include "content/test/test_render_frame_host.h"
#include "content/test/test_render_view_host.h"
#include "content/test/test_web_contents.h"
+#include "testing/gmock/include/gmock/gmock.h"
+#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/blink/public/common/features.h"
+#include "third_party/blink/public/common/loader/loader_constants.h"
namespace content {
namespace {
+using ::testing::_;
+
// TODO(nhiroki): Merge this into TestNavigationObserver for code
// simplification.
class ActivationObserver : public PrerenderHost::Observer {
@@ -306,5 +312,68 @@
->page_state());
}
+// Test that WebContentsObserver::LoadProgressChanged is not invoked when the
+// page gets loaded while prerendering but is invoked on prerender activation.
+// Check that in case the load is incomplete with load progress
+// `kPartialLoadProgress`, we would see
+// LoadProgressChanged(kPartialLoadProgress) called on activation.
+TEST_F(PrerenderHostTest, LoadProgressChangedInvokedOnActivation) {
+ const GURL kOriginUrl("https://example.com/");
+ std::unique_ptr<TestWebContents> web_contents = CreateWebContents(kOriginUrl);
+ WebContentsImpl* web_contents_impl =
+ static_cast<WebContentsImpl*>(web_contents.get());
+
+ web_contents_impl->set_minimum_delay_between_loading_updates_for_testing(
+ base::TimeDelta::FromMilliseconds(0));
+
+ // Initialize a MockWebContentsObserver and ensure that LoadProgressChanged is
+ // not invoked while prerendering.
+ testing::NiceMock<MockWebContentsObserver> observer(web_contents_impl);
+ testing::InSequence s;
+ EXPECT_CALL(observer, LoadProgressChanged(testing::_)).Times(0);
+
+ // Start prerendering a page and commit prerender navigation.
+ const GURL kPrerenderingUrl("https://example.com/next");
+ constexpr double kPartialLoadProgress = 0.7;
+ RenderFrameHostImpl* prerender_rfh =
+ web_contents->AddPrerenderAndCommitNavigation(kPrerenderingUrl);
+ FrameTreeNode* ftn = prerender_rfh->frame_tree_node();
+ EXPECT_FALSE(ftn->HasNavigation());
+
+ // Verify and clear all expectations on the mock observer before setting new
+ // ones.
+ testing::Mock::VerifyAndClearExpectations(&observer);
+
+ // Activate the prerendered page. This should result in invoking
+ // LoadProgressChanged for the following cases:
+ {
+ // 1) During DidStartLoading LoadProgressChanged is invoked with
+ // kInitialLoadProgress value.
+ EXPECT_CALL(observer, LoadProgressChanged(blink::kInitialLoadProgress));
+
+ // Verify that DidFinishNavigation is invoked before final load progress
+ // notification.
+ EXPECT_CALL(observer, DidFinishNavigation(testing::_));
+
+ // 2) After DidCommitNavigationInternal on activation with
+ // LoadProgressChanged is invoked with kPartialLoadProgress value.
+ EXPECT_CALL(observer, LoadProgressChanged(kPartialLoadProgress));
+
+ // 3) During DidStopLoading LoadProgressChanged is invoked with
+ // kFinalLoadProgress.
+ EXPECT_CALL(observer, LoadProgressChanged(blink::kFinalLoadProgress));
+ }
+
+ // Set load_progress value to kPartialLoadProgress in prerendering state,
+ // this should result in invoking LoadProgressChanged(kPartialLoadProgress) on
+ // activation.
+ prerender_rfh->GetPage().set_load_progress(kPartialLoadProgress);
+
+ // Perform a navigation in the primary frame tree which activates the
+ // prerendered page.
+ ActivatePrerenderedPage(kPrerenderingUrl, *web_contents);
+ ExpectFinalStatus(PrerenderHost::FinalStatus::kActivated);
+}
+
} // namespace
} // namespace content
diff --git a/content/browser/renderer_host/frame_tree.cc b/content/browser/renderer_host/frame_tree.cc
index 7f96b53f..3cf1577 100644
--- a/content/browser/renderer_host/frame_tree.cc
+++ b/content/browser/renderer_host/frame_tree.cc
@@ -23,6 +23,7 @@
#include "content/browser/renderer_host/navigation_request.h"
#include "content/browser/renderer_host/navigator.h"
#include "content/browser/renderer_host/navigator_delegate.h"
+#include "content/browser/renderer_host/page_impl.h"
#include "content/browser/renderer_host/render_frame_host_delegate.h"
#include "content/browser/renderer_host/render_frame_host_factory.h"
#include "content/browser/renderer_host/render_frame_host_impl.h"
@@ -33,6 +34,7 @@
#include "content/common/content_switches_internal.h"
#include "third_party/blink/public/common/features.h"
#include "third_party/blink/public/common/frame/frame_policy.h"
+#include "third_party/blink/public/common/loader/loader_constants.h"
#include "third_party/blink/public/mojom/frame/frame_owner_properties.mojom.h"
namespace content {
@@ -561,8 +563,11 @@
focused_frame_tree_node_id_ = FrameTreeNode::kFrameTreeNodeInvalidId;
}
-void FrameTree::ResetLoadProgress() {
- load_progress_ = 0.0;
+double FrameTree::GetLoadProgress() {
+ if (root_->HasNavigation())
+ return blink::kInitialLoadProgress;
+
+ return root_->current_frame_host()->GetPage().load_progress();
}
bool FrameTree::IsLoading() const {
@@ -672,12 +677,6 @@
void FrameTree::DidStartLoadingNode(FrameTreeNode& node,
bool to_different_document,
bool was_previously_loading) {
- // Any main frame load to a new document should reset the load progress since
- // it will replace the current page and any frames. The WebContents will
- // be notified when DidChangeLoadProgress is called.
- if (to_different_document && node.IsMainFrame())
- ResetLoadProgress();
-
if (was_previously_loading)
return;
@@ -693,18 +692,6 @@
delegate_->DidStopLoading();
}
-void FrameTree::DidChangeLoadProgressForNode(FrameTreeNode& node,
- double load_progress) {
- if (!node.IsMainFrame())
- return;
- if (load_progress <= load_progress_)
- return;
- load_progress_ = load_progress;
-
- // Notify the WebContents.
- delegate_->DidChangeLoadProgress();
-}
-
void FrameTree::DidCancelLoading() {
OPTIONAL_TRACE_EVENT0("content", "FrameTree::DidCancelLoading");
navigator_.controller().DiscardNonCommittedEntries();
diff --git a/content/browser/renderer_host/frame_tree.h b/content/browser/renderer_host/frame_tree.h
index 556d2df46..c249c92 100644
--- a/content/browser/renderer_host/frame_tree.h
+++ b/content/browser/renderer_host/frame_tree.h
@@ -355,14 +355,11 @@
bool to_different_document,
bool was_previously_loading);
void DidStopLoadingNode(FrameTreeNode& node);
- void DidChangeLoadProgressForNode(FrameTreeNode& node, double load_progress);
void DidCancelLoading();
- // Returns this FrameTree's total load progress.
- double load_progress() const { return load_progress_; }
-
- // Resets the load progress on all nodes in this FrameTree.
- void ResetLoadProgress();
+ // Returns this FrameTree's total load progress. If the `root_` FrameTreeNode
+ // is navigating returns `blink::kInitialLoadProgress`.
+ double GetLoadProgress();
// Returns true if at least one of the nodes in this FrameTree is loading.
bool IsLoading() const;
diff --git a/content/browser/renderer_host/frame_tree_node.cc b/content/browser/renderer_host/frame_tree_node.cc
index 7596d07..99e01371 100644
--- a/content/browser/renderer_host/frame_tree_node.cc
+++ b/content/browser/renderer_host/frame_tree_node.cc
@@ -28,6 +28,7 @@
#include "services/network/public/cpp/web_sandbox_flags.h"
#include "services/network/public/mojom/web_sandbox_flags.mojom-shared.h"
#include "third_party/blink/public/common/features.h"
+#include "third_party/blink/public/common/loader/loader_constants.h"
#include "third_party/blink/public/mojom/frame/user_activation_update_types.mojom.h"
#include "third_party/blink/public/mojom/security_context/insecure_request_policy.mojom.h"
@@ -42,12 +43,6 @@
base::LazyInstance<FrameTreeNodeIdMap>::DestructorAtExit
g_frame_tree_node_id_map = LAZY_INSTANCE_INITIALIZER;
-// These values indicate the loading progress status. The minimum progress
-// value matches what Blink's ProgressTracker has traditionally used for a
-// minimum progress value.
-const double kLoadingProgressMinimum = 0.1;
-const double kLoadingProgressDone = 1.0;
-
} // namespace
// This observer watches the opener of its owner FrameTreeNode and clears the
@@ -568,7 +563,7 @@
// Set initial load progress and update overall progress. This will notify
// the WebContents of the load progress change.
- DidChangeLoadProgress(kLoadingProgressMinimum);
+ DidChangeLoadProgress(blink::kInitialLoadProgress);
// Notify the RenderFrameHostManager of the event.
render_manager()->OnDidStartLoading();
@@ -579,7 +574,7 @@
frame_tree_node_id());
// Set final load progress and update overall progress. This will notify
// the WebContents of the load progress change.
- DidChangeLoadProgress(kLoadingProgressDone);
+ DidChangeLoadProgress(blink::kFinalLoadProgress);
// Notify the RenderFrameHostManager of the event.
render_manager()->OnDidStopLoading();
@@ -588,9 +583,9 @@
}
void FrameTreeNode::DidChangeLoadProgress(double load_progress) {
- DCHECK_GE(load_progress, kLoadingProgressMinimum);
- DCHECK_LE(load_progress, kLoadingProgressDone);
- frame_tree_->DidChangeLoadProgressForNode(*this, load_progress);
+ DCHECK_GE(load_progress, blink::kInitialLoadProgress);
+ DCHECK_LE(load_progress, blink::kFinalLoadProgress);
+ current_frame_host()->DidChangeLoadProgress(load_progress);
}
bool FrameTreeNode::StopLoading() {
diff --git a/content/browser/renderer_host/page_impl.cc b/content/browser/renderer_host/page_impl.cc
index bfedc35..18fbbeb 100644
--- a/content/browser/renderer_host/page_impl.cc
+++ b/content/browser/renderer_host/page_impl.cc
@@ -13,6 +13,7 @@
#include "content/browser/renderer_host/render_view_host_delegate.h"
#include "content/browser/renderer_host/render_view_host_impl.h"
#include "content/public/browser/render_view_host.h"
+#include "third_party/blink/public/common/loader/loader_constants.h"
#include "third_party/perfetto/include/perfetto/tracing/traced_value.h"
namespace content {
@@ -140,6 +141,13 @@
void PageImpl::MaybeDispatchLoadEventsOnPrerenderActivation() {
DCHECK(IsPrimary());
+ // Dispatch LoadProgressChanged notification on activation with the
+ // prerender last load progress value if the value is not equal to
+ // blink::kFinalLoadProgress, whose notification is dispatched during call
+ // to DidStopLoading.
+ if (load_progress() != blink::kFinalLoadProgress)
+ main_document_.DidChangeLoadProgress(load_progress());
+
main_document_.ForEachRenderFrameHost(
base::BindRepeating([](RenderFrameHostImpl* rfh) {
rfh->MaybeDispatchDOMContentLoadedOnPrerenderActivation();
diff --git a/content/browser/renderer_host/page_impl.h b/content/browser/renderer_host/page_impl.h
index 5a221ea6..444194b 100644
--- a/content/browser/renderer_host/page_impl.h
+++ b/content/browser/renderer_host/page_impl.h
@@ -114,6 +114,11 @@
// activation.
void MaybeDispatchLoadEventsOnPrerenderActivation();
+ void set_load_progress(double load_progress) {
+ load_progress_ = load_progress;
+ }
+ double load_progress() const { return load_progress_; }
+
private:
void DidActivateAllRenderViewsForPrerendering();
@@ -126,6 +131,10 @@
// run for the main document.
bool is_on_load_completed_in_main_document_ = false;
+ // Overall load progress of this Page. Initial load progress value is 0.0
+ // before the load has begun.
+ double load_progress_ = 0.0;
+
// Web application manifest URL for this page.
// See https://w3c.github.io/manifest/#web-application-manifest.
//
diff --git a/content/browser/renderer_host/render_frame_host_impl.cc b/content/browser/renderer_host/render_frame_host_impl.cc
index d38584b..0cfabc4 100644
--- a/content/browser/renderer_host/render_frame_host_impl.cc
+++ b/content/browser/renderer_host/render_frame_host_impl.cc
@@ -5353,7 +5353,15 @@
}
void RenderFrameHostImpl::DidChangeLoadProgress(double load_progress) {
- frame_tree_node_->DidChangeLoadProgress(load_progress);
+ if (!is_main_frame())
+ return;
+
+ if (load_progress < GetPage().load_progress())
+ return;
+
+ GetPage().set_load_progress(load_progress);
+
+ frame_tree_node_->frame_tree()->delegate()->DidChangeLoadProgress();
}
void RenderFrameHostImpl::DidFinishLoad(const GURL& validated_url) {
diff --git a/content/browser/web_contents/web_contents_impl.cc b/content/browser/web_contents/web_contents_impl.cc
index d68a98d..d1d7867 100644
--- a/content/browser/web_contents/web_contents_impl.cc
+++ b/content/browser/web_contents/web_contents_impl.cc
@@ -194,8 +194,6 @@
constexpr auto kUpdateLoadStatesInterval =
base::TimeDelta::FromMilliseconds(250);
-const int kMinimumDelayBetweenLoadingUpdatesMS = 100;
-
using LifecycleState = RenderFrameHost::LifecycleState;
using LifecycleStateImpl = RenderFrameHostImpl::LifecycleStateImpl;
@@ -1872,7 +1870,9 @@
}
double WebContentsImpl::GetLoadProgress() {
- return frame_tree_.load_progress();
+ // TODO(crbug.com/1199682): Make this MPArch friendly considering primary
+ // frame tree and its descendants.
+ return frame_tree_.GetLoadProgress();
}
bool WebContentsImpl::IsLoadingToDifferentDocument() {
@@ -6405,17 +6405,17 @@
void WebContentsImpl::SendChangeLoadProgress() {
OPTIONAL_TRACE_EVENT1("content", "WebContentsImpl::SendChangeLoadProgress",
- "load_progress", frame_tree_.load_progress());
+ "load_progress", GetLoadProgress());
loading_last_progress_update_ = base::TimeTicks::Now();
SCOPED_UMA_HISTOGRAM_TIMER("WebContentsObserver.LoadProgressChanged");
observers_.NotifyObservers(&WebContentsObserver::LoadProgressChanged,
- frame_tree_.load_progress());
+ GetLoadProgress());
}
void WebContentsImpl::ResetLoadProgressState() {
OPTIONAL_TRACE_EVENT0("content", "WebContentsImpl::ResetLoadProgressState");
- frame_tree_.ResetLoadProgress();
+ GetPrimaryPage().set_load_progress(0.0);
loading_weak_factory_.InvalidateWeakPtrs();
loading_last_progress_update_ = base::TimeTicks();
}
@@ -7271,14 +7271,13 @@
OPTIONAL_TRACE_EVENT0("content", "WebContentsImpl::DidChangeLoadProgress");
if (IsBeingDestroyed())
return;
- double load_progress = frame_tree_.load_progress();
+ double load_progress = GetLoadProgress();
// The delegate is notified immediately for the first and last updates. Also,
// since the message loop may be pretty busy when a page is loaded, it might
// not execute a posted task in a timely manner so the progress report is sent
// immediately if enough time has passed.
- base::TimeDelta min_delay =
- base::TimeDelta::FromMilliseconds(kMinimumDelayBetweenLoadingUpdatesMS);
+ base::TimeDelta min_delay = minimum_delay_between_loading_updates_ms_;
bool delay_elapsed =
loading_last_progress_update_.is_null() ||
base::TimeTicks::Now() - loading_last_progress_update_ > min_delay;
@@ -7299,11 +7298,15 @@
if (loading_weak_factory_.HasWeakPtrs())
return;
- base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
- FROM_HERE,
- base::BindOnce(&WebContentsImpl::SendChangeLoadProgress,
- loading_weak_factory_.GetWeakPtr()),
- min_delay);
+ if (min_delay == base::TimeDelta::FromMilliseconds(0)) {
+ SendChangeLoadProgress();
+ } else {
+ base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
+ FROM_HERE,
+ base::BindOnce(&WebContentsImpl::SendChangeLoadProgress,
+ loading_weak_factory_.GetWeakPtr()),
+ min_delay);
+ }
}
bool WebContentsImpl::IsHidden() {
diff --git a/content/browser/web_contents/web_contents_impl.h b/content/browser/web_contents/web_contents_impl.h
index 1d45d6c..4e3b10c 100644
--- a/content/browser/web_contents/web_contents_impl.h
+++ b/content/browser/web_contents/web_contents_impl.h
@@ -1305,6 +1305,12 @@
show_poup_menu_callback_ = std::move(callback);
}
+ // Sets the value in tests to ensure expected ordering and correctness.
+ void set_minimum_delay_between_loading_updates_for_testing(
+ base::TimeDelta duration) {
+ minimum_delay_between_loading_updates_ms_ = duration;
+ }
+
private:
using FrameTreeIterationCallback = base::RepeatingCallback<void(FrameTree*)>;
@@ -1902,6 +1908,10 @@
base::TimeTicks loading_last_progress_update_;
+ // Default value is set to 100ms between LoadProgressChanged events.
+ base::TimeDelta minimum_delay_between_loading_updates_ms_ =
+ base::TimeDelta::FromMilliseconds(100);
+
// Upload progress, for displaying in the status bar.
// Set to zero when there is no significant upload happening.
uint64_t upload_size_;
diff --git a/third_party/blink/public/common/loader/loader_constants.h b/third_party/blink/public/common/loader/loader_constants.h
index 9c963ab..3a22f95 100644
--- a/third_party/blink/public/common/loader/loader_constants.h
+++ b/third_party/blink/public/common/loader/loader_constants.h
@@ -12,6 +12,14 @@
// HTTP header set in requests to indicate they should be marked DoNotTrack.
BLINK_COMMON_EXPORT extern const char kDoNotTrackHeader[];
+// These values indicate the load progress constants shared between both
+// //content and //blink.
+//
+// Initial progress value is set to 0.1 to help provide feedback as soon as a
+// load starts.
+constexpr double kInitialLoadProgress = 0.1;
+constexpr double kFinalLoadProgress = 1.0;
+
} // namespace blink
#endif // THIRD_PARTY_BLINK_PUBLIC_COMMON_LOADER_LOADER_CONSTANTS_H_
diff --git a/third_party/blink/renderer/core/loader/progress_tracker.cc b/third_party/blink/renderer/core/loader/progress_tracker.cc
index f6f2ad94..751acdc00 100644
--- a/third_party/blink/renderer/core/loader/progress_tracker.cc
+++ b/third_party/blink/renderer/core/loader/progress_tracker.cc
@@ -25,6 +25,7 @@
#include "third_party/blink/renderer/core/loader/progress_tracker.h"
+#include "third_party/blink/public/common/loader/loader_constants.h"
#include "third_party/blink/public/web/web_settings.h"
#include "third_party/blink/renderer/core/frame/local_frame.h"
#include "third_party/blink/renderer/core/frame/local_frame_client.h"
@@ -40,14 +41,10 @@
namespace blink {
-// Always start progress at initialProgressValue. This helps provide feedback as
-// soon as a load starts.
-static const double kInitialProgressValue = 0.1;
+static constexpr int kProgressItemDefaultEstimatedLength = 1024 * 1024;
-static const int kProgressItemDefaultEstimatedLength = 1024 * 1024;
-
-static const double kProgressNotificationInterval = 0.02;
-static const double kProgressNotificationTimeInterval = 0.1;
+static constexpr double kProgressNotificationInterval = 0.02;
+static constexpr double kProgressNotificationTimeInterval = 0.1;
ProgressTracker::ProgressTracker(LocalFrame* frame)
: frame_(frame),
@@ -90,7 +87,7 @@
void ProgressTracker::ProgressStarted() {
Reset();
- progress_value_ = kInitialProgressValue;
+ progress_value_ = kInitialLoadProgress;
if (!frame_->IsLoading()) {
GetLocalFrameClient()->DidStartLoading();
frame_->SetIsLoading(true);
@@ -183,7 +180,7 @@
if (!frame_->IsLoading())
return;
- progress_value_ = kInitialProgressValue + 0.1; // +0.1 for committing
+ progress_value_ = kInitialLoadProgress + 0.1; // +0.1 for committing
if (finished_parsing_)
progress_value_ += 0.1;
if (did_first_contentful_paint_)
@@ -202,7 +199,7 @@
(double)estimated_bytes_for_pending_requests_;
progress_value_ += percent_of_bytes_received / 2;
- DCHECK_GE(progress_value_, kInitialProgressValue);
+ DCHECK_GE(progress_value_, kInitialLoadProgress);
// Always leave space at the end. This helps show the user that we're not
// done until we're done.
DCHECK_LE(progress_value_, 0.9);