Commit 5440a8ec authored by Lukasz Anforowicz's avatar Lukasz Anforowicz Committed by Commit Bot

Removing callers of the WebContents::GetRenderProcessHost() method.

WebContents::GetRenderProcessHost is an API that doesn't behave as
expected with out-of-process iframes, as multiple processes can be
associated with a single WebContents.  This CL replaces callers of this
API, so that they go through an equivalent API that explicitly selects
which frame's process is needed.

This CL was started by using an ad-hoc clang-plugin that replaced
existing callsites of WebContents::GetRenderProcessHost() with a call to
something like wc->GetMainFrame()->GetProcess().  This was followed-up
by manually adding an include of render_frame_host.h and git cl format
and git cl lint and then a self-review with small tweaks (e.g. sometimes
using a wc->GetRenderViewHost()->GetProcess() is more appropriate).

This CL was uploaded by git cl split.

R=rdsmith@chromium.org

Bug: 666525
Change-Id: I97adc233a59bd7edc9a95fce1c2db458a2caf48f
Reviewed-on: https://chromium-review.googlesource.com/688005Reviewed-by: default avatarRandy Smith <rdsmith@chromium.org>
Commit-Queue: Łukasz Anforowicz <lukasza@chromium.org>
Cr-Commit-Position: refs/heads/master@{#505061}
parent e3a0864f
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
#include "content/browser/web_contents/web_contents_impl.h" #include "content/browser/web_contents/web_contents_impl.h"
#include "content/public/browser/browser_context.h" #include "content/public/browser/browser_context.h"
#include "content/public/browser/browser_thread.h" #include "content/public/browser/browser_thread.h"
#include "content/public/browser/render_frame_host.h"
#include "content/public/browser/resource_dispatcher_host_delegate.h" #include "content/public/browser/resource_dispatcher_host_delegate.h"
#include "content/public/browser/resource_request_info.h" #include "content/public/browser/resource_request_info.h"
#include "content/public/browser/web_contents.h" #include "content/public/browser/web_contents.h"
...@@ -270,9 +271,9 @@ std::unique_ptr<net::test_server::HttpResponse> CancelOnRequest( ...@@ -270,9 +271,9 @@ std::unique_ptr<net::test_server::HttpResponse> CancelOnRequest(
// response to call to AsyncResourceHandler::OnResponseComplete. // response to call to AsyncResourceHandler::OnResponseComplete.
IN_PROC_BROWSER_TEST_F(ResourceDispatcherHostBrowserTest, IN_PROC_BROWSER_TEST_F(ResourceDispatcherHostBrowserTest,
SyncXMLHttpRequest_Cancelled) { SyncXMLHttpRequest_Cancelled) {
embedded_test_server()->RegisterRequestHandler( embedded_test_server()->RegisterRequestHandler(base::Bind(
base::Bind(&CancelOnRequest, "/hung", &CancelOnRequest, "/hung",
shell()->web_contents()->GetRenderProcessHost()->GetID())); shell()->web_contents()->GetMainFrame()->GetProcess()->GetID()));
ASSERT_TRUE(embedded_test_server()->Start()); ASSERT_TRUE(embedded_test_server()->Start());
WaitForLoadStop(shell()->web_contents()); WaitForLoadStop(shell()->web_contents());
......
...@@ -45,6 +45,7 @@ ...@@ -45,6 +45,7 @@
#include "content/common/view_messages.h" #include "content/common/view_messages.h"
#include "content/public/browser/browser_thread.h" #include "content/public/browser/browser_thread.h"
#include "content/public/browser/global_request_id.h" #include "content/public/browser/global_request_id.h"
#include "content/public/browser/render_frame_host.h"
#include "content/public/browser/render_process_host.h" #include "content/public/browser/render_process_host.h"
#include "content/public/browser/render_view_host.h" #include "content/public/browser/render_view_host.h"
#include "content/public/browser/resource_context.h" #include "content/public/browser/resource_context.h"
...@@ -911,8 +912,8 @@ class ResourceDispatcherHostTest : public testing::Test, public IPC::Sender { ...@@ -911,8 +912,8 @@ class ResourceDispatcherHostTest : public testing::Test, public IPC::Sender {
new TestWebContentsObserver(web_contents_.get())); new TestWebContentsObserver(web_contents_.get()));
web_contents_filter_ = new TestFilterSpecifyingChild( web_contents_filter_ = new TestFilterSpecifyingChild(
browser_context_->GetResourceContext(), browser_context_->GetResourceContext(),
web_contents_->GetRenderProcessHost()->GetID()); web_contents_->GetMainFrame()->GetProcess()->GetID());
child_ids_.insert(web_contents_->GetRenderProcessHost()->GetID()); child_ids_.insert(web_contents_->GetMainFrame()->GetProcess()->GetID());
request_context_getter_ = new net::TestURLRequestContextGetter( request_context_getter_ = new net::TestURLRequestContextGetter(
content::BrowserThread::GetTaskRunnerForThread( content::BrowserThread::GetTaskRunnerForThread(
content::BrowserThread::UI)); content::BrowserThread::UI));
...@@ -1204,7 +1205,7 @@ void ResourceDispatcherHostTest:: ...@@ -1204,7 +1205,7 @@ void ResourceDispatcherHostTest::
const GURL& url, const GURL& url,
ResourceType type) { ResourceType type) {
ResourceRequest request = CreateResourceRequest("GET", type, url); ResourceRequest request = CreateResourceRequest("GET", type, url);
request.origin_pid = web_contents_->GetRenderProcessHost()->GetID(); request.origin_pid = web_contents_->GetMainFrame()->GetProcess()->GetID();
request.render_frame_id = web_contents_->GetMainFrame()->GetRoutingID(); request.render_frame_id = web_contents_->GetMainFrame()->GetRoutingID();
ResourceHostMsg_RequestResource msg( ResourceHostMsg_RequestResource msg(
web_contents_->GetRenderViewHost()->GetRoutingID(), request_id, request, web_contents_->GetRenderViewHost()->GetRoutingID(), request_id, request,
...@@ -1246,7 +1247,7 @@ void ResourceDispatcherHostTest::MakeWebContentsAssociatedDownloadRequest( ...@@ -1246,7 +1247,7 @@ void ResourceDispatcherHostTest::MakeWebContentsAssociatedDownloadRequest(
DownloadManagerImpl::BeginDownloadRequest( DownloadManagerImpl::BeginDownloadRequest(
std::move(request), Referrer(), browser_context_->GetResourceContext(), std::move(request), Referrer(), browser_context_->GetResourceContext(),
false, // is_content_initiated false, // is_content_initiated
web_contents_->GetRenderProcessHost()->GetID(), web_contents_->GetRenderViewHost()->GetProcess()->GetID(),
web_contents_->GetRenderViewHost()->GetRoutingID(), web_contents_->GetRenderViewHost()->GetRoutingID(),
web_contents_->GetMainFrame()->GetRoutingID(), false); web_contents_->GetMainFrame()->GetRoutingID(), false);
} }
......
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