Chromium Code Reviews| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 730 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 741 iter++) { | 741 iter++) { |
| 742 if (iter->get() == render_frame_host) { | 742 if (iter->get() == render_frame_host) { |
| 743 pending_delete_hosts_.erase(iter); | 743 pending_delete_hosts_.erase(iter); |
| 744 return true; | 744 return true; |
| 745 } | 745 } |
| 746 } | 746 } |
| 747 return false; | 747 return false; |
| 748 } | 748 } |
| 749 | 749 |
| 750 void RenderFrameHostManager::ResetProxyHosts() { | 750 void RenderFrameHostManager::ResetProxyHosts() { |
| 751 for (auto& pair : proxy_hosts_) { | 751 for (const auto& pair : proxy_hosts_) { |
| 752 static_cast<SiteInstanceImpl*>(pair.second->GetSiteInstance()) | 752 static_cast<SiteInstanceImpl*>(pair.second->GetSiteInstance()) |
| 753 ->RemoveObserver(this); | 753 ->RemoveObserver(this); |
| 754 } | 754 } |
| 755 proxy_hosts_.clear(); | 755 proxy_hosts_.clear(); |
| 756 } | 756 } |
| 757 | 757 |
| 758 void RenderFrameHostManager::ClearRFHsPendingShutdown() { | 758 void RenderFrameHostManager::ClearRFHsPendingShutdown() { |
| 759 pending_delete_hosts_.clear(); | 759 pending_delete_hosts_.clear(); |
| 760 } | 760 } |
| 761 | 761 |
| (...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1004 proxy->PassFrameHostOwnership(); | 1004 proxy->PassFrameHostOwnership(); |
| 1005 MoveToPendingDeleteHosts(std::move(swapped_out_rfh)); | 1005 MoveToPendingDeleteHosts(std::move(swapped_out_rfh)); |
| 1006 } | 1006 } |
| 1007 | 1007 |
| 1008 DeleteRenderFrameProxyHost(site_instance); | 1008 DeleteRenderFrameProxyHost(site_instance); |
| 1009 } | 1009 } |
| 1010 | 1010 |
| 1011 RenderFrameProxyHost* RenderFrameHostManager::CreateRenderFrameProxyHost( | 1011 RenderFrameProxyHost* RenderFrameHostManager::CreateRenderFrameProxyHost( |
| 1012 SiteInstance* site_instance, | 1012 SiteInstance* site_instance, |
| 1013 RenderViewHostImpl* rvh) { | 1013 RenderViewHostImpl* rvh) { |
| 1014 auto result = proxy_hosts_.add(site_instance->GetId(), | 1014 int site_instance_id = site_instance->GetId(); |
| 1015 make_scoped_ptr(new RenderFrameProxyHost( | 1015 CHECK(proxy_hosts_.find(site_instance_id) == proxy_hosts_.end()) |
| 1016 site_instance, rvh, frame_tree_node_))); | 1016 << "A proxy already existed for this SiteInstance."; |
| 1017 CHECK(result.second) << "A proxy already existed for this SiteInstance."; | 1017 RenderFrameProxyHost* proxy_host = |
| 1018 new RenderFrameProxyHost(site_instance, rvh, frame_tree_node_); | |
| 1019 proxy_hosts_[site_instance_id] = make_scoped_ptr(proxy_host); | |
|
nasko
2016/02/12 18:14:08
Why was this rewrite necessary?
lfg
2016/03/02 18:29:08
Moved to another CL.
| |
| 1018 static_cast<SiteInstanceImpl*>(site_instance)->AddObserver(this); | 1020 static_cast<SiteInstanceImpl*>(site_instance)->AddObserver(this); |
| 1019 return result.first->second; | 1021 return proxy_host; |
| 1020 } | 1022 } |
| 1021 | 1023 |
| 1022 void RenderFrameHostManager::DeleteRenderFrameProxyHost( | 1024 void RenderFrameHostManager::DeleteRenderFrameProxyHost( |
| 1023 SiteInstance* site_instance) { | 1025 SiteInstance* site_instance) { |
| 1024 static_cast<SiteInstanceImpl*>(site_instance)->RemoveObserver(this); | 1026 static_cast<SiteInstanceImpl*>(site_instance)->RemoveObserver(this); |
| 1025 proxy_hosts_.erase(site_instance->GetId()); | 1027 proxy_hosts_.erase(site_instance->GetId()); |
| 1026 } | 1028 } |
| 1027 | 1029 |
| 1028 bool RenderFrameHostManager::ShouldTransitionCrossSite() { | 1030 bool RenderFrameHostManager::ShouldTransitionCrossSite() { |
| 1029 // The logic below is weaker than "are all sites isolated" -- it asks instead, | 1031 // The logic below is weaker than "are all sites isolated" -- it asks instead, |
| (...skipping 719 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1749 | 1751 |
| 1750 return proxy->GetRoutingID(); | 1752 return proxy->GetRoutingID(); |
| 1751 } | 1753 } |
| 1752 | 1754 |
| 1753 void RenderFrameHostManager::CreateProxiesForChildFrame(FrameTreeNode* child) { | 1755 void RenderFrameHostManager::CreateProxiesForChildFrame(FrameTreeNode* child) { |
| 1754 RenderFrameProxyHost* outer_delegate_proxy = | 1756 RenderFrameProxyHost* outer_delegate_proxy = |
| 1755 ForInnerDelegate() ? GetProxyToOuterDelegate() : nullptr; | 1757 ForInnerDelegate() ? GetProxyToOuterDelegate() : nullptr; |
| 1756 for (const auto& pair : proxy_hosts_) { | 1758 for (const auto& pair : proxy_hosts_) { |
| 1757 // Do not create proxies for subframes in the outer delegate's process, | 1759 // Do not create proxies for subframes in the outer delegate's process, |
| 1758 // since the outer delegate does not need to interact with them. | 1760 // since the outer delegate does not need to interact with them. |
| 1759 if (pair.second == outer_delegate_proxy) | 1761 if (pair.second.get() == outer_delegate_proxy) |
| 1760 continue; | 1762 continue; |
| 1761 | 1763 |
| 1762 child->render_manager()->CreateRenderFrameProxy( | 1764 child->render_manager()->CreateRenderFrameProxy( |
| 1763 pair.second->GetSiteInstance()); | 1765 pair.second->GetSiteInstance()); |
| 1764 } | 1766 } |
| 1765 } | 1767 } |
| 1766 | 1768 |
| 1767 void RenderFrameHostManager::EnsureRenderViewInitialized( | 1769 void RenderFrameHostManager::EnsureRenderViewInitialized( |
| 1768 RenderViewHostImpl* render_view_host, | 1770 RenderViewHostImpl* render_view_host, |
| 1769 SiteInstance* instance) { | 1771 SiteInstance* instance) { |
| (...skipping 555 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2325 RenderFrameProxyHost* proxy = GetRenderFrameProxyHost(instance); | 2327 RenderFrameProxyHost* proxy = GetRenderFrameProxyHost(instance); |
| 2326 if (proxy) | 2328 if (proxy) |
| 2327 return proxy->GetRenderViewHost(); | 2329 return proxy->GetRenderViewHost(); |
| 2328 return nullptr; | 2330 return nullptr; |
| 2329 } | 2331 } |
| 2330 | 2332 |
| 2331 RenderFrameProxyHost* RenderFrameHostManager::GetRenderFrameProxyHost( | 2333 RenderFrameProxyHost* RenderFrameHostManager::GetRenderFrameProxyHost( |
| 2332 SiteInstance* instance) const { | 2334 SiteInstance* instance) const { |
| 2333 auto it = proxy_hosts_.find(instance->GetId()); | 2335 auto it = proxy_hosts_.find(instance->GetId()); |
| 2334 if (it != proxy_hosts_.end()) | 2336 if (it != proxy_hosts_.end()) |
| 2335 return it->second; | 2337 return it->second.get(); |
| 2336 return nullptr; | 2338 return nullptr; |
| 2337 } | 2339 } |
| 2338 | 2340 |
| 2339 int RenderFrameHostManager::GetProxyCount() { | 2341 int RenderFrameHostManager::GetProxyCount() { |
| 2340 return proxy_hosts_.size(); | 2342 return proxy_hosts_.size(); |
| 2341 } | 2343 } |
| 2342 | 2344 |
| 2343 std::map<int, RenderFrameProxyHost*> | |
| 2344 RenderFrameHostManager::GetAllProxyHostsForTesting() { | |
| 2345 std::map<int, RenderFrameProxyHost*> result; | |
| 2346 for (const auto& pair : proxy_hosts_) | |
| 2347 result[pair.first] = pair.second; | |
| 2348 return result; | |
| 2349 } | |
| 2350 | |
| 2351 void RenderFrameHostManager::CollectOpenerFrameTrees( | 2345 void RenderFrameHostManager::CollectOpenerFrameTrees( |
| 2352 std::vector<FrameTree*>* opener_frame_trees, | 2346 std::vector<FrameTree*>* opener_frame_trees, |
| 2353 base::hash_set<FrameTreeNode*>* nodes_with_back_links) { | 2347 base::hash_set<FrameTreeNode*>* nodes_with_back_links) { |
| 2354 CHECK(opener_frame_trees); | 2348 CHECK(opener_frame_trees); |
| 2355 opener_frame_trees->push_back(frame_tree_node_->frame_tree()); | 2349 opener_frame_trees->push_back(frame_tree_node_->frame_tree()); |
| 2356 | 2350 |
| 2357 // Add the FrameTree of the given node's opener to the list of | 2351 // Add the FrameTree of the given node's opener to the list of |
| 2358 // |opener_frame_trees| if it doesn't exist there already. |visited_index| | 2352 // |opener_frame_trees| if it doesn't exist there already. |visited_index| |
| 2359 // indicates which FrameTrees in |opener_frame_trees| have already been | 2353 // indicates which FrameTrees in |opener_frame_trees| have already been |
| 2360 // visited (i.e., those at indices less than |visited_index|). | 2354 // visited (i.e., those at indices less than |visited_index|). |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2483 | 2477 |
| 2484 int RenderFrameHostManager::GetOpenerRoutingID(SiteInstance* instance) { | 2478 int RenderFrameHostManager::GetOpenerRoutingID(SiteInstance* instance) { |
| 2485 if (!frame_tree_node_->opener()) | 2479 if (!frame_tree_node_->opener()) |
| 2486 return MSG_ROUTING_NONE; | 2480 return MSG_ROUTING_NONE; |
| 2487 | 2481 |
| 2488 return frame_tree_node_->opener() | 2482 return frame_tree_node_->opener() |
| 2489 ->render_manager() | 2483 ->render_manager() |
| 2490 ->GetRoutingIdForSiteInstance(instance); | 2484 ->GetRoutingIdForSiteInstance(instance); |
| 2491 } | 2485 } |
| 2492 | 2486 |
| 2487 void RenderFrameHostManager::SendPageMsg(IPC::Message* msg) { | |
| 2488 DCHECK(IPC_MESSAGE_CLASS(*msg) == PageMsgStart); | |
|
nasko
2016/02/12 18:14:08
Should this method return if the IPC is not a Page
lfg
2016/03/02 18:29:08
Done.
| |
| 2489 | |
| 2490 // We should always deliver page messages through the main frame. | |
| 2491 DCHECK(!frame_tree_node_->parent()); | |
|
nasko
2016/02/12 18:14:08
Same as above. What happens when the DCHECK is vio
lfg
2016/03/02 18:29:08
We shouldn't write code to violate the DCHECK ;)
| |
| 2492 | |
| 2493 for (const auto& pair : proxy_hosts_) { | |
| 2494 RenderFrameProxyHost* proxy = pair.second.get(); | |
| 2495 | |
| 2496 IPC::Message* copy = new IPC::Message(*msg); | |
| 2497 copy->set_routing_id(proxy->GetRoutingID()); | |
| 2498 proxy->Send(copy); | |
| 2499 } | |
| 2500 | |
| 2501 if (speculative_render_frame_host_) { | |
| 2502 IPC::Message* copy = new IPC::Message(*msg); | |
| 2503 copy->set_routing_id(speculative_render_frame_host_->GetRoutingID()); | |
| 2504 speculative_render_frame_host_->Send(copy); | |
| 2505 } | |
| 2506 | |
| 2507 if (pending_render_frame_host_) { | |
|
nasko
2016/02/12 18:14:08
Speculative and pending cannot exist at the same t
lfg
2016/03/02 18:29:08
Done.
| |
| 2508 IPC::Message* copy = new IPC::Message(*msg); | |
| 2509 copy->set_routing_id(pending_render_frame_host_->GetRoutingID()); | |
| 2510 pending_render_frame_host_->Send(copy); | |
| 2511 } | |
| 2512 | |
| 2513 msg->set_routing_id(render_frame_host_->GetRoutingID()); | |
| 2514 render_frame_host_->Send(msg); | |
| 2515 } | |
| 2516 | |
| 2493 } // namespace content | 2517 } // namespace content |
| OLD | NEW |