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

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: bleck 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
« no previous file with comments | « content/renderer/render_frame_impl.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/renderer/render_frame_impl.cc
diff --git a/content/renderer/render_frame_impl.cc b/content/renderer/render_frame_impl.cc
index a6cf03b61c62c576eedd093783a0ecb65d07fc54..8671506c34e683da4cce88b1eb0ff1138fbff922 100644
--- a/content/renderer/render_frame_impl.cc
+++ b/content/renderer/render_frame_impl.cc
@@ -4,14 +4,17 @@
#include "content/renderer/render_frame_impl.h"
+#include "base/command_line.h"
#include "base/strings/utf_string_conversions.h"
#include "base/time/time.h"
#include "content/child/appcache/appcache_dispatcher.h"
#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/content_switches.h"
#include "content/public/common/url_constants.h"
#include "content/public/renderer/content_renderer_client.h"
#include "content/public/renderer/document_state.h"
@@ -94,29 +97,36 @@ 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),
+ is_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_;
}
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 (is_detaching_ ||
+ (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);
+ // TODO(ajwong): Fill in with message handlers as various components
+ // are migrated over to understand frames.
+ return false;
}
// WebKit::WebFrameClient implementation -------------------------------------
@@ -164,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;
@@ -176,7 +186,7 @@ WebKit::WebSharedWorker* RenderFrameImpl::createSharedWorker(
document_id,
exists,
route_id,
- GetRoutingID());
+ render_view_->GetRoutingID());
}
}
@@ -210,7 +220,9 @@ 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(),
child->identifier(), UTF16ToUTF8(child->assignedName())));
}
@@ -219,12 +231,25 @@ void RenderFrameImpl::didDisownOpener(WebKit::WebFrame* frame) {
}
void RenderFrameImpl::frameDetached(WebKit::WebFrame* frame) {
+ // Currently multiple WebCore::Frames can send frameDetached to a single
+ // RenderFrameImpl. This is legacy behavior from when RenderViewImpl served
+ // as a shared WebFrameClient for multiple Webcore::Frame objects. It also
+ // prevents this class from entering the |is_detaching_| state because
+ // even though one WebCore::Frame may have detached itself, others will
+ // still need to use this object.
+ if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kSitePerProcess)) {
+ // TODO(ajwong): Add CHECK(!is_detaching_) once we guarantee each
+ // RenderFrameImpl is only used by one WebCore::Frame.
+ is_detaching_ = true;
+ }
+
int64 parent_frame_id = -1;
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,
+ frame->identifier()));
// Call back to RenderViewImpl for observers to be notified.
// TODO(nasko): Remove once we have RenderFrameObserver.
@@ -242,10 +267,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,
@@ -261,8 +287,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);
}
@@ -387,8 +414,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.
@@ -568,7 +597,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()) {
@@ -654,8 +683,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(),
@@ -664,22 +693,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,
@@ -716,8 +747,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,
@@ -727,24 +760,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::requestStorageQuota(
@@ -760,14 +787,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(
@@ -825,8 +852,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));
@@ -835,7 +862,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));
« no previous file with comments | « content/renderer/render_frame_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698