OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/web_contents/render_view_host_manager.h" | 5 #include "content/browser/web_contents/render_view_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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 // Shut down any swapped out RenderViewHosts. | 57 // Shut down any swapped out RenderViewHosts. |
58 for (RenderViewHostMap::iterator iter = swapped_out_hosts_.begin(); | 58 for (RenderViewHostMap::iterator iter = swapped_out_hosts_.begin(); |
59 iter != swapped_out_hosts_.end(); | 59 iter != swapped_out_hosts_.end(); |
60 ++iter) { | 60 ++iter) { |
61 iter->second->Shutdown(); | 61 iter->second->Shutdown(); |
62 } | 62 } |
63 } | 63 } |
64 | 64 |
65 void RenderViewHostManager::Init(BrowserContext* browser_context, | 65 void RenderViewHostManager::Init(BrowserContext* browser_context, |
66 SiteInstance* site_instance, | 66 SiteInstance* site_instance, |
67 int routing_id) { | 67 int routing_id, |
| 68 int main_frame_routing_id) { |
68 // Create a RenderViewHost, once we have an instance. It is important to | 69 // Create a RenderViewHost, once we have an instance. It is important to |
69 // immediately give this SiteInstance to a RenderViewHost so that it is | 70 // immediately give this SiteInstance to a RenderViewHost so that it is |
70 // ref counted. | 71 // ref counted. |
71 if (!site_instance) | 72 if (!site_instance) |
72 site_instance = SiteInstance::Create(browser_context); | 73 site_instance = SiteInstance::Create(browser_context); |
73 render_view_host_ = static_cast<RenderViewHostImpl*>( | 74 render_view_host_ = static_cast<RenderViewHostImpl*>( |
74 RenderViewHostFactory::Create( | 75 RenderViewHostFactory::Create( |
75 site_instance, render_view_delegate_, render_widget_delegate_, | 76 site_instance, render_view_delegate_, render_widget_delegate_, |
76 routing_id, false, delegate_-> | 77 routing_id, main_frame_routing_id, false, delegate_-> |
77 GetControllerForRenderManager().GetSessionStorageNamespace( | 78 GetControllerForRenderManager().GetSessionStorageNamespace( |
78 site_instance))); | 79 site_instance))); |
79 | 80 |
80 // Keep track of renderer processes as they start to shut down. | 81 // Keep track of renderer processes as they start to shut down. |
81 registrar_.Add(this, NOTIFICATION_RENDERER_PROCESS_CLOSING, | 82 registrar_.Add(this, NOTIFICATION_RENDERER_PROCESS_CLOSING, |
82 NotificationService::AllSources()); | 83 NotificationService::AllSources()); |
83 } | 84 } |
84 | 85 |
85 RenderViewHostImpl* RenderViewHostManager::current_host() const { | 86 RenderViewHostImpl* RenderViewHostManager::current_host() const { |
86 return render_view_host_; | 87 return render_view_host_; |
(...skipping 530 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
617 GetSwappedOutRenderViewHost(instance)); | 618 GetSwappedOutRenderViewHost(instance)); |
618 if (new_render_view_host) { | 619 if (new_render_view_host) { |
619 // Prevent the process from exiting while we're trying to use it. | 620 // Prevent the process from exiting while we're trying to use it. |
620 if (!swapped_out) | 621 if (!swapped_out) |
621 new_render_view_host->GetProcess()->AddPendingView(); | 622 new_render_view_host->GetProcess()->AddPendingView(); |
622 } else { | 623 } else { |
623 // Create a new RenderViewHost if we don't find an existing one. | 624 // Create a new RenderViewHost if we don't find an existing one. |
624 new_render_view_host = static_cast<RenderViewHostImpl*>( | 625 new_render_view_host = static_cast<RenderViewHostImpl*>( |
625 RenderViewHostFactory::Create(instance, | 626 RenderViewHostFactory::Create(instance, |
626 render_view_delegate_, render_widget_delegate_, MSG_ROUTING_NONE, | 627 render_view_delegate_, render_widget_delegate_, MSG_ROUTING_NONE, |
627 swapped_out, delegate_-> | 628 MSG_ROUTING_NONE, swapped_out, delegate_-> |
628 GetControllerForRenderManager().GetSessionStorageNamespace( | 629 GetControllerForRenderManager().GetSessionStorageNamespace( |
629 instance))); | 630 instance))); |
630 | 631 |
631 // If the new RVH is swapped out already, store it. Otherwise prevent the | 632 // If the new RVH is swapped out already, store it. Otherwise prevent the |
632 // process from exiting while we're trying to navigate in it. | 633 // process from exiting while we're trying to navigate in it. |
633 if (swapped_out) { | 634 if (swapped_out) { |
634 swapped_out_hosts_[instance->GetId()] = new_render_view_host; | 635 swapped_out_hosts_[instance->GetId()] = new_render_view_host; |
635 } else { | 636 } else { |
636 new_render_view_host->GetProcess()->AddPendingView(); | 637 new_render_view_host->GetProcess()->AddPendingView(); |
637 } | 638 } |
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
972 RenderViewHostImpl* RenderViewHostManager::GetSwappedOutRenderViewHost( | 973 RenderViewHostImpl* RenderViewHostManager::GetSwappedOutRenderViewHost( |
973 SiteInstance* instance) { | 974 SiteInstance* instance) { |
974 RenderViewHostMap::iterator iter = swapped_out_hosts_.find(instance->GetId()); | 975 RenderViewHostMap::iterator iter = swapped_out_hosts_.find(instance->GetId()); |
975 if (iter != swapped_out_hosts_.end()) | 976 if (iter != swapped_out_hosts_.end()) |
976 return iter->second; | 977 return iter->second; |
977 | 978 |
978 return NULL; | 979 return NULL; |
979 } | 980 } |
980 | 981 |
981 } // namespace content | 982 } // namespace content |
OLD | NEW |