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 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
| 11 #include "base/command_line.h" |
11 #include "base/containers/hash_tables.h" | 12 #include "base/containers/hash_tables.h" |
12 #include "base/lazy_instance.h" | 13 #include "base/lazy_instance.h" |
13 #include "content/browser/frame_host/frame_tree_node.h" | 14 #include "content/browser/frame_host/frame_tree_node.h" |
14 #include "content/browser/frame_host/navigator.h" | 15 #include "content/browser/frame_host/navigator.h" |
15 #include "content/browser/frame_host/render_frame_host_factory.h" | 16 #include "content/browser/frame_host/render_frame_host_factory.h" |
16 #include "content/browser/frame_host/render_frame_host_impl.h" | 17 #include "content/browser/frame_host/render_frame_host_impl.h" |
17 #include "content/browser/frame_host/render_frame_proxy_host.h" | 18 #include "content/browser/frame_host/render_frame_proxy_host.h" |
18 #include "content/browser/renderer_host/render_view_host_factory.h" | 19 #include "content/browser/renderer_host/render_view_host_factory.h" |
19 #include "content/browser/renderer_host/render_view_host_impl.h" | 20 #include "content/browser/renderer_host/render_view_host_impl.h" |
| 21 #include "content/public/common/content_switches.h" |
20 #include "third_party/WebKit/public/web/WebSandboxFlags.h" | 22 #include "third_party/WebKit/public/web/WebSandboxFlags.h" |
21 | 23 |
22 namespace content { | 24 namespace content { |
23 | 25 |
24 namespace { | 26 namespace { |
25 | 27 |
26 // Used with FrameTree::ForEach() to search for the FrameTreeNode | 28 // Used with FrameTree::ForEach() to search for the FrameTreeNode |
27 // corresponding to |frame_tree_node_id| within a specific FrameTree. | 29 // corresponding to |frame_tree_node_id| within a specific FrameTree. |
28 bool FrameTreeNodeForId(int frame_tree_node_id, | 30 bool FrameTreeNodeForId(int frame_tree_node_id, |
29 FrameTreeNode** out_node, | 31 FrameTreeNode** out_node, |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
219 void FrameTree::CreateProxiesForSiteInstance( | 221 void FrameTree::CreateProxiesForSiteInstance( |
220 FrameTreeNode* source, | 222 FrameTreeNode* source, |
221 SiteInstance* site_instance) { | 223 SiteInstance* site_instance) { |
222 // Create the swapped out RVH for the new SiteInstance. This will create | 224 // Create the swapped out RVH for the new SiteInstance. This will create |
223 // a top-level swapped out RFH as well, which will then be wrapped by a | 225 // a top-level swapped out RFH as well, which will then be wrapped by a |
224 // RenderFrameProxyHost. | 226 // RenderFrameProxyHost. |
225 if (!source->IsMainFrame()) { | 227 if (!source->IsMainFrame()) { |
226 RenderViewHostImpl* render_view_host = | 228 RenderViewHostImpl* render_view_host = |
227 source->frame_tree()->GetRenderViewHost(site_instance); | 229 source->frame_tree()->GetRenderViewHost(site_instance); |
228 if (!render_view_host) { | 230 if (!render_view_host) { |
229 root()->render_manager()->CreateRenderFrame( | 231 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
230 site_instance, nullptr, MSG_ROUTING_NONE, | 232 switches::kSitePerProcess)) { |
231 CREATE_RF_SWAPPED_OUT | CREATE_RF_HIDDEN, nullptr); | 233 root()->render_manager()->CreateRenderFrameProxy(site_instance); |
| 234 } else { |
| 235 root()->render_manager()->CreateRenderFrame( |
| 236 site_instance, nullptr, MSG_ROUTING_NONE, |
| 237 CREATE_RF_SWAPPED_OUT | CREATE_RF_HIDDEN, nullptr); |
| 238 } |
232 } else { | 239 } else { |
233 root()->render_manager()->EnsureRenderViewInitialized( | 240 root()->render_manager()->EnsureRenderViewInitialized( |
234 source, render_view_host, site_instance); | 241 source, render_view_host, site_instance); |
235 } | 242 } |
236 } | 243 } |
237 | 244 |
238 scoped_refptr<SiteInstance> instance(site_instance); | 245 scoped_refptr<SiteInstance> instance(site_instance); |
239 | 246 |
240 // Proxies are created in the FrameTree in response to a node navigating to a | 247 // Proxies are created in the FrameTree in response to a node navigating to a |
241 // new SiteInstance. Since |source|'s navigation will replace the currently | 248 // new SiteInstance. Since |source|'s navigation will replace the currently |
(...skipping 16 matching lines...) Expand all Loading... |
258 void FrameTree::SetFrameRemoveListener( | 265 void FrameTree::SetFrameRemoveListener( |
259 const base::Callback<void(RenderFrameHost*)>& on_frame_removed) { | 266 const base::Callback<void(RenderFrameHost*)>& on_frame_removed) { |
260 on_frame_removed_ = on_frame_removed; | 267 on_frame_removed_ = on_frame_removed; |
261 } | 268 } |
262 | 269 |
263 RenderViewHostImpl* FrameTree::CreateRenderViewHost(SiteInstance* site_instance, | 270 RenderViewHostImpl* FrameTree::CreateRenderViewHost(SiteInstance* site_instance, |
264 int routing_id, | 271 int routing_id, |
265 int main_frame_routing_id, | 272 int main_frame_routing_id, |
266 bool swapped_out, | 273 bool swapped_out, |
267 bool hidden) { | 274 bool hidden) { |
268 DCHECK(main_frame_routing_id != MSG_ROUTING_NONE); | |
269 RenderViewHostMap::iterator iter = | 275 RenderViewHostMap::iterator iter = |
270 render_view_host_map_.find(site_instance->GetId()); | 276 render_view_host_map_.find(site_instance->GetId()); |
271 if (iter != render_view_host_map_.end()) { | 277 if (iter != render_view_host_map_.end()) { |
272 // If a RenderViewHost's main frame is pending deletion for this | 278 // If a RenderViewHost's main frame is pending deletion for this |
273 // |site_instance|, put it in the map of RenderViewHosts pending shutdown. | 279 // |site_instance|, put it in the map of RenderViewHosts pending shutdown. |
274 // Otherwise return the existing RenderViewHost for the SiteInstance. | 280 // Otherwise return the existing RenderViewHost for the SiteInstance. |
275 RenderFrameHostImpl* main_frame = static_cast<RenderFrameHostImpl*>( | 281 RenderFrameHostImpl* main_frame = static_cast<RenderFrameHostImpl*>( |
276 iter->second->GetMainFrame()); | 282 iter->second->GetMainFrame()); |
277 if (main_frame->frame_tree_node()->render_manager()->IsPendingDeletion( | 283 if (main_frame && |
| 284 main_frame->frame_tree_node()->render_manager()->IsPendingDeletion( |
278 main_frame)) { | 285 main_frame)) { |
279 render_view_host_pending_shutdown_map_.insert( | 286 render_view_host_pending_shutdown_map_.insert( |
280 std::pair<int, RenderViewHostImpl*>(site_instance->GetId(), | 287 std::pair<int, RenderViewHostImpl*>(site_instance->GetId(), |
281 iter->second)); | 288 iter->second)); |
282 render_view_host_map_.erase(iter); | 289 render_view_host_map_.erase(iter); |
283 } else { | 290 } else { |
284 return iter->second; | 291 return iter->second; |
285 } | 292 } |
286 } | 293 } |
287 RenderViewHostImpl* rvh = static_cast<RenderViewHostImpl*>( | 294 RenderViewHostImpl* rvh = static_cast<RenderViewHostImpl*>( |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
392 load_progress_ = 0.0; | 399 load_progress_ = 0.0; |
393 } | 400 } |
394 | 401 |
395 bool FrameTree::IsLoading() { | 402 bool FrameTree::IsLoading() { |
396 bool is_loading = false; | 403 bool is_loading = false; |
397 ForEach(base::Bind(&IsNodeLoading, &is_loading)); | 404 ForEach(base::Bind(&IsNodeLoading, &is_loading)); |
398 return is_loading; | 405 return is_loading; |
399 } | 406 } |
400 | 407 |
401 } // namespace content | 408 } // namespace content |
OLD | NEW |