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

Unified Diff: content/browser/frame_host/render_frame_host_impl.cc

Issue 196133032: Add test for filtering of IPC messages when RenderFrameHost is swapped out. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 9 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/browser/frame_host/render_frame_host_impl.cc
diff --git a/content/browser/frame_host/render_frame_host_impl.cc b/content/browser/frame_host/render_frame_host_impl.cc
index a70eb9397d3f57ac915f12c8a3ab7aa4d226aa18..f401cf3d6a4ad32929c45875e4c7fc80b0f59cc7 100644
--- a/content/browser/frame_host/render_frame_host_impl.cc
+++ b/content/browser/frame_host/render_frame_host_impl.cc
@@ -18,6 +18,7 @@
#include "content/common/frame_messages.h"
#include "content/common/input_messages.h"
#include "content/common/inter_process_time_ticks_converter.h"
+#include "content/common/swapped_out_messages.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/content_browser_client.h"
#include "content/public/browser/render_process_host.h"
@@ -224,6 +225,23 @@ bool RenderFrameHostImpl::Send(IPC::Message* message) {
}
bool RenderFrameHostImpl::OnMessageReceived(const IPC::Message &msg) {
+ // Filter out most IPC messages if this renderer is swapped out.
+ // We still want to handle certain ACKs to keep our state consistent.
+ if (is_swapped_out_ || render_view_host_->IsSwappedOut()) {
+ if (!SwappedOutMessages::CanHandleWhileSwappedOut(msg)) {
+ // If this is a synchronous message and we decided not to handle it,
+ // we must send an error reply, or else the renderer will be stuck
+ // and won't respond to future requests.
+ if (msg.is_sync()) {
+ IPC::Message* reply = IPC::SyncMessage::GenerateReply(&msg);
+ reply->set_reply_error();
+ Send(reply);
+ }
+ // Don't continue looking for someone to handle it.
+ return true;
+ }
+ }
+
if (delegate_->OnMessageReceived(this, msg))
return true;

Powered by Google App Engine
This is Rietveld 408576698