OLD | NEW |
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 Loading... |
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 // TODO(nasko): Only check RenderViewHost state, as this object's own state |
| 231 // isn't yet properly updated. Transition this check once the swapped out |
| 232 // state is correct in RenderFrameHost itself. |
| 233 if (render_view_host_->IsSwappedOut()) { |
| 234 if (!SwappedOutMessages::CanHandleWhileSwappedOut(msg)) { |
| 235 // If this is a synchronous message and we decided not to handle it, |
| 236 // we must send an error reply, or else the renderer will be stuck |
| 237 // and won't respond to future requests. |
| 238 if (msg.is_sync()) { |
| 239 IPC::Message* reply = IPC::SyncMessage::GenerateReply(&msg); |
| 240 reply->set_reply_error(); |
| 241 Send(reply); |
| 242 } |
| 243 // Don't continue looking for someone to handle it. |
| 244 return true; |
| 245 } |
| 246 } |
| 247 |
227 if (delegate_->OnMessageReceived(this, msg)) | 248 if (delegate_->OnMessageReceived(this, msg)) |
228 return true; | 249 return true; |
229 | 250 |
230 if (cross_process_frame_connector_ && | 251 if (cross_process_frame_connector_ && |
231 cross_process_frame_connector_->OnMessageReceived(msg)) | 252 cross_process_frame_connector_->OnMessageReceived(msg)) |
232 return true; | 253 return true; |
233 | 254 |
234 bool handled = true; | 255 bool handled = true; |
235 bool msg_is_ok = true; | 256 bool msg_is_ok = true; |
236 IPC_BEGIN_MESSAGE_MAP_EX(RenderFrameHostImpl, msg, msg_is_ok) | 257 IPC_BEGIN_MESSAGE_MAP_EX(RenderFrameHostImpl, msg, msg_is_ok) |
(...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
607 params.pending_history_list_offset = -1; | 628 params.pending_history_list_offset = -1; |
608 params.current_history_list_offset = -1; | 629 params.current_history_list_offset = -1; |
609 params.current_history_list_length = 0; | 630 params.current_history_list_length = 0; |
610 params.url = url; | 631 params.url = url; |
611 params.transition = PAGE_TRANSITION_LINK; | 632 params.transition = PAGE_TRANSITION_LINK; |
612 params.navigation_type = FrameMsg_Navigate_Type::NORMAL; | 633 params.navigation_type = FrameMsg_Navigate_Type::NORMAL; |
613 Navigate(params); | 634 Navigate(params); |
614 } | 635 } |
615 | 636 |
616 } // namespace content | 637 } // namespace content |
OLD | NEW |