Commit fcdaa486 authored by aiolos's avatar aiolos Committed by Commit bot

Hook up RenderWidgetHost's

loading signal to ResourceScheduler

BUG=128035

Review URL: https://codereview.chromium.org/501703002

Cr-Commit-Position: refs/heads/master@{#292695}
parent 1c5b7a8a
...@@ -1360,6 +1360,12 @@ void ResourceDispatcherHostImpl::OnRenderViewHostDeleted( ...@@ -1360,6 +1360,12 @@ void ResourceDispatcherHostImpl::OnRenderViewHostDeleted(
CancelRequestsForRoute(child_id, route_id); CancelRequestsForRoute(child_id, route_id);
} }
void ResourceDispatcherHostImpl::OnRenderViewHostSetIsLoading(int child_id,
int route_id,
bool is_loading) {
scheduler_->OnLoadingStateChanged(child_id, route_id, !is_loading);
}
void ResourceDispatcherHostImpl::OnRenderViewHostWasHidden( void ResourceDispatcherHostImpl::OnRenderViewHostWasHidden(
int child_id, int child_id,
int route_id) { int route_id) {
......
...@@ -169,6 +169,11 @@ class CONTENT_EXPORT ResourceDispatcherHostImpl ...@@ -169,6 +169,11 @@ class CONTENT_EXPORT ResourceDispatcherHostImpl
// Called when a RenderViewHost is deleted. // Called when a RenderViewHost is deleted.
void OnRenderViewHostDeleted(int child_id, int route_id); void OnRenderViewHostDeleted(int child_id, int route_id);
// Called when a RenderViewHost starts or stops loading.
void OnRenderViewHostSetIsLoading(int child_id,
int route_id,
bool is_loading);
// Called when a RenderViewHost is hidden. // Called when a RenderViewHost is hidden.
void OnRenderViewHostWasHidden(int child_id, int route_id); void OnRenderViewHostWasHidden(int child_id, int route_id);
......
...@@ -288,7 +288,7 @@ class ResourceScheduler::Client { ...@@ -288,7 +288,7 @@ class ResourceScheduler::Client {
bool is_loaded() const { return is_loaded_; } bool is_loaded() const { return is_loaded_; }
bool IsVisible() const { return is_visible_; } bool is_visible() const { return is_visible_; }
void OnAudibilityChanged(bool is_audible) { void OnAudibilityChanged(bool is_audible) {
if (is_audible == is_audible_) { if (is_audible == is_audible_) {
...@@ -821,6 +821,22 @@ void ResourceScheduler::OnClientDeleted(int child_id, int route_id) { ...@@ -821,6 +821,22 @@ void ResourceScheduler::OnClientDeleted(int child_id, int route_id) {
client_map_.erase(it); client_map_.erase(it);
} }
void ResourceScheduler::OnVisibilityChanged(int child_id,
int route_id,
bool is_visible) {
Client* client = GetClient(child_id, route_id);
DCHECK(client);
client->OnVisibilityChanged(is_visible);
}
void ResourceScheduler::OnLoadingStateChanged(int child_id,
int route_id,
bool is_loaded) {
Client* client = GetClient(child_id, route_id);
DCHECK(client);
client->OnLoadingStateChanged(is_loaded);
}
void ResourceScheduler::OnNavigate(int child_id, int route_id) { void ResourceScheduler::OnNavigate(int child_id, int route_id) {
DCHECK(CalledOnValidThread()); DCHECK(CalledOnValidThread());
ClientId client_id = MakeClientId(child_id, route_id); ClientId client_id = MakeClientId(child_id, route_id);
...@@ -872,26 +888,10 @@ void ResourceScheduler::OnAudibilityChanged(int child_id, ...@@ -872,26 +888,10 @@ void ResourceScheduler::OnAudibilityChanged(int child_id,
client->OnAudibilityChanged(is_audible); client->OnAudibilityChanged(is_audible);
} }
void ResourceScheduler::OnVisibilityChanged(int child_id,
int route_id,
bool is_visible) {
Client* client = GetClient(child_id, route_id);
DCHECK(client);
client->OnVisibilityChanged(is_visible);
}
void ResourceScheduler::OnLoadingStateChanged(int child_id,
int route_id,
bool is_loaded) {
Client* client = GetClient(child_id, route_id);
DCHECK(client);
client->OnLoadingStateChanged(is_loaded);
}
bool ResourceScheduler::IsClientVisibleForTesting(int child_id, int route_id) { bool ResourceScheduler::IsClientVisibleForTesting(int child_id, int route_id) {
Client* client = GetClient(child_id, route_id); Client* client = GetClient(child_id, route_id);
DCHECK(client); DCHECK(client);
return client->IsVisible(); return client->is_visible();
} }
ResourceScheduler::Client* ResourceScheduler::GetClient(int child_id, ResourceScheduler::Client* ResourceScheduler::GetClient(int child_id,
......
...@@ -116,6 +116,12 @@ class CONTENT_EXPORT ResourceScheduler : public base::NonThreadSafe { ...@@ -116,6 +116,12 @@ class CONTENT_EXPORT ResourceScheduler : public base::NonThreadSafe {
// Called when a renderer is destroyed. // Called when a renderer is destroyed.
void OnClientDeleted(int child_id, int route_id); void OnClientDeleted(int child_id, int route_id);
// Called when a renderer stops or restarts loading.
void OnLoadingStateChanged(int child_id, int route_id, bool is_loaded);
// Called when a Client is shown or hidden.
void OnVisibilityChanged(int child_id, int route_id, bool is_visible);
// Signals from IPC messages directly from the renderers: // Signals from IPC messages directly from the renderers:
// Called when a client navigates to a new main document. // Called when a client navigates to a new main document.
...@@ -139,11 +145,6 @@ class CONTENT_EXPORT ResourceScheduler : public base::NonThreadSafe { ...@@ -139,11 +145,6 @@ class CONTENT_EXPORT ResourceScheduler : public base::NonThreadSafe {
// Called when a Client starts or stops playing audio. // Called when a Client starts or stops playing audio.
void OnAudibilityChanged(int child_id, int route_id, bool is_audible); void OnAudibilityChanged(int child_id, int route_id, bool is_audible);
// Called when a Client is shown or hidden.
void OnVisibilityChanged(int child_id, int route_id, bool is_visible);
void OnLoadingStateChanged(int child_id, int route_id, bool is_loaded);
bool IsClientVisibleForTesting(int child_id, int route_id); bool IsClientVisibleForTesting(int child_id, int route_id);
private: private:
......
...@@ -841,6 +841,20 @@ void RenderViewHostImpl::DirectoryEnumerationFinished( ...@@ -841,6 +841,20 @@ void RenderViewHostImpl::DirectoryEnumerationFinished(
files)); files));
} }
void RenderViewHostImpl::SetIsLoading(bool is_loading) {
if (ResourceDispatcherHostImpl::Get()) {
BrowserThread::PostTask(
BrowserThread::IO,
FROM_HERE,
base::Bind(&ResourceDispatcherHostImpl::OnRenderViewHostSetIsLoading,
base::Unretained(ResourceDispatcherHostImpl::Get()),
GetProcess()->GetID(),
GetRoutingID(),
is_loading));
}
RenderWidgetHostImpl::SetIsLoading(is_loading);
}
void RenderViewHostImpl::LoadStateChanged( void RenderViewHostImpl::LoadStateChanged(
const GURL& url, const GURL& url,
const net::LoadStateWithParam& load_state, const net::LoadStateWithParam& load_state,
......
...@@ -314,6 +314,7 @@ class CONTENT_EXPORT RenderViewHostImpl ...@@ -314,6 +314,7 @@ class CONTENT_EXPORT RenderViewHostImpl
virtual void GotFocus() OVERRIDE; virtual void GotFocus() OVERRIDE;
virtual void LostCapture() OVERRIDE; virtual void LostCapture() OVERRIDE;
virtual void LostMouseLock() OVERRIDE; virtual void LostMouseLock() OVERRIDE;
virtual void SetIsLoading(bool is_loading) OVERRIDE;
virtual void ForwardMouseEvent( virtual void ForwardMouseEvent(
const blink::WebMouseEvent& mouse_event) OVERRIDE; const blink::WebMouseEvent& mouse_event) OVERRIDE;
virtual void OnPointerEventActivate() OVERRIDE; virtual void OnPointerEventActivate() OVERRIDE;
......
...@@ -487,6 +487,13 @@ bool RenderWidgetHostImpl::Send(IPC::Message* msg) { ...@@ -487,6 +487,13 @@ bool RenderWidgetHostImpl::Send(IPC::Message* msg) {
return process_->Send(msg); return process_->Send(msg);
} }
void RenderWidgetHostImpl::SetIsLoading(bool is_loading) {
is_loading_ = is_loading;
if (!view_)
return;
view_->SetIsLoading(is_loading);
}
void RenderWidgetHostImpl::WasHidden() { void RenderWidgetHostImpl::WasHidden() {
if (is_hidden_) if (is_hidden_)
return; return;
...@@ -654,13 +661,6 @@ void RenderWidgetHostImpl::ViewDestroyed() { ...@@ -654,13 +661,6 @@ void RenderWidgetHostImpl::ViewDestroyed() {
SetView(NULL); SetView(NULL);
} }
void RenderWidgetHostImpl::SetIsLoading(bool is_loading) {
is_loading_ = is_loading;
if (!view_)
return;
view_->SetIsLoading(is_loading);
}
void RenderWidgetHostImpl::CopyFromBackingStore( void RenderWidgetHostImpl::CopyFromBackingStore(
const gfx::Rect& src_subrect, const gfx::Rect& src_subrect,
const gfx::Size& accelerated_dst_size, const gfx::Size& accelerated_dst_size,
......
...@@ -204,6 +204,9 @@ class CONTENT_EXPORT RenderWidgetHostImpl ...@@ -204,6 +204,9 @@ class CONTENT_EXPORT RenderWidgetHostImpl
// Sends a message to the corresponding object in the renderer. // Sends a message to the corresponding object in the renderer.
virtual bool Send(IPC::Message* msg) OVERRIDE; virtual bool Send(IPC::Message* msg) OVERRIDE;
// Indicates if the page has finished loading.
virtual void SetIsLoading(bool is_loading);
// Called to notify the RenderWidget that it has been hidden or restored from // Called to notify the RenderWidget that it has been hidden or restored from
// having been hidden. // having been hidden.
virtual void WasHidden(); virtual void WasHidden();
...@@ -226,9 +229,6 @@ class CONTENT_EXPORT RenderWidgetHostImpl ...@@ -226,9 +229,6 @@ class CONTENT_EXPORT RenderWidgetHostImpl
// Notifies the RenderWidgetHost that the View was destroyed. // Notifies the RenderWidgetHost that the View was destroyed.
void ViewDestroyed(); void ViewDestroyed();
// Indicates if the page has finished loading.
void SetIsLoading(bool is_loading);
#if defined(OS_MACOSX) #if defined(OS_MACOSX)
// Pause for a moment to wait for pending repaint or resize messages sent to // Pause for a moment to wait for pending repaint or resize messages sent to
// the renderer to arrive. If pending resize messages are for an old window // the renderer to arrive. If pending resize messages are for an old window
......
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