Skip to content

Commit

Permalink
A bunch of work to transition from render_view_id to render_frame_id.
Browse files Browse the repository at this point in the history
-remove ResourceRequestInfo::GetRenderViewForRequest
-reduce usage of GetAssociatedRenderView and add GetAssociatedRenderFrame which will replace it
-move the cookie jar from RenderView to RenderFrame
-switch most of the usages of RenderView to RenderFrame in WebPluginImpl

BUG=304341
R=boliu@chromium.org, nasko@chromium.org

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

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@242200 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
jam@chromium.org committed Dec 20, 2013
1 parent 13c3497 commit f3add92
Show file tree
Hide file tree
Showing 94 changed files with 356 additions and 300 deletions.
8 changes: 4 additions & 4 deletions android_webview/browser/aw_content_browser_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -258,28 +258,28 @@ bool AwContentBrowserClient::AllowGetCookie(const GURL& url,
const net::CookieList& cookie_list,
content::ResourceContext* context,
int render_process_id,
int render_view_id) {
int render_frame_id) {
return AwCookieAccessPolicy::GetInstance()->AllowGetCookie(url,
first_party,
cookie_list,
context,
render_process_id,
render_view_id);
render_frame_id);
}

bool AwContentBrowserClient::AllowSetCookie(const GURL& url,
const GURL& first_party,
const std::string& cookie_line,
content::ResourceContext* context,
int render_process_id,
int render_view_id,
int render_frame_id,
net::CookieOptions* options) {
return AwCookieAccessPolicy::GetInstance()->AllowSetCookie(url,
first_party,
cookie_line,
context,
render_process_id,
render_view_id,
render_frame_id,
options);
}

Expand Down
4 changes: 2 additions & 2 deletions android_webview/browser/aw_content_browser_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,13 @@ class AwContentBrowserClient : public content::ContentBrowserClient {
const net::CookieList& cookie_list,
content::ResourceContext* context,
int render_process_id,
int render_view_id) OVERRIDE;
int render_frame_id) OVERRIDE;
virtual bool AllowSetCookie(const GURL& url,
const GURL& first_party,
const std::string& cookie_line,
content::ResourceContext* context,
int render_process_id,
int render_view_id,
int render_frame_id,
net::CookieOptions* options) OVERRIDE;
virtual bool AllowWorkerDatabase(
const GURL& url,
Expand Down
4 changes: 2 additions & 2 deletions android_webview/browser/aw_contents_io_thread_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,11 @@ class AwContentsIoThreadClient {
virtual CacheMode GetCacheMode() const = 0;

// This will attempt to fetch the AwContentsIoThreadClient for the given
// |render_process_id|, |render_view_id| pair.
// |render_process_id|, |render_frame_id| pair.
// This method can be called from any thread.
// An empty scoped_ptr is a valid return value.
static scoped_ptr<AwContentsIoThreadClient> FromID(int render_process_id,
int render_view_id);
int render_frame_id);

// This method is called on the IO thread only.
virtual scoped_ptr<InterceptedRequestData> ShouldInterceptRequest(
Expand Down
4 changes: 2 additions & 2 deletions android_webview/browser/aw_cookie_access_policy.cc
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ bool AwCookieAccessPolicy::AllowGetCookie(const GURL& url,
const net::CookieList& cookie_list,
content::ResourceContext* context,
int render_process_id,
int render_view_id) {
int render_frame_id) {
return GetGlobalAllowAccess();
}

Expand All @@ -63,7 +63,7 @@ bool AwCookieAccessPolicy::AllowSetCookie(const GURL& url,
const std::string& cookie_line,
content::ResourceContext* context,
int render_process_id,
int render_view_id,
int render_frame_id,
net::CookieOptions* options) {
return GetGlobalAllowAccess();
}
Expand Down
4 changes: 2 additions & 2 deletions android_webview/browser/aw_cookie_access_policy.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,13 @@ class AwCookieAccessPolicy {
const net::CookieList& cookie_list,
content::ResourceContext* context,
int render_process_id,
int render_view_id);
int render_frame_id);
bool AllowSetCookie(const GURL& url,
const GURL& first_party,
const std::string& cookie_line,
content::ResourceContext* context,
int render_process_id,
int render_view_id,
int render_frame_id,
net::CookieOptions* options);

private:
Expand Down
20 changes: 10 additions & 10 deletions android_webview/browser/aw_login_delegate.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#include "base/logging.h"
#include "base/supports_user_data.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/render_view_host.h"
#include "content/public/browser/render_frame_host.h"
#include "content/public/browser/resource_dispatcher_host.h"
#include "content/public/browser/resource_request_info.h"
#include "content/public/browser/web_contents.h"
Expand All @@ -18,7 +18,7 @@
using namespace base::android;

using content::BrowserThread;
using content::RenderViewHost;
using content::RenderFrameHost;
using content::ResourceDispatcherHost;
using content::ResourceRequestInfo;
using content::WebContents;
Expand All @@ -41,9 +41,9 @@ AwLoginDelegate::AwLoginDelegate(net::AuthChallengeInfo* auth_info,
: auth_info_(auth_info),
request_(request),
render_process_id_(0),
render_view_id_(0) {
ResourceRequestInfo::GetRenderViewForRequest(
request, &render_process_id_, &render_view_id_);
render_frame_id_(0) {
ResourceRequestInfo::GetRenderFrameForRequest(
request, &render_process_id_, &render_frame_id_);

UrlRequestAuthAttemptsData* count =
static_cast<UrlRequestAuthAttemptsData*>(
Expand Down Expand Up @@ -87,15 +87,15 @@ void AwLoginDelegate::HandleHttpAuthRequestOnUIThread(
aw_http_auth_handler_.reset(AwHttpAuthHandlerBase::Create(
this, auth_info_.get(), first_auth_attempt));

RenderViewHost* render_view_host = RenderViewHost::FromID(
render_process_id_, render_view_id_);
if (!render_view_host) {
RenderFrameHost* render_frame_host = RenderFrameHost::FromID(
render_process_id_, render_frame_id_);
if (!render_frame_host) {
Cancel();
return;
}

WebContents* web_contents = WebContents::FromRenderViewHost(
render_view_host);
WebContents* web_contents = WebContents::FromRenderFrameHost(
render_frame_host);
if (!aw_http_auth_handler_->HandleOnUIThread(web_contents)) {
Cancel();
return;
Expand Down
2 changes: 1 addition & 1 deletion android_webview/browser/aw_login_delegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class AwLoginDelegate :
scoped_refptr<net::AuthChallengeInfo> auth_info_;
net::URLRequest* request_;
int render_process_id_;
int render_view_id_;
int render_frame_id_;
};

} // namespace android_webview
Expand Down
8 changes: 4 additions & 4 deletions android_webview/browser/aw_request_interceptor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,13 @@ AwRequestInterceptor::QueryForInterceptedRequestData(
const GURL& location,
net::URLRequest* request) const {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
int render_process_id, render_view_id;
if (!ResourceRequestInfo::GetRenderViewForRequest(
request, &render_process_id, &render_view_id))
int render_process_id, render_frame_id;
if (!ResourceRequestInfo::GetRenderFrameForRequest(
request, &render_process_id, &render_frame_id))
return scoped_ptr<InterceptedRequestData>();

scoped_ptr<AwContentsIoThreadClient> io_thread_client =
AwContentsIoThreadClient::FromID(render_process_id, render_view_id);
AwContentsIoThreadClient::FromID(render_process_id, render_frame_id);

if (!io_thread_client.get())
return scoped_ptr<InterceptedRequestData>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,13 @@ namespace android_webview {

// Calls through the IoThreadClient to check the embedders settings to determine
// if the request should be cancelled. There may not always be an IoThreadClient
// available for the |child_id|, |route_id| pair (in the case of newly created
// pop up windows, for example) and in that case the request and the client
// callbacks will be deferred the request until a client is ready.
// available for the |render_process_id|, |render_frame_id| pair (in the case of
// newly created pop up windows, for example) and in that case the request and
// the client callbacks will be deferred the request until a client is ready.
class IoThreadClientThrottle : public content::ResourceThrottle {
public:
IoThreadClientThrottle(int child_id,
int route_id,
IoThreadClientThrottle(int render_process_id,
int render_frame_id,
net::URLRequest* request);
virtual ~IoThreadClientThrottle();

Expand All @@ -68,23 +68,24 @@ class IoThreadClientThrottle : public content::ResourceThrottle {
virtual void WillRedirectRequest(const GURL& new_url, bool* defer) OVERRIDE;
virtual const char* GetNameForLogging() const OVERRIDE;

void OnIoThreadClientReady(int new_child_id, int new_route_id);
void OnIoThreadClientReady(int new_render_process_id,
int new_render_frame_id);
bool MaybeBlockRequest();
bool ShouldBlockRequest();
int get_child_id() const { return child_id_; }
int get_route_id() const { return route_id_; }
int render_process_id() const { return render_process_id_; }
int render_frame_id() const { return render_frame_id_; }

private:
int child_id_;
int route_id_;
private:
int render_process_id_;
int render_frame_id_;
net::URLRequest* request_;
};

IoThreadClientThrottle::IoThreadClientThrottle(int child_id,
int route_id,
IoThreadClientThrottle::IoThreadClientThrottle(int render_process_id,
int render_frame_id,
net::URLRequest* request)
: child_id_(child_id),
route_id_(route_id),
: render_process_id_(render_process_id),
render_frame_id_(render_frame_id),
request_(request) { }

IoThreadClientThrottle::~IoThreadClientThrottle() {
Expand All @@ -100,22 +101,22 @@ const char* IoThreadClientThrottle::GetNameForLogging() const {
void IoThreadClientThrottle::WillStartRequest(bool* defer) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
// TODO(sgurun): This block can be removed when crbug.com/277937 is fixed.
if (route_id_ < 1) {
if (render_frame_id_ < 1) {
// OPTIONS is used for preflighted requests which are generated internally.
DCHECK_EQ("OPTIONS", request_->method());
return;
}
DCHECK(child_id_);
DCHECK(render_process_id_);
*defer = false;

// Defer all requests of a pop up that is still not associated with Java
// client so that the client will get a chance to override requests.
scoped_ptr<AwContentsIoThreadClient> io_client =
AwContentsIoThreadClient::FromID(child_id_, route_id_);
AwContentsIoThreadClient::FromID(render_process_id_, render_frame_id_);
if (io_client && io_client->PendingAssociation()) {
*defer = true;
AwResourceDispatcherHostDelegate::AddPendingThrottle(
child_id_, route_id_, this);
render_process_id_, render_frame_id_, this);
} else {
MaybeBlockRequest();
}
Expand All @@ -126,8 +127,8 @@ void IoThreadClientThrottle::WillRedirectRequest(const GURL& new_url,
WillStartRequest(defer);
}

void IoThreadClientThrottle::OnIoThreadClientReady(int new_child_id,
int new_route_id) {
void IoThreadClientThrottle::OnIoThreadClientReady(int new_render_process_id,
int new_render_frame_id) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));

if (!MaybeBlockRequest()) {
Expand All @@ -145,7 +146,7 @@ bool IoThreadClientThrottle::MaybeBlockRequest() {

bool IoThreadClientThrottle::ShouldBlockRequest() {
scoped_ptr<AwContentsIoThreadClient> io_client =
AwContentsIoThreadClient::FromID(child_id_, route_id_);
AwContentsIoThreadClient::FromID(render_process_id_, render_frame_id_);
if (!io_client)
return false;

Expand Down Expand Up @@ -215,13 +216,16 @@ void AwResourceDispatcherHostDelegate::RequestBeginning(

AddExtraHeadersIfNeeded(request, resource_context);

const content::ResourceRequestInfo* request_info =
content::ResourceRequestInfo::ForRequest(request);

// We always push the throttles here. Checking the existence of io_client
// is racy when a popup window is created. That is because RequestBeginning
// is called whether or not requests are blocked via BlockRequestForRoute()
// however io_client may or may not be ready at the time depending on whether
// webcontents is created.
throttles->push_back(new IoThreadClientThrottle(
child_id, route_id, request));
child_id, request_info->GetRenderFrameID(), request));

// We allow intercepting only navigations within main frames. This
// is used to post onPageStarted. We handle shouldOverrideUrlLoading
Expand Down Expand Up @@ -268,8 +272,12 @@ void AwResourceDispatcherHostDelegate::DownloadStarting(

request->Cancel();

const content::ResourceRequestInfo* request_info =
content::ResourceRequestInfo::ForRequest(request);

scoped_ptr<AwContentsIoThreadClient> io_client =
AwContentsIoThreadClient::FromID(child_id, route_id);
AwContentsIoThreadClient::FromID(
child_id, request_info->GetRenderFrameID());

// POST request cannot be repeated in general, so prevent client from
// retrying the same request, even if it is with a GET.
Expand Down Expand Up @@ -337,7 +345,7 @@ void AwResourceDispatcherHostDelegate::OnResponseStarted(
request, auto_login_parser::ALLOW_ANY_REALM, &header_data)) {
scoped_ptr<AwContentsIoThreadClient> io_client =
AwContentsIoThreadClient::FromID(request_info->GetChildID(),
request_info->GetRouteID());
request_info->GetRenderFrameID());
if (io_client) {
io_client->NewLoginRequest(
header_data.realm, header_data.account, header_data.args);
Expand All @@ -350,57 +358,59 @@ void AwResourceDispatcherHostDelegate::RemovePendingThrottleOnIoThread(
IoThreadClientThrottle* throttle) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
PendingThrottleMap::iterator it = pending_throttles_.find(
ChildRouteIDPair(throttle->get_child_id(), throttle->get_route_id()));
FrameRouteIDPair(throttle->render_process_id(),
throttle->render_frame_id()));
if (it != pending_throttles_.end()) {
pending_throttles_.erase(it);
}
}

// static
void AwResourceDispatcherHostDelegate::OnIoThreadClientReady(
int new_child_id,
int new_route_id) {
int new_render_process_id,
int new_render_frame_id) {
BrowserThread::PostTask(BrowserThread::IO, FROM_HERE,
base::Bind(
&AwResourceDispatcherHostDelegate::OnIoThreadClientReadyInternal,
base::Unretained(
g_webview_resource_dispatcher_host_delegate.Pointer()),
new_child_id, new_route_id));
new_render_process_id, new_render_frame_id));
}

// static
void AwResourceDispatcherHostDelegate::AddPendingThrottle(
int child_id,
int route_id,
int render_process_id,
int render_frame_id,
IoThreadClientThrottle* pending_throttle) {
BrowserThread::PostTask(BrowserThread::IO, FROM_HERE,
base::Bind(
&AwResourceDispatcherHostDelegate::AddPendingThrottleOnIoThread,
base::Unretained(
g_webview_resource_dispatcher_host_delegate.Pointer()),
child_id, route_id, pending_throttle));
render_process_id, render_frame_id, pending_throttle));
}

void AwResourceDispatcherHostDelegate::AddPendingThrottleOnIoThread(
int child_id,
int route_id,
int render_process_id,
int render_frame_id_id,
IoThreadClientThrottle* pending_throttle) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
pending_throttles_.insert(
std::pair<ChildRouteIDPair, IoThreadClientThrottle*>(
ChildRouteIDPair(child_id, route_id), pending_throttle));
std::pair<FrameRouteIDPair, IoThreadClientThrottle*>(
FrameRouteIDPair(render_process_id, render_frame_id_id),
pending_throttle));
}

void AwResourceDispatcherHostDelegate::OnIoThreadClientReadyInternal(
int new_child_id,
int new_route_id) {
int new_render_process_id,
int new_render_frame_id) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
PendingThrottleMap::iterator it = pending_throttles_.find(
ChildRouteIDPair(new_child_id, new_route_id));
FrameRouteIDPair(new_render_process_id, new_render_frame_id));

if (it != pending_throttles_.end()) {
IoThreadClientThrottle* throttle = it->second;
throttle->OnIoThreadClientReady(new_child_id, new_route_id);
throttle->OnIoThreadClientReady(new_render_process_id, new_render_frame_id);
pending_throttles_.erase(it);
}
}
Expand Down
Loading

0 comments on commit f3add92

Please sign in to comment.