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

Side by Side Diff: content/browser/frame_host/render_frame_host_impl.cc

Issue 438393004: Revert of Start using RenderFrameProxyHost objects. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 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 unified diff | Download patch
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/bind.h" 7 #include "base/bind.h"
8 #include "base/containers/hash_tables.h" 8 #include "base/containers/hash_tables.h"
9 #include "base/lazy_instance.h" 9 #include "base/lazy_instance.h"
10 #include "base/metrics/user_metrics_action.h" 10 #include "base/metrics/user_metrics_action.h"
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 } 137 }
138 138
139 } // namespace 139 } // namespace
140 140
141 RenderFrameHost* RenderFrameHost::FromID(int render_process_id, 141 RenderFrameHost* RenderFrameHost::FromID(int render_process_id,
142 int render_frame_id) { 142 int render_frame_id) {
143 return RenderFrameHostImpl::FromID(render_process_id, render_frame_id); 143 return RenderFrameHostImpl::FromID(render_process_id, render_frame_id);
144 } 144 }
145 145
146 // static 146 // static
147 RenderFrameHostImpl* RenderFrameHostImpl::FromID(int process_id, 147 RenderFrameHostImpl* RenderFrameHostImpl::FromID(
148 int routing_id) { 148 int process_id, int routing_id) {
149 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 149 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
150 RoutingIDFrameMap* frames = g_routing_id_frame_map.Pointer(); 150 RoutingIDFrameMap* frames = g_routing_id_frame_map.Pointer();
151 RoutingIDFrameMap::iterator it = frames->find( 151 RoutingIDFrameMap::iterator it = frames->find(
152 RenderFrameHostID(process_id, routing_id)); 152 RenderFrameHostID(process_id, routing_id));
153 return it == frames->end() ? NULL : it->second; 153 return it == frames->end() ? NULL : it->second;
154 } 154 }
155 155
156 RenderFrameHostImpl::RenderFrameHostImpl(RenderViewHostImpl* render_view_host, 156 RenderFrameHostImpl::RenderFrameHostImpl(
157 RenderFrameHostDelegate* delegate, 157 RenderViewHostImpl* render_view_host,
158 FrameTree* frame_tree, 158 RenderFrameHostDelegate* delegate,
159 FrameTreeNode* frame_tree_node, 159 FrameTree* frame_tree,
160 int routing_id, 160 FrameTreeNode* frame_tree_node,
161 bool is_swapped_out) 161 int routing_id,
162 bool is_swapped_out)
162 : render_view_host_(render_view_host), 163 : render_view_host_(render_view_host),
163 delegate_(delegate), 164 delegate_(delegate),
164 cross_process_frame_connector_(NULL), 165 cross_process_frame_connector_(NULL),
165 render_frame_proxy_host_(NULL), 166 render_frame_proxy_host_(NULL),
166 frame_tree_(frame_tree), 167 frame_tree_(frame_tree),
167 frame_tree_node_(frame_tree_node), 168 frame_tree_node_(frame_tree_node),
168 routing_id_(routing_id), 169 routing_id_(routing_id),
169 is_swapped_out_(is_swapped_out), 170 is_swapped_out_(is_swapped_out),
170 renderer_initialized_(false),
171 weak_ptr_factory_(this) { 171 weak_ptr_factory_(this) {
172 frame_tree_->RegisterRenderFrameHost(this); 172 frame_tree_->RegisterRenderFrameHost(this);
173 GetProcess()->AddRoute(routing_id_, this); 173 GetProcess()->AddRoute(routing_id_, this);
174 g_routing_id_frame_map.Get().insert(std::make_pair( 174 g_routing_id_frame_map.Get().insert(std::make_pair(
175 RenderFrameHostID(GetProcess()->GetID(), routing_id_), 175 RenderFrameHostID(GetProcess()->GetID(), routing_id_),
176 this)); 176 this));
177 177
178 if (GetProcess()->GetServiceRegistry()) { 178 if (GetProcess()->GetServiceRegistry()) {
179 RenderFrameSetupPtr setup; 179 RenderFrameSetupPtr setup;
180 GetProcess()->GetServiceRegistry()->ConnectToRemoteService(&setup); 180 GetProcess()->GetServiceRegistry()->ConnectToRemoteService(&setup);
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
268 static_cast<RenderProcessHostImpl*>(GetProcess())->EnsureMojoActivated(); 268 static_cast<RenderProcessHostImpl*>(GetProcess())->EnsureMojoActivated();
269 return &service_registry_; 269 return &service_registry_;
270 } 270 }
271 271
272 bool RenderFrameHostImpl::Send(IPC::Message* message) { 272 bool RenderFrameHostImpl::Send(IPC::Message* message) {
273 if (IPC_MESSAGE_ID_CLASS(message->type()) == InputMsgStart) { 273 if (IPC_MESSAGE_ID_CLASS(message->type()) == InputMsgStart) {
274 return render_view_host_->input_router()->SendInput( 274 return render_view_host_->input_router()->SendInput(
275 make_scoped_ptr(message)); 275 make_scoped_ptr(message));
276 } 276 }
277 277
278 // Route IPCs through the RenderFrameProxyHost when in swapped out state. 278 if (render_view_host_->IsSwappedOut()) {
279 // Note: For subframes in --site-per-process mode, we don't use swapped out
280 // RenderFrameHosts.
281 if (frame_tree_node_->IsMainFrame() && render_view_host_->IsSwappedOut()) {
282 DCHECK(render_frame_proxy_host_); 279 DCHECK(render_frame_proxy_host_);
283 return render_frame_proxy_host_->Send(message); 280 return render_frame_proxy_host_->Send(message);
284 } 281 }
285 282
286 return GetProcess()->Send(message); 283 return GetProcess()->Send(message);
287 } 284 }
288 285
289 bool RenderFrameHostImpl::OnMessageReceived(const IPC::Message &msg) { 286 bool RenderFrameHostImpl::OnMessageReceived(const IPC::Message &msg) {
290 // Filter out most IPC messages if this renderer is swapped out. 287 // Filter out most IPC messages if this renderer is swapped out.
291 // We still want to handle certain ACKs to keep our state consistent. 288 // We still want to handle certain ACKs to keep our state consistent.
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
445 442
446 gfx::NativeViewAccessible 443 gfx::NativeViewAccessible
447 RenderFrameHostImpl::AccessibilityGetNativeViewAccessible() { 444 RenderFrameHostImpl::AccessibilityGetNativeViewAccessible() {
448 RenderWidgetHostViewBase* view = static_cast<RenderWidgetHostViewBase*>( 445 RenderWidgetHostViewBase* view = static_cast<RenderWidgetHostViewBase*>(
449 render_view_host_->GetView()); 446 render_view_host_->GetView());
450 if (view) 447 if (view)
451 return view->AccessibilityGetNativeViewAccessible(); 448 return view->AccessibilityGetNativeViewAccessible();
452 return NULL; 449 return NULL;
453 } 450 }
454 451
455 bool RenderFrameHostImpl::CreateRenderFrame(int parent_routing_id) {
456 TRACE_EVENT0("frame_host", "RenderFrameHostImpl::CreateRenderFrame");
457 DCHECK(!IsRenderFrameLive()) << "Creating frame twice";
458
459 // The process may (if we're sharing a process with another host that already
460 // initialized it) or may not (we have our own process or the old process
461 // crashed) have been initialized. Calling Init multiple times will be
462 // ignored, so this is safe.
463 if (!GetProcess()->Init())
464 return false;
465
466 DCHECK(GetProcess()->HasConnection());
467
468 renderer_initialized_ = true;
469 Send(new FrameMsg_NewFrame(routing_id_, parent_routing_id));
470
471 return true;
472 }
473
474 bool RenderFrameHostImpl::IsRenderFrameLive() {
475 return GetProcess()->HasConnection() && renderer_initialized_;
476 }
477
478 void RenderFrameHostImpl::Init() { 452 void RenderFrameHostImpl::Init() {
479 GetProcess()->ResumeRequestsForView(routing_id_); 453 GetProcess()->ResumeRequestsForView(routing_id_);
480 } 454 }
481 455
482 void RenderFrameHostImpl::OnAddMessageToConsole( 456 void RenderFrameHostImpl::OnAddMessageToConsole(
483 int32 level, 457 int32 level,
484 const base::string16& message, 458 const base::string16& message,
485 int32 line_no, 459 int32 line_no,
486 const base::string16& source_id) { 460 const base::string16& source_id) {
487 if (delegate_->AddMessageToConsole(level, message, line_no, source_id)) 461 if (delegate_->AddMessageToConsole(level, message, line_no, source_id))
(...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after
909 WebTextDirectionToChromeTextDirection( 883 WebTextDirectionToChromeTextDirection(
910 title_direction)); 884 title_direction));
911 } 885 }
912 886
913 void RenderFrameHostImpl::OnUpdateEncoding(const std::string& encoding_name) { 887 void RenderFrameHostImpl::OnUpdateEncoding(const std::string& encoding_name) {
914 // This message is only sent for top-level frames. TODO(avi): when frame tree 888 // This message is only sent for top-level frames. TODO(avi): when frame tree
915 // mirroring works correctly, add a check here to enforce it. 889 // mirroring works correctly, add a check here to enforce it.
916 delegate_->UpdateEncoding(this, encoding_name); 890 delegate_->UpdateEncoding(this, encoding_name);
917 } 891 }
918 892
893
919 void RenderFrameHostImpl::OnBeginNavigation( 894 void RenderFrameHostImpl::OnBeginNavigation(
920 const FrameHostMsg_BeginNavigation_Params& params) { 895 const FrameHostMsg_BeginNavigation_Params& params) {
921 #if defined(USE_BROWSER_SIDE_NAVIGATION) 896 #if defined(USE_BROWSER_SIDE_NAVIGATION)
922 frame_tree_node()->render_manager()->OnBeginNavigation(params); 897 frame_tree_node()->render_manager()->OnBeginNavigation(params);
923 #endif 898 #endif
924 } 899 }
925 900
926 void RenderFrameHostImpl::OnAccessibilityEvents( 901 void RenderFrameHostImpl::OnAccessibilityEvents(
927 const std::vector<AccessibilityHostMsg_EventParams>& params) { 902 const std::vector<AccessibilityHostMsg_EventParams>& params) {
928 RenderWidgetHostViewBase* view = static_cast<RenderWidgetHostViewBase*>( 903 RenderWidgetHostViewBase* view = static_cast<RenderWidgetHostViewBase*>(
929 render_view_host_->GetView()); 904 render_view_host_->GetView());
930 905
906
931 AccessibilityMode accessibility_mode = delegate_->GetAccessibilityMode(); 907 AccessibilityMode accessibility_mode = delegate_->GetAccessibilityMode();
932 if ((accessibility_mode != AccessibilityModeOff) && view && 908 if ((accessibility_mode != AccessibilityModeOff) && view &&
933 RenderViewHostImpl::IsRVHStateActive(render_view_host_->rvh_state())) { 909 RenderViewHostImpl::IsRVHStateActive(render_view_host_->rvh_state())) {
934 if (accessibility_mode & AccessibilityModeFlagPlatform) { 910 if (accessibility_mode & AccessibilityModeFlagPlatform) {
935 GetOrCreateBrowserAccessibilityManager(); 911 GetOrCreateBrowserAccessibilityManager();
936 if (browser_accessibility_manager_) 912 if (browser_accessibility_manager_)
937 browser_accessibility_manager_->OnAccessibilityEvents(params); 913 browser_accessibility_manager_->OnAccessibilityEvents(params);
938 } 914 }
939 915
940 std::vector<AXEventNotificationDetails> details; 916 std::vector<AXEventNotificationDetails> details;
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
1215 FROM_HERE, 1191 FROM_HERE,
1216 base::Bind( 1192 base::Bind(
1217 &TransitionRequestManager::SetHasPendingTransitionRequest, 1193 &TransitionRequestManager::SetHasPendingTransitionRequest,
1218 base::Unretained(TransitionRequestManager::GetInstance()), 1194 base::Unretained(TransitionRequestManager::GetInstance()),
1219 GetProcess()->GetID(), 1195 GetProcess()->GetID(),
1220 routing_id_, 1196 routing_id_,
1221 has_pending_request)); 1197 has_pending_request));
1222 } 1198 }
1223 1199
1224 } // namespace content 1200 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/frame_host/render_frame_host_impl.h ('k') | content/browser/frame_host/render_frame_host_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698