Commit cad9c3d1 authored by Elly Fong-Jones's avatar Elly Fong-Jones Committed by Commit Bot

content: suppress no-op LoadStateChanged

Whenever any requests are running, ResourceDispatcherHostImpl polls for state
changes to running requests, so that these can be reflected in the UI. However,
ResourceDispatcherHostImpl doesn't remember the previous state of a request, so
it always calls LoaderDelegate::LoadStateChanged() for any running request, at
4Hz. This calls into WebContentsImpl::LoadStateChanged(), which *does* have
access to the previous state, which then notifies the UI of a change.

Instead, WebContentsImpl should check if the state notification is redundant,
and if so, should ignore it. This will save doing a bunch of work in the UI. In
principle, ResourceDispatcherHostImpl could do this de-duplication instead, but
that involves storing more data in RDHI for a very small further decrease in
work done.

This also fixes the root cause of an old bug where on Mac, the status bar would
be clobbered (at 4Hz) whenever there was a pending request in the current tab.
This bug was worked around in the Views status bar code by suppressing updates
with no text changes, but that workaround never made it to the Cocoa status
bar.

Bug: 147303
Change-Id: Idbaded695b161543d1750aa9e6253c3bdd0a145a
Reviewed-on: https://chromium-review.googlesource.com/895724Reviewed-by: default avatarAvi Drissman <avi@chromium.org>
Commit-Queue: Elly Fong-Jones <ellyjones@chromium.org>
Cr-Commit-Position: refs/heads/master@{#533309}
parent 868f1e24
......@@ -3415,10 +3415,18 @@ void WebContentsImpl::LoadStateChanged(
const net::LoadStateWithParam& load_state,
uint64_t upload_position,
uint64_t upload_size) {
base::string16 host = url_formatter::IDNToUnicode(url.host());
// Drop no-op updates.
if (load_state_.state == load_state.state &&
load_state_.param == load_state.param &&
upload_position_ == upload_position && upload_size_ == upload_size &&
load_state_host_ == host) {
return;
}
load_state_ = load_state;
upload_position_ = upload_position;
upload_size_ = upload_size;
load_state_host_ = url_formatter::IDNToUnicode(url.host());
load_state_host_ = host;
if (load_state_.state == net::LOAD_STATE_READING_RESPONSE)
SetNotWaitingForResponse();
if (IsLoading()) {
......
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