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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/browser/frame_host/render_frame_host_impl.h" 5 #include "content/browser/frame_host/render_frame_host_impl.h"
6 6
7 #include "base/containers/hash_tables.h" 7 #include "base/containers/hash_tables.h"
8 #include "base/lazy_instance.h" 8 #include "base/lazy_instance.h"
9 #include "base/metrics/user_metrics_action.h" 9 #include "base/metrics/user_metrics_action.h"
10 #include "content/browser/child_process_security_policy_impl.h" 10 #include "content/browser/child_process_security_policy_impl.h"
11 #include "content/browser/frame_host/cross_process_frame_connector.h" 11 #include "content/browser/frame_host/cross_process_frame_connector.h"
12 #include "content/browser/frame_host/cross_site_transferring_request.h" 12 #include "content/browser/frame_host/cross_site_transferring_request.h"
13 #include "content/browser/frame_host/frame_tree.h" 13 #include "content/browser/frame_host/frame_tree.h"
14 #include "content/browser/frame_host/frame_tree_node.h" 14 #include "content/browser/frame_host/frame_tree_node.h"
15 #include "content/browser/frame_host/navigator.h" 15 #include "content/browser/frame_host/navigator.h"
16 #include "content/browser/frame_host/render_frame_host_delegate.h" 16 #include "content/browser/frame_host/render_frame_host_delegate.h"
17 #include "content/browser/renderer_host/render_view_host_impl.h" 17 #include "content/browser/renderer_host/render_view_host_impl.h"
18 #include "content/common/frame_messages.h" 18 #include "content/common/frame_messages.h"
19 #include "content/common/input_messages.h" 19 #include "content/common/input_messages.h"
20 #include "content/common/inter_process_time_ticks_converter.h" 20 #include "content/common/inter_process_time_ticks_converter.h"
21 #include "content/common/swapped_out_messages.h"
21 #include "content/public/browser/browser_thread.h" 22 #include "content/public/browser/browser_thread.h"
22 #include "content/public/browser/content_browser_client.h" 23 #include "content/public/browser/content_browser_client.h"
23 #include "content/public/browser/render_process_host.h" 24 #include "content/public/browser/render_process_host.h"
24 #include "content/public/browser/render_widget_host_view.h" 25 #include "content/public/browser/render_widget_host_view.h"
25 #include "content/public/browser/user_metrics.h" 26 #include "content/public/browser/user_metrics.h"
26 #include "content/public/common/url_constants.h" 27 #include "content/public/common/url_constants.h"
27 #include "url/gurl.h" 28 #include "url/gurl.h"
28 29
29 using base::TimeDelta; 30 using base::TimeDelta;
30 31
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 218
218 RenderViewHost* RenderFrameHostImpl::GetRenderViewHost() { 219 RenderViewHost* RenderFrameHostImpl::GetRenderViewHost() {
219 return render_view_host_; 220 return render_view_host_;
220 } 221 }
221 222
222 bool RenderFrameHostImpl::Send(IPC::Message* message) { 223 bool RenderFrameHostImpl::Send(IPC::Message* message) {
223 return GetProcess()->Send(message); 224 return GetProcess()->Send(message);
224 } 225 }
225 226
226 bool RenderFrameHostImpl::OnMessageReceived(const IPC::Message &msg) { 227 bool RenderFrameHostImpl::OnMessageReceived(const IPC::Message &msg) {
228 // Filter out most IPC messages if this renderer is swapped out.
229 // We still want to handle certain ACKs to keep our state consistent.
230 if (is_swapped_out_ || render_view_host_->IsSwappedOut()) {
231 if (!SwappedOutMessages::CanHandleWhileSwappedOut(msg)) {
232 // If this is a synchronous message and we decided not to handle it,
233 // we must send an error reply, or else the renderer will be stuck
234 // and won't respond to future requests.
235 if (msg.is_sync()) {
236 IPC::Message* reply = IPC::SyncMessage::GenerateReply(&msg);
237 reply->set_reply_error();
238 Send(reply);
239 }
240 // Don't continue looking for someone to handle it.
241 return true;
242 }
243 }
244
227 if (delegate_->OnMessageReceived(this, msg)) 245 if (delegate_->OnMessageReceived(this, msg))
228 return true; 246 return true;
229 247
230 if (cross_process_frame_connector_ && 248 if (cross_process_frame_connector_ &&
231 cross_process_frame_connector_->OnMessageReceived(msg)) 249 cross_process_frame_connector_->OnMessageReceived(msg))
232 return true; 250 return true;
233 251
234 bool handled = true; 252 bool handled = true;
235 bool msg_is_ok = true; 253 bool msg_is_ok = true;
236 IPC_BEGIN_MESSAGE_MAP_EX(RenderFrameHostImpl, msg, msg_is_ok) 254 IPC_BEGIN_MESSAGE_MAP_EX(RenderFrameHostImpl, msg, msg_is_ok)
(...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after
607 params.pending_history_list_offset = -1; 625 params.pending_history_list_offset = -1;
608 params.current_history_list_offset = -1; 626 params.current_history_list_offset = -1;
609 params.current_history_list_length = 0; 627 params.current_history_list_length = 0;
610 params.url = url; 628 params.url = url;
611 params.transition = PAGE_TRANSITION_LINK; 629 params.transition = PAGE_TRANSITION_LINK;
612 params.navigation_type = FrameMsg_Navigate_Type::NORMAL; 630 params.navigation_type = FrameMsg_Navigate_Type::NORMAL;
613 Navigate(params); 631 Navigate(params);
614 } 632 }
615 633
616 } // namespace content 634 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698