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_manager.h" | 5 #include "content/browser/frame_host/render_frame_host_manager.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/debug/trace_event.h" | 10 #include "base/debug/trace_event.h" |
(...skipping 511 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
522 render_frame_host_->render_view_host()->SuppressDialogsUntilSwapOut(); | 522 render_frame_host_->render_view_host()->SuppressDialogsUntilSwapOut(); |
523 | 523 |
524 // Now close any modal dialogs that would prevent us from swapping out. This | 524 // Now close any modal dialogs that would prevent us from swapping out. This |
525 // must be done separately from SwapOut, so that the PageGroupLoadDeferrer is | 525 // must be done separately from SwapOut, so that the PageGroupLoadDeferrer is |
526 // no longer on the stack when we send the SwapOut message. | 526 // no longer on the stack when we send the SwapOut message. |
527 delegate_->CancelModalDialogsForRenderManager(); | 527 delegate_->CancelModalDialogsForRenderManager(); |
528 | 528 |
529 // Create the RenderFrameProxyHost that will replace the | 529 // Create the RenderFrameProxyHost that will replace the |
530 // RenderFrameHost which is swapping out. If one exists, ensure it is deleted | 530 // RenderFrameHost which is swapping out. If one exists, ensure it is deleted |
531 // from the map and not leaked. | 531 // from the map and not leaked. |
532 RenderFrameProxyHostMap::iterator iter = proxy_hosts_.find( | 532 DeleteRenderFrameProxyHost(render_frame_host_->GetSiteInstance()); |
533 render_frame_host_->GetSiteInstance()->GetId()); | |
534 if (iter != proxy_hosts_.end()) { | |
535 delete iter->second; | |
536 proxy_hosts_.erase(iter); | |
537 } | |
538 | 533 |
539 RenderFrameProxyHost* proxy = new RenderFrameProxyHost( | 534 RenderFrameProxyHost* proxy = new RenderFrameProxyHost( |
540 render_frame_host_->GetSiteInstance(), frame_tree_node_); | 535 render_frame_host_->GetSiteInstance(), frame_tree_node_); |
541 std::pair<RenderFrameProxyHostMap::iterator, bool> result = | 536 std::pair<RenderFrameProxyHostMap::iterator, bool> result = |
542 proxy_hosts_.insert(std::make_pair( | 537 proxy_hosts_.insert(std::make_pair( |
543 render_frame_host_->GetSiteInstance()->GetId(), proxy)); | 538 render_frame_host_->GetSiteInstance()->GetId(), proxy)); |
544 CHECK(result.second) << "Inserting a duplicate item."; | 539 CHECK(result.second) << "Inserting a duplicate item."; |
545 | 540 |
546 // Tell the old frame it is being swapped out. This will fire the unload | 541 // Tell the old frame it is being swapped out. This will fire the unload |
547 // handler in the background (without firing the beforeunload handler a second | 542 // handler in the background (without firing the beforeunload handler a second |
(...skipping 902 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1450 // doesn't otherwise know that the cross-site request is happening. This | 1445 // doesn't otherwise know that the cross-site request is happening. This |
1451 // will trigger a call to OnBeforeUnloadACK with the reply. | 1446 // will trigger a call to OnBeforeUnloadACK with the reply. |
1452 if (!is_transfer) | 1447 if (!is_transfer) |
1453 render_frame_host_->DispatchBeforeUnload(true); | 1448 render_frame_host_->DispatchBeforeUnload(true); |
1454 | 1449 |
1455 return pending_render_frame_host_.get(); | 1450 return pending_render_frame_host_.get(); |
1456 } | 1451 } |
1457 | 1452 |
1458 // Otherwise the same SiteInstance can be used. Navigate render_frame_host_. | 1453 // Otherwise the same SiteInstance can be used. Navigate render_frame_host_. |
1459 DCHECK(!cross_navigation_pending_); | 1454 DCHECK(!cross_navigation_pending_); |
| 1455 |
| 1456 // It's possible to swap out the current RFH and then decide to navigate in it |
| 1457 // anyway (e.g., a cross-process navigation that redirects back to the |
| 1458 // original site). In that case, we have a proxy for the current RFH but |
| 1459 // haven't deleted it yet. The new navigation will swap it back in, so we can |
| 1460 // delete the proxy. |
| 1461 DeleteRenderFrameProxyHost(new_instance); |
| 1462 |
1460 if (ShouldReuseWebUI(current_entry, &entry)) { | 1463 if (ShouldReuseWebUI(current_entry, &entry)) { |
1461 pending_web_ui_.reset(); | 1464 pending_web_ui_.reset(); |
1462 pending_and_current_web_ui_ = web_ui_->AsWeakPtr(); | 1465 pending_and_current_web_ui_ = web_ui_->AsWeakPtr(); |
1463 } else { | 1466 } else { |
1464 SetPendingWebUI(entry); | 1467 SetPendingWebUI(entry); |
1465 | 1468 |
1466 // Make sure the new RenderViewHost has the right bindings. | 1469 // Make sure the new RenderViewHost has the right bindings. |
1467 if (pending_web_ui() && | 1470 if (pending_web_ui() && |
1468 !render_frame_host_->GetProcess()->IsIsolatedGuest()) { | 1471 !render_frame_host_->GetProcess()->IsIsolatedGuest()) { |
1469 render_frame_host_->render_view_host()->AllowBindings( | 1472 render_frame_host_->render_view_host()->AllowBindings( |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1584 RenderFrameProxyHost* RenderFrameHostManager::GetRenderFrameProxyHost( | 1587 RenderFrameProxyHost* RenderFrameHostManager::GetRenderFrameProxyHost( |
1585 SiteInstance* instance) const { | 1588 SiteInstance* instance) const { |
1586 RenderFrameProxyHostMap::const_iterator iter = | 1589 RenderFrameProxyHostMap::const_iterator iter = |
1587 proxy_hosts_.find(instance->GetId()); | 1590 proxy_hosts_.find(instance->GetId()); |
1588 if (iter != proxy_hosts_.end()) | 1591 if (iter != proxy_hosts_.end()) |
1589 return iter->second; | 1592 return iter->second; |
1590 | 1593 |
1591 return NULL; | 1594 return NULL; |
1592 } | 1595 } |
1593 | 1596 |
| 1597 void RenderFrameHostManager::DeleteRenderFrameProxyHost( |
| 1598 SiteInstance* instance) { |
| 1599 RenderFrameProxyHostMap::iterator iter = proxy_hosts_.find(instance->GetId()); |
| 1600 if (iter != proxy_hosts_.end()) { |
| 1601 delete iter->second; |
| 1602 proxy_hosts_.erase(iter); |
| 1603 } |
| 1604 } |
| 1605 |
1594 } // namespace content | 1606 } // namespace content |
OLD | NEW |