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

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

Issue 1835833002: Fix 3 crashes related to navigations after a process dies. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Lots of cleanup Created 4 years, 8 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/frame_tree.h" 5 #include "content/browser/frame_host/frame_tree.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <queue> 9 #include <queue>
10 #include <utility> 10 #include <utility>
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after
348 bool hidden) { 348 bool hidden) {
349 RenderViewHostMap::iterator iter = 349 RenderViewHostMap::iterator iter =
350 render_view_host_map_.find(site_instance->GetId()); 350 render_view_host_map_.find(site_instance->GetId());
351 if (iter != render_view_host_map_.end()) { 351 if (iter != render_view_host_map_.end()) {
352 // If a RenderViewHost is pending deletion for this |site_instance|, it 352 // If a RenderViewHost is pending deletion for this |site_instance|, it
353 // shouldn't be reused, so put it in the map of RenderViewHosts pending 353 // shouldn't be reused, so put it in the map of RenderViewHosts pending
354 // shutdown. Otherwise, return the existing RenderViewHost for the 354 // shutdown. Otherwise, return the existing RenderViewHost for the
355 // SiteInstance. Note that if swapped-out is forbidden, the 355 // SiteInstance. Note that if swapped-out is forbidden, the
356 // RenderViewHost's main frame has already been cleared, so we cannot rely 356 // RenderViewHost's main frame has already been cleared, so we cannot rely
357 // on checking whether the main frame is pending deletion. 357 // on checking whether the main frame is pending deletion.
358 if (iter->second->is_pending_deletion()) { 358 if (root_->render_manager()->IsViewPendingDeletion(iter->second)) {
Charlie Reis 2016/03/28 19:06:36 Computing this on the fly rather than keeping a bi
alexmos 2016/03/29 18:43:01 Acknowledged.
359 render_view_host_pending_shutdown_map_.insert( 359 render_view_host_pending_shutdown_map_.insert(
360 std::make_pair(site_instance->GetId(), iter->second)); 360 std::make_pair(site_instance->GetId(), iter->second));
361 render_view_host_map_.erase(iter); 361 render_view_host_map_.erase(iter);
362 } else { 362 } else {
363 return iter->second; 363 return iter->second;
364 } 364 }
365 } 365 }
366 RenderViewHostImpl* rvh = 366 RenderViewHostImpl* rvh =
367 static_cast<RenderViewHostImpl*>(RenderViewHostFactory::Create( 367 static_cast<RenderViewHostImpl*>(RenderViewHostFactory::Create(
368 site_instance, render_view_delegate_, render_widget_delegate_, 368 site_instance, render_view_delegate_, render_widget_delegate_,
369 routing_id, main_frame_routing_id, swapped_out, hidden)); 369 routing_id, main_frame_routing_id, swapped_out, hidden));
370 370
371 render_view_host_map_[site_instance->GetId()] = rvh; 371 render_view_host_map_[site_instance->GetId()] = rvh;
372 return rvh; 372 return rvh;
373 } 373 }
374 374
375 RenderViewHostImpl* FrameTree::GetRenderViewHost(SiteInstance* site_instance) { 375 RenderViewHostImpl* FrameTree::GetRenderViewHost(SiteInstance* site_instance) {
376 RenderViewHostMap::iterator iter = 376 RenderViewHostMap::iterator iter =
377 render_view_host_map_.find(site_instance->GetId()); 377 render_view_host_map_.find(site_instance->GetId());
378 if (iter == render_view_host_map_.end()) 378 // Don't return the RVH if it is pending deletion.
379 return nullptr; 379 if (iter != render_view_host_map_.end() &&
380 return iter->second; 380 !root_->render_manager()->IsViewPendingDeletion(iter->second)) {
Charlie Reis 2016/03/28 19:06:36 This fixes 591478. (It would have been fixed by i
alexmos 2016/03/29 18:43:01 Acknowledged.
381 return iter->second;
382 }
383 return nullptr;
381 } 384 }
382 385
383 void FrameTree::AddRenderViewHostRef(RenderViewHostImpl* render_view_host) { 386 void FrameTree::AddRenderViewHostRef(RenderViewHostImpl* render_view_host) {
384 SiteInstance* site_instance = render_view_host->GetSiteInstance(); 387 SiteInstance* site_instance = render_view_host->GetSiteInstance();
385 RenderViewHostMap::iterator iter = 388 RenderViewHostMap::iterator iter =
386 render_view_host_map_.find(site_instance->GetId()); 389 render_view_host_map_.find(site_instance->GetId());
387 CHECK(iter != render_view_host_map_.end()); 390 CHECK(iter != render_view_host_map_.end());
388 CHECK(iter->second == render_view_host); 391 CHECK(iter->second == render_view_host);
389 392
390 iter->second->increment_ref_count(); 393 iter->second->increment_ref_count();
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
504 // This is only used to set page-level focus in cross-process subframes, and 507 // This is only used to set page-level focus in cross-process subframes, and
505 // requests to set focus in main frame's SiteInstance are ignored. 508 // requests to set focus in main frame's SiteInstance are ignored.
506 if (instance != root_manager->current_frame_host()->GetSiteInstance()) { 509 if (instance != root_manager->current_frame_host()->GetSiteInstance()) {
507 RenderFrameProxyHost* proxy = 510 RenderFrameProxyHost* proxy =
508 root_manager->GetRenderFrameProxyHost(instance); 511 root_manager->GetRenderFrameProxyHost(instance);
509 proxy->Send(new InputMsg_SetFocus(proxy->GetRoutingID(), is_focused)); 512 proxy->Send(new InputMsg_SetFocus(proxy->GetRoutingID(), is_focused));
510 } 513 }
511 } 514 }
512 515
513 } // namespace content 516 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698