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/logging.h" | 10 #include "base/logging.h" |
(...skipping 1328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1339 SiteInstance* old_instance, | 1339 SiteInstance* old_instance, |
1340 SiteInstance* new_instance, | 1340 SiteInstance* new_instance, |
1341 bool is_main_frame) { | 1341 bool is_main_frame) { |
1342 int create_render_frame_flags = 0; | 1342 int create_render_frame_flags = 0; |
1343 if (is_main_frame) | 1343 if (is_main_frame) |
1344 create_render_frame_flags |= CREATE_RF_FOR_MAIN_FRAME_NAVIGATION; | 1344 create_render_frame_flags |= CREATE_RF_FOR_MAIN_FRAME_NAVIGATION; |
1345 | 1345 |
1346 if (delegate_->IsHidden()) | 1346 if (delegate_->IsHidden()) |
1347 create_render_frame_flags |= CREATE_RF_HIDDEN; | 1347 create_render_frame_flags |= CREATE_RF_HIDDEN; |
1348 | 1348 |
| 1349 if (pending_render_frame_host_) |
| 1350 CancelPending(); |
| 1351 |
| 1352 // The process for the new SiteInstance may (if we're sharing a process with |
| 1353 // another host that already initialized it) or may not (we have our own |
| 1354 // process or the existing process crashed) have been initialized. Calling |
| 1355 // Init multiple times will be ignored, so this is safe. |
| 1356 if (!new_instance->GetProcess()->Init()) |
| 1357 return; |
| 1358 |
1349 int opener_route_id = CreateOpenerRenderViewsIfNeeded( | 1359 int opener_route_id = CreateOpenerRenderViewsIfNeeded( |
1350 old_instance, new_instance, &create_render_frame_flags); | 1360 old_instance, new_instance, &create_render_frame_flags); |
1351 | 1361 |
1352 if (pending_render_frame_host_) | |
1353 CancelPending(); | |
1354 | |
1355 // Create a non-swapped-out RFH with the given opener. | 1362 // Create a non-swapped-out RFH with the given opener. |
1356 pending_render_frame_host_ = | 1363 pending_render_frame_host_ = |
1357 CreateRenderFrame(new_instance, pending_web_ui(), opener_route_id, | 1364 CreateRenderFrame(new_instance, pending_web_ui(), opener_route_id, |
1358 create_render_frame_flags, nullptr); | 1365 create_render_frame_flags, nullptr); |
1359 } | 1366 } |
1360 | 1367 |
1361 int RenderFrameHostManager::CreateOpenerRenderViewsIfNeeded( | 1368 int RenderFrameHostManager::CreateOpenerRenderViewsIfNeeded( |
1362 SiteInstance* old_instance, | 1369 SiteInstance* old_instance, |
1363 SiteInstance* new_instance, | 1370 SiteInstance* new_instance, |
1364 int* create_render_frame_flags) { | 1371 int* create_render_frame_flags) { |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1428 int bindings) { | 1435 int bindings) { |
1429 CHECK(new_instance); | 1436 CHECK(new_instance); |
1430 CHECK_NE(old_instance, new_instance); | 1437 CHECK_NE(old_instance, new_instance); |
1431 CHECK(!should_reuse_web_ui_); | 1438 CHECK(!should_reuse_web_ui_); |
1432 | 1439 |
1433 // Note: |speculative_web_ui_| must be initialized before starting the | 1440 // Note: |speculative_web_ui_| must be initialized before starting the |
1434 // |speculative_render_frame_host_| creation steps otherwise the WebUI | 1441 // |speculative_render_frame_host_| creation steps otherwise the WebUI |
1435 // won't be properly initialized. | 1442 // won't be properly initialized. |
1436 speculative_web_ui_ = CreateWebUI(url, bindings); | 1443 speculative_web_ui_ = CreateWebUI(url, bindings); |
1437 | 1444 |
| 1445 // The process for the new SiteInstance may (if we're sharing a process with |
| 1446 // another host that already initialized it) or may not (we have our own |
| 1447 // process or the existing process crashed) have been initialized. Calling |
| 1448 // Init multiple times will be ignored, so this is safe. |
| 1449 if (!new_instance->GetProcess()->Init()) |
| 1450 return false; |
| 1451 |
1438 int create_render_frame_flags = 0; | 1452 int create_render_frame_flags = 0; |
1439 int opener_route_id = | 1453 int opener_route_id = |
1440 CreateOpenerRenderViewsIfNeeded(old_instance, new_instance, | 1454 CreateOpenerRenderViewsIfNeeded(old_instance, new_instance, |
1441 &create_render_frame_flags); | 1455 &create_render_frame_flags); |
1442 | 1456 |
1443 if (frame_tree_node_->IsMainFrame()) | 1457 if (frame_tree_node_->IsMainFrame()) |
1444 create_render_frame_flags |= CREATE_RF_FOR_MAIN_FRAME_NAVIGATION; | 1458 create_render_frame_flags |= CREATE_RF_FOR_MAIN_FRAME_NAVIGATION; |
1445 if (delegate_->IsHidden()) | 1459 if (delegate_->IsHidden()) |
1446 create_render_frame_flags |= CREATE_RF_HIDDEN; | 1460 create_render_frame_flags |= CREATE_RF_HIDDEN; |
1447 speculative_render_frame_host_ = | 1461 speculative_render_frame_host_ = |
(...skipping 670 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2118 void RenderFrameHostManager::DeleteRenderFrameProxyHost( | 2132 void RenderFrameHostManager::DeleteRenderFrameProxyHost( |
2119 SiteInstance* instance) { | 2133 SiteInstance* instance) { |
2120 RenderFrameProxyHostMap::iterator iter = proxy_hosts_.find(instance->GetId()); | 2134 RenderFrameProxyHostMap::iterator iter = proxy_hosts_.find(instance->GetId()); |
2121 if (iter != proxy_hosts_.end()) { | 2135 if (iter != proxy_hosts_.end()) { |
2122 delete iter->second; | 2136 delete iter->second; |
2123 proxy_hosts_.erase(iter); | 2137 proxy_hosts_.erase(iter); |
2124 } | 2138 } |
2125 } | 2139 } |
2126 | 2140 |
2127 } // namespace content | 2141 } // namespace content |
OLD | NEW |