Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(428)

Unified Diff: content/renderer/render_frame_impl.cc

Issue 22876014: Make RenderFrame{Host} objects routable. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix style errors. Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/renderer/render_frame_impl.cc
diff --git a/content/renderer/render_frame_impl.cc b/content/renderer/render_frame_impl.cc
index 784e988182b1e4e89324d0bd2c1066c69f1e365f..165c79623626b4a323c26ecbeace42f7746e1ec3 100644
--- a/content/renderer/render_frame_impl.cc
+++ b/content/renderer/render_frame_impl.cc
@@ -12,6 +12,7 @@
#include "content/child/quota_dispatcher.h"
#include "content/child/request_extra_data.h"
#include "content/common/socket_stream_handle_data.h"
+#include "content/common/swapped_out_messages.h"
#include "content/common/view_messages.h"
#include "content/public/common/content_constants.h"
#include "content/public/common/url_constants.h"
@@ -98,29 +99,34 @@ void RenderFrameImpl::InstallCreateHook(
// RenderFrameImpl ----------------------------------------------------------
RenderFrameImpl::RenderFrameImpl(RenderViewImpl* render_view, int routing_id)
: render_view_(render_view),
- routing_id_(routing_id) {
+ routing_id_(routing_id),
+ is_swapped_out_(false),
+ detaching_(false) {
}
RenderFrameImpl::~RenderFrameImpl() {
}
int RenderFrameImpl::GetRoutingID() const {
- // TODO(nasko): Until we register RenderFrameHost in the browser process as
- // a listener, we must route all messages to the RenderViewHost, so use the
- // routing id of the RenderView for now.
- return render_view_->GetRoutingID();
+ return routing_id_;
Charlie Reis 2013/08/26 18:27:10 I'm not sure I understand the intention of changin
awong 2013/08/27 19:58:13 The guiding thought was to make all uses of render
}
bool RenderFrameImpl::Send(IPC::Message* message) {
- // TODO(nasko): Move away from using the RenderView's Send method once we
- // have enough infrastructure and state to make the right checks here.
- return render_view_->Send(message);
+ if (detaching_ ||
Charlie Reis 2013/08/26 18:27:10 This is never set to true. Why include it?
awong 2013/08/27 19:58:13 Honestly, I was trying to replicated RenderViewHos
+ (is_swapped_out_ &&
+ !SwappedOutMessages::CanSendWhileSwappedOut(message))) {
+ delete message;
+ return false;
+ }
+
+ if (message->routing_id() == MSG_ROUTING_NONE)
+ message->set_routing_id(routing_id_);
+
+ return RenderThread::Get()->Send(message);
}
bool RenderFrameImpl::OnMessageReceived(const IPC::Message& msg) {
- // Pass the message up to the RenderView, until we have enough
- // infrastructure to start processing messages in this object.
- return render_view_->OnMessageReceived(msg);
+ return false;
Charlie Reis 2013/08/26 18:27:10 Maybe add a TODO comment here about what the inten
awong 2013/08/27 19:58:13 Done.
}
// WebKit::WebFrameClient implementation -------------------------------------
@@ -168,10 +174,10 @@ WebKit::WebSharedWorker* RenderFrameImpl::createSharedWorker(
params.url = url;
params.name = name;
params.document_id = document_id;
- params.render_view_route_id = GetRoutingID();
+ params.render_view_route_id = render_view_->GetRoutingID();
params.route_id = MSG_ROUTING_NONE;
params.script_resource_appcache_id = 0;
- Send(new ViewHostMsg_LookupSharedWorker(
+ render_view_->Send(new ViewHostMsg_LookupSharedWorker(
params, &exists, &route_id, &url_mismatch));
if (url_mismatch) {
return NULL;
@@ -180,7 +186,7 @@ WebKit::WebSharedWorker* RenderFrameImpl::createSharedWorker(
document_id,
exists,
route_id,
- GetRoutingID());
+ render_view_->GetRoutingID());
}
}
@@ -214,7 +220,8 @@ void RenderFrameImpl::didAccessInitialDocument(WebKit::WebFrame* frame) {
void RenderFrameImpl::didCreateFrame(WebKit::WebFrame* parent,
WebKit::WebFrame* child) {
- Send(new ViewHostMsg_FrameAttached(GetRoutingID(), parent->identifier(),
+ render_view_->Send(new ViewHostMsg_FrameAttached(render_view_->GetRoutingID(),
+ parent->identifier(),
Charlie Reis 2013/08/26 18:27:10 nit: Wrong indent.
awong 2013/08/27 19:58:13 Done.
child->identifier(), UTF16ToUTF8(child->assignedName())));
}
@@ -227,8 +234,9 @@ void RenderFrameImpl::frameDetached(WebKit::WebFrame* frame) {
if (frame->parent())
parent_frame_id = frame->parent()->identifier();
- Send(new ViewHostMsg_FrameDetached(GetRoutingID(), parent_frame_id,
- frame->identifier()));
+ render_view_->Send(new ViewHostMsg_FrameDetached(render_view_->GetRoutingID(),
+ parent_frame_id,
Charlie Reis 2013/08/26 18:27:10 nit: Wrong indent.
awong 2013/08/27 19:58:13 Done.
+ frame->identifier()));
// Call back to RenderViewImpl for observers to be notified.
// TODO(nasko): Remove once we have RenderFrameObserver.
@@ -246,10 +254,11 @@ void RenderFrameImpl::didChangeName(WebKit::WebFrame* frame,
if (!render_view_->renderer_preferences_.report_frame_name_changes)
return;
- Send(new ViewHostMsg_UpdateFrameName(GetRoutingID(),
- frame->identifier(),
- !frame->parent(),
- UTF16ToUTF8(name)));
+ render_view_->Send(
+ new ViewHostMsg_UpdateFrameName(render_view_->GetRoutingID(),
+ frame->identifier(),
+ !frame->parent(),
+ UTF16ToUTF8(name)));
}
void RenderFrameImpl::loadURLExternally(WebKit::WebFrame* frame,
@@ -265,8 +274,9 @@ void RenderFrameImpl::loadURLExternally(
const WebKit::WebString& suggested_name) {
Referrer referrer(RenderViewImpl::GetReferrerFromRequest(frame, request));
if (policy == WebKit::WebNavigationPolicyDownload) {
- Send(new ViewHostMsg_DownloadUrl(GetRoutingID(), request.url(), referrer,
- suggested_name));
+ render_view_->Send(new ViewHostMsg_DownloadUrl(render_view_->GetRoutingID(),
+ request.url(), referrer,
+ suggested_name));
} else {
render_view_->OpenURL(frame, request.url(), referrer, policy);
}
@@ -380,8 +390,10 @@ void RenderFrameImpl::didCreateDocumentElement(WebKit::WebFrame* frame) {
if (url.is_valid() && url.spec() != kAboutBlankURL) {
// TODO(nasko): Check if webview()->mainFrame() is the same as the
// frame->tree()->top().
- if (frame == render_view_->webview()->mainFrame())
- Send(new ViewHostMsg_DocumentAvailableInMainFrame(GetRoutingID()));
+ if (frame == render_view_->webview()->mainFrame()) {
+ render_view_->Send(new ViewHostMsg_DocumentAvailableInMainFrame(
+ render_view_->GetRoutingID()));
+ }
}
// Call back to RenderViewImpl for observers to be notified.
@@ -560,7 +572,7 @@ void RenderFrameImpl::willSendRequest(
// into the data portion of the message. This can cause problems if we
// don't register this id on the browser side, since the download manager
// expects to find a RenderViewHost based off the id.
- request.setRequestorID(GetRoutingID());
+ request.setRequestorID(render_view_->GetRoutingID());
request.setHasUserGesture(WebUserGestureIndicator::isProcessingUserGesture());
if (!navigation_state->extra_headers().empty()) {
@@ -646,8 +658,8 @@ void RenderFrameImpl::didLoadResourceFromMemoryCache(
// Let the browser know we loaded a resource from the memory cache. This
// message is needed to display the correct SSL indicators.
- Send(new ViewHostMsg_DidLoadResourceFromMemoryCache(
- GetRoutingID(),
+ render_view_->Send(new ViewHostMsg_DidLoadResourceFromMemoryCache(
+ render_view_->GetRoutingID(),
url,
response.securityInfo(),
request.httpMethod().utf8(),
@@ -656,22 +668,24 @@ void RenderFrameImpl::didLoadResourceFromMemoryCache(
}
void RenderFrameImpl::didDisplayInsecureContent(WebKit::WebFrame* frame) {
- Send(new ViewHostMsg_DidDisplayInsecureContent(GetRoutingID()));
+ render_view_->Send(new ViewHostMsg_DidDisplayInsecureContent(
+ render_view_->GetRoutingID()));
}
void RenderFrameImpl::didRunInsecureContent(
WebKit::WebFrame* frame,
const WebKit::WebSecurityOrigin& origin,
const WebKit::WebURL& target) {
- Send(new ViewHostMsg_DidRunInsecureContent(
- GetRoutingID(),
+ render_view_->Send(new ViewHostMsg_DidRunInsecureContent(
+ render_view_->GetRoutingID(),
origin.toString().utf8(),
target));
}
void RenderFrameImpl::didExhaustMemoryAvailableForScript(
WebKit::WebFrame* frame) {
- Send(new ViewHostMsg_JSOutOfMemory(GetRoutingID()));
+ render_view_->Send(new ViewHostMsg_JSOutOfMemory(
+ render_view_->GetRoutingID()));
}
void RenderFrameImpl::didCreateScriptContext(WebKit::WebFrame* frame,
@@ -708,8 +722,10 @@ void RenderFrameImpl::didChangeScrollOffset(WebKit::WebFrame* frame) {
}
void RenderFrameImpl::willInsertBody(WebKit::WebFrame* frame) {
- if (!frame->parent())
- Send(new ViewHostMsg_WillInsertBody(GetRoutingID()));
+ if (!frame->parent()) {
+ render_view_->Send(new ViewHostMsg_WillInsertBody(
+ render_view_->GetRoutingID()));
+ }
}
void RenderFrameImpl::reportFindInPageMatchCount(int request_id,
@@ -719,24 +735,18 @@ void RenderFrameImpl::reportFindInPageMatchCount(int request_id,
if (!count)
active_match_ordinal = 0;
- Send(new ViewHostMsg_Find_Reply(GetRoutingID(),
- request_id,
- count,
- gfx::Rect(),
- active_match_ordinal,
- final_update));
+ render_view_->Send(new ViewHostMsg_Find_Reply(
+ render_view_->GetRoutingID(), request_id, count,
+ gfx::Rect(), active_match_ordinal, final_update));
}
void RenderFrameImpl::reportFindInPageSelection(
int request_id,
int active_match_ordinal,
const WebKit::WebRect& selection_rect) {
- Send(new ViewHostMsg_Find_Reply(GetRoutingID(),
- request_id,
- -1,
- selection_rect,
- active_match_ordinal,
- false));
+ render_view_->Send(new ViewHostMsg_Find_Reply(
+ render_view_->GetRoutingID(), request_id, -1, selection_rect,
+ active_match_ordinal, false));
}
void RenderFrameImpl::openFileSystem(
@@ -793,14 +803,14 @@ void RenderFrameImpl::requestStorageQuota(
return;
}
ChildThread::current()->quota_dispatcher()->RequestStorageQuota(
- GetRoutingID(), GURL(origin.toString()),
+ render_view_->GetRoutingID(), GURL(origin.toString()),
static_cast<quota::StorageType>(type), requested_size,
QuotaDispatcher::CreateWebStorageQuotaCallbacksWrapper(callbacks));
}
void RenderFrameImpl::willOpenSocketStream(
WebKit::WebSocketStreamHandle* handle) {
- SocketStreamHandleData::AddToHandle(handle, GetRoutingID());
+ SocketStreamHandleData::AddToHandle(handle, render_view_->GetRoutingID());
}
void RenderFrameImpl::willStartUsingPeerConnectionHandler(
@@ -858,8 +868,8 @@ bool RenderFrameImpl::allowWebGL(WebKit::WebFrame* frame, bool default_value) {
return false;
bool blocked = true;
- Send(new ViewHostMsg_Are3DAPIsBlocked(
- GetRoutingID(),
+ render_view_->Send(new ViewHostMsg_Are3DAPIsBlocked(
+ render_view_->GetRoutingID(),
GURL(frame->top()->document().securityOrigin().toString()),
THREE_D_API_TYPE_WEBGL,
&blocked));
@@ -868,7 +878,7 @@ bool RenderFrameImpl::allowWebGL(WebKit::WebFrame* frame, bool default_value) {
void RenderFrameImpl::didLoseWebGLContext(WebKit::WebFrame* frame,
int arb_robustness_status_code) {
- Send(new ViewHostMsg_DidLose3DContext(
+ render_view_->Send(new ViewHostMsg_DidLose3DContext(
GURL(frame->top()->document().securityOrigin().toString()),
THREE_D_API_TYPE_WEBGL,
arb_robustness_status_code));
« content/renderer/render_frame_impl.h ('K') | « content/renderer/render_frame_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698