| 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/frame_tree.h" | 12 #include "content/browser/frame_host/frame_tree.h" |
| 13 #include "content/browser/frame_host/frame_tree_node.h" | 13 #include "content/browser/frame_host/frame_tree_node.h" |
| 14 #include "content/browser/frame_host/navigator.h" | 14 #include "content/browser/frame_host/navigator.h" |
| 15 #include "content/browser/frame_host/render_frame_host_delegate.h" | 15 #include "content/browser/frame_host/render_frame_host_delegate.h" |
| 16 #include "content/browser/renderer_host/render_view_host_impl.h" | 16 #include "content/browser/renderer_host/render_view_host_impl.h" |
| 17 #include "content/common/frame_messages.h" | 17 #include "content/common/frame_messages.h" |
| 18 #include "content/common/swapped_out_messages.h" |
| 18 #include "content/public/browser/browser_thread.h" | 19 #include "content/public/browser/browser_thread.h" |
| 19 #include "content/public/browser/content_browser_client.h" | 20 #include "content/public/browser/content_browser_client.h" |
| 20 #include "content/public/browser/render_process_host.h" | 21 #include "content/public/browser/render_process_host.h" |
| 21 #include "content/public/browser/render_widget_host_view.h" | 22 #include "content/public/browser/render_widget_host_view.h" |
| 22 #include "content/public/browser/user_metrics.h" | 23 #include "content/public/browser/user_metrics.h" |
| 23 #include "content/public/common/url_constants.h" | 24 #include "content/public/common/url_constants.h" |
| 24 #include "url/gurl.h" | 25 #include "url/gurl.h" |
| 25 | 26 |
| 26 namespace content { | 27 namespace content { |
| 27 | 28 |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 | 114 |
| 114 RenderViewHost* RenderFrameHostImpl::GetRenderViewHost() { | 115 RenderViewHost* RenderFrameHostImpl::GetRenderViewHost() { |
| 115 return render_view_host_; | 116 return render_view_host_; |
| 116 } | 117 } |
| 117 | 118 |
| 118 bool RenderFrameHostImpl::Send(IPC::Message* message) { | 119 bool RenderFrameHostImpl::Send(IPC::Message* message) { |
| 119 return GetProcess()->Send(message); | 120 return GetProcess()->Send(message); |
| 120 } | 121 } |
| 121 | 122 |
| 122 bool RenderFrameHostImpl::OnMessageReceived(const IPC::Message &msg) { | 123 bool RenderFrameHostImpl::OnMessageReceived(const IPC::Message &msg) { |
| 124 // Filter out most IPC messages if this renderer is swapped out. |
| 125 // We still want to handle certain ACKs to keep our state consistent. |
| 126 // TODO(nasko): Only check RenderViewHost state, as this object's own state |
| 127 // isn't yet properly updated. Transition this check once the swapped out |
| 128 // state is correct in RenderFrameHost itself. |
| 129 if (render_view_host_->IsSwappedOut()) { |
| 130 if (!SwappedOutMessages::CanHandleWhileSwappedOut(msg)) { |
| 131 // If this is a synchronous message and we decided not to handle it, |
| 132 // we must send an error reply, or else the renderer will be stuck |
| 133 // and won't respond to future requests. |
| 134 if (msg.is_sync()) { |
| 135 IPC::Message* reply = IPC::SyncMessage::GenerateReply(&msg); |
| 136 reply->set_reply_error(); |
| 137 Send(reply); |
| 138 } |
| 139 // Don't continue looking for someone to handle it. |
| 140 return true; |
| 141 } |
| 142 } |
| 143 |
| 123 if (delegate_->OnMessageReceived(this, msg)) | 144 if (delegate_->OnMessageReceived(this, msg)) |
| 124 return true; | 145 return true; |
| 125 | 146 |
| 126 if (cross_process_frame_connector_ && | 147 if (cross_process_frame_connector_ && |
| 127 cross_process_frame_connector_->OnMessageReceived(msg)) | 148 cross_process_frame_connector_->OnMessageReceived(msg)) |
| 128 return true; | 149 return true; |
| 129 | 150 |
| 130 bool handled = true; | 151 bool handled = true; |
| 131 bool msg_is_ok = true; | 152 bool msg_is_ok = true; |
| 132 IPC_BEGIN_MESSAGE_MAP_EX(RenderFrameHostImpl, msg, msg_is_ok) | 153 IPC_BEGIN_MESSAGE_MAP_EX(RenderFrameHostImpl, msg, msg_is_ok) |
| (...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 416 params.pending_history_list_offset = -1; | 437 params.pending_history_list_offset = -1; |
| 417 params.current_history_list_offset = -1; | 438 params.current_history_list_offset = -1; |
| 418 params.current_history_list_length = 0; | 439 params.current_history_list_length = 0; |
| 419 params.url = url; | 440 params.url = url; |
| 420 params.transition = PAGE_TRANSITION_LINK; | 441 params.transition = PAGE_TRANSITION_LINK; |
| 421 params.navigation_type = FrameMsg_Navigate_Type::NORMAL; | 442 params.navigation_type = FrameMsg_Navigate_Type::NORMAL; |
| 422 Navigate(params); | 443 Navigate(params); |
| 423 } | 444 } |
| 424 | 445 |
| 425 } // namespace content | 446 } // namespace content |
| OLD | NEW |