diff options
author | rockot <rockot@chromium.org> | 2015-08-14 19:57:12 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-08-15 02:58:16 +0000 |
commit | 49e40cc11f68ffe6ede21f0c3e1db0239d456a7a (patch) | |
tree | 53a9455581d3de8b85764d259a50fb727f747aa4 /extensions/browser/app_window | |
parent | 8b605f21c02e8e920dcd7b26aa9716bb8ed751ad (diff) | |
download | chromium_src-49e40cc11f68ffe6ede21f0c3e1db0239d456a7a.zip chromium_src-49e40cc11f68ffe6ede21f0c3e1db0239d456a7a.tar.gz chromium_src-49e40cc11f68ffe6ede21f0c3e1db0239d456a7a.tar.bz2 |
Ensure proper ordering of app window request block/unblock
This fixes a race in app window initialization which could
cause resources to be permanently blocked from loading on
behalf of the renderer.
BUG=520750
TBR=kalman@chromium.org for tabs
TBR=nasko@chromium.org for IPC message (symbol rename only)
Review URL: https://codereview.chromium.org/1294923002
Cr-Commit-Position: refs/heads/master@{#343552}
Diffstat (limited to 'extensions/browser/app_window')
6 files changed, 39 insertions, 1 deletions
diff --git a/extensions/browser/app_window/app_window.cc b/extensions/browser/app_window/app_window.cc index 575062b..b6d7754 100644 --- a/extensions/browser/app_window/app_window.cc +++ b/extensions/browser/app_window/app_window.cc @@ -714,6 +714,11 @@ void AppWindow::WindowEventsReady() { SendOnWindowShownIfShown(); } +void AppWindow::NotifyRenderViewReady() { + if (app_window_contents_) + app_window_contents_->OnWindowReady(); +} + void AppWindow::GetSerializedState(base::DictionaryValue* properties) const { DCHECK(properties); diff --git a/extensions/browser/app_window/app_window.h b/extensions/browser/app_window/app_window.h index 449a729..4a06269 100644 --- a/extensions/browser/app_window/app_window.h +++ b/extensions/browser/app_window/app_window.h @@ -68,6 +68,9 @@ class AppWindowContents { // Called in tests when the window is shown virtual void DispatchWindowShownForTests() const = 0; + // Called when the renderer notifies the browser that the window is ready. + virtual void OnWindowReady() = 0; + virtual content::WebContents* GetWebContents() const = 0; virtual extensions::WindowController* GetWindowController() const = 0; @@ -341,6 +344,10 @@ class AppWindow : public content::WebContentsDelegate, // app. void WindowEventsReady(); + // Notifies the window's contents that the render view is ready and it can + // unblock resource requests. + void NotifyRenderViewReady(); + // Whether the app window wants to be alpha enabled. bool requested_alpha_enabled() const { return requested_alpha_enabled_; } diff --git a/extensions/browser/app_window/app_window_contents.cc b/extensions/browser/app_window/app_window_contents.cc index 8b95283..181e211 100644 --- a/extensions/browser/app_window/app_window_contents.cc +++ b/extensions/browser/app_window/app_window_contents.cc @@ -21,7 +21,8 @@ namespace extensions { -AppWindowContentsImpl::AppWindowContentsImpl(AppWindow* host) : host_(host) {} +AppWindowContentsImpl::AppWindowContentsImpl(AppWindow* host) + : host_(host), is_blocking_requests_(false), is_window_ready_(false) {} AppWindowContentsImpl::~AppWindowContentsImpl() {} @@ -84,6 +85,21 @@ void AppWindowContentsImpl::DispatchWindowShownForTests() const { "appWindowShownForTests", args, false)); } +void AppWindowContentsImpl::OnWindowReady() { + is_window_ready_ = true; + if (is_blocking_requests_) { + is_blocking_requests_ = false; + content::RenderFrameHost* frame = web_contents_->GetMainFrame(); + content::BrowserThread::PostTask( + content::BrowserThread::IO, FROM_HERE, + base::Bind( + &content::ResourceDispatcherHost::ResumeBlockedRequestsForRoute, + base::Unretained(content::ResourceDispatcherHost::Get()), + frame->GetProcess()->GetID(), + frame->GetRenderViewHost()->GetRoutingID())); + } +} + content::WebContents* AppWindowContentsImpl::GetWebContents() const { return web_contents_.get(); } @@ -110,6 +126,10 @@ void AppWindowContentsImpl::UpdateDraggableRegions( void AppWindowContentsImpl::SuspendRenderFrameHost( content::RenderFrameHost* rfh) { DCHECK(rfh); + // Don't bother blocking requests if the renderer side is already good to go. + if (is_window_ready_) + return; + is_blocking_requests_ = true; // The ResourceDispatcherHost only accepts RenderViewHost child ids. // TODO(devlin): This will need to change for site isolation. content::BrowserThread::PostTask( diff --git a/extensions/browser/app_window/app_window_contents.h b/extensions/browser/app_window/app_window_contents.h index 608b987..7656a68 100644 --- a/extensions/browser/app_window/app_window_contents.h +++ b/extensions/browser/app_window/app_window_contents.h @@ -35,6 +35,7 @@ class AppWindowContentsImpl : public AppWindowContents, void NativeWindowChanged(NativeAppWindow* native_app_window) override; void NativeWindowClosed() override; void DispatchWindowShownForTests() const override; + void OnWindowReady() override; content::WebContents* GetWebContents() const override; WindowController* GetWindowController() const override; @@ -48,6 +49,8 @@ class AppWindowContentsImpl : public AppWindowContents, AppWindow* host_; // This class is owned by |host_| GURL url_; scoped_ptr<content::WebContents> web_contents_; + bool is_blocking_requests_; + bool is_window_ready_; DISALLOW_COPY_AND_ASSIGN(AppWindowContentsImpl); }; diff --git a/extensions/browser/app_window/test_app_window_contents.cc b/extensions/browser/app_window/test_app_window_contents.cc index 18401e7..6cdefcb 100644 --- a/extensions/browser/app_window/test_app_window_contents.cc +++ b/extensions/browser/app_window/test_app_window_contents.cc @@ -32,6 +32,8 @@ void TestAppWindowContents::NativeWindowClosed() { void TestAppWindowContents::DispatchWindowShownForTests() const { } +void TestAppWindowContents::OnWindowReady() {} + content::WebContents* TestAppWindowContents::GetWebContents() const { return web_contents_.get(); } diff --git a/extensions/browser/app_window/test_app_window_contents.h b/extensions/browser/app_window/test_app_window_contents.h index d52fb97..97635aa 100644 --- a/extensions/browser/app_window/test_app_window_contents.h +++ b/extensions/browser/app_window/test_app_window_contents.h @@ -27,6 +27,7 @@ class TestAppWindowContents : public AppWindowContents { void NativeWindowChanged(NativeAppWindow* native_app_window) override; void NativeWindowClosed() override; void DispatchWindowShownForTests() const override; + void OnWindowReady() override; content::WebContents* GetWebContents() const override; WindowController* GetWindowController() const override; |