| 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/frame_tree.h" | 5 #include "content/browser/frame_host/frame_tree.h" |
| 6 | 6 |
| 7 #include <queue> | 7 #include <queue> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| 11 #include "base/callback.h" | 11 #include "base/callback.h" |
| 12 #include "base/containers/hash_tables.h" | 12 #include "base/containers/hash_tables.h" |
| 13 #include "base/lazy_instance.h" | 13 #include "base/lazy_instance.h" |
| 14 #include "content/browser/frame_host/frame_tree_node.h" | 14 #include "content/browser/frame_host/frame_tree_node.h" |
| 15 #include "content/browser/frame_host/navigator.h" | 15 #include "content/browser/frame_host/navigator.h" |
| 16 #include "content/browser/frame_host/render_frame_host_factory.h" | 16 #include "content/browser/frame_host/render_frame_host_factory.h" |
| 17 #include "content/browser/frame_host/render_frame_host_impl.h" | 17 #include "content/browser/frame_host/render_frame_host_impl.h" |
| 18 #include "content/browser/frame_host/render_frame_proxy_host.h" | 18 #include "content/browser/frame_host/render_frame_proxy_host.h" |
| 19 #include "content/browser/frame_host/traced_frame_tree.h" |
| 19 #include "content/browser/renderer_host/render_view_host_factory.h" | 20 #include "content/browser/renderer_host/render_view_host_factory.h" |
| 20 #include "content/browser/renderer_host/render_view_host_impl.h" | 21 #include "content/browser/renderer_host/render_view_host_impl.h" |
| 21 #include "content/common/input_messages.h" | 22 #include "content/common/input_messages.h" |
| 22 #include "content/common/site_isolation_policy.h" | 23 #include "content/common/site_isolation_policy.h" |
| 23 #include "third_party/WebKit/public/web/WebSandboxFlags.h" | 24 #include "third_party/WebKit/public/web/WebSandboxFlags.h" |
| 24 | 25 |
| 25 namespace content { | 26 namespace content { |
| 26 | 27 |
| 27 namespace { | 28 namespace { |
| 28 | 29 |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 209 if (parent->current_frame_host()->GetProcess()->GetID() != process_id) | 210 if (parent->current_frame_host()->GetProcess()->GetID() != process_id) |
| 210 return nullptr; | 211 return nullptr; |
| 211 | 212 |
| 212 scoped_ptr<FrameTreeNode> node( | 213 scoped_ptr<FrameTreeNode> node( |
| 213 new FrameTreeNode(this, parent->navigator(), render_frame_delegate_, | 214 new FrameTreeNode(this, parent->navigator(), render_frame_delegate_, |
| 214 render_view_delegate_, render_widget_delegate_, | 215 render_view_delegate_, render_widget_delegate_, |
| 215 manager_delegate_, scope, frame_name, sandbox_flags)); | 216 manager_delegate_, scope, frame_name, sandbox_flags)); |
| 216 FrameTreeNode* node_ptr = node.get(); | 217 FrameTreeNode* node_ptr = node.get(); |
| 217 // AddChild is what creates the RenderFrameHost. | 218 // AddChild is what creates the RenderFrameHost. |
| 218 parent->AddChild(node.Pass(), process_id, new_routing_id); | 219 parent->AddChild(node.Pass(), process_id, new_routing_id); |
| 220 TraceSnapshot(); |
| 219 return node_ptr->current_frame_host(); | 221 return node_ptr->current_frame_host(); |
| 220 } | 222 } |
| 221 | 223 |
| 222 void FrameTree::RemoveFrame(FrameTreeNode* child) { | 224 void FrameTree::RemoveFrame(FrameTreeNode* child) { |
| 223 FrameTreeNode* parent = child->parent(); | 225 FrameTreeNode* parent = child->parent(); |
| 224 if (!parent) { | 226 if (!parent) { |
| 225 NOTREACHED() << "Unexpected RemoveFrame call for main frame."; | 227 NOTREACHED() << "Unexpected RemoveFrame call for main frame."; |
| 226 return; | 228 return; |
| 227 } | 229 } |
| 228 | 230 |
| 229 parent->RemoveChild(child); | 231 parent->RemoveChild(child); |
| 232 TraceSnapshot(); |
| 230 } | 233 } |
| 231 | 234 |
| 232 void FrameTree::CreateProxiesForSiteInstance( | 235 void FrameTree::CreateProxiesForSiteInstance( |
| 233 FrameTreeNode* source, | 236 FrameTreeNode* source, |
| 234 SiteInstance* site_instance) { | 237 SiteInstance* site_instance) { |
| 235 // Create the swapped out RVH for the new SiteInstance. This will create | 238 // Create the swapped out RVH for the new SiteInstance. This will create |
| 236 // a top-level swapped out RFH as well, which will then be wrapped by a | 239 // a top-level swapped out RFH as well, which will then be wrapped by a |
| 237 // RenderFrameProxyHost. | 240 // RenderFrameProxyHost. |
| 238 if (!source || !source->IsMainFrame()) { | 241 if (!source || !source->IsMainFrame()) { |
| 239 RenderViewHostImpl* render_view_host = GetRenderViewHost(site_instance); | 242 RenderViewHostImpl* render_view_host = GetRenderViewHost(site_instance); |
| (...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 432 for (const auto& instance : frame_tree_site_instances) { | 435 for (const auto& instance : frame_tree_site_instances) { |
| 433 if (instance == root_->current_frame_host()->GetSiteInstance()) | 436 if (instance == root_->current_frame_host()->GetSiteInstance()) |
| 434 continue; | 437 continue; |
| 435 | 438 |
| 436 RenderFrameProxyHost* proxy = | 439 RenderFrameProxyHost* proxy = |
| 437 root_->render_manager()->GetRenderFrameProxyHost(instance); | 440 root_->render_manager()->GetRenderFrameProxyHost(instance); |
| 438 proxy->Send(new InputMsg_SetFocus(proxy->GetRoutingID(), is_focused)); | 441 proxy->Send(new InputMsg_SetFocus(proxy->GetRoutingID(), is_focused)); |
| 439 } | 442 } |
| 440 } | 443 } |
| 441 | 444 |
| 445 void FrameTree::TraceSnapshot() const { |
| 446 TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID("navigation", "FrameTree", this, |
| 447 scoped_refptr<base::trace_event::ConvertableToTraceFormat>( |
| 448 TracedFrameTree::Create(*this))); |
| 449 } |
| 450 |
| 442 } // namespace content | 451 } // namespace content |
| OLD | NEW |