| 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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 int routing_id) { | 74 int routing_id) { |
| 75 // Create a RenderViewHost, once we have an instance. It is important to | 75 // Create a RenderViewHost, once we have an instance. It is important to |
| 76 // immediately give this SiteInstance to a RenderViewHost so that it is | 76 // immediately give this SiteInstance to a RenderViewHost so that it is |
| 77 // ref counted. | 77 // ref counted. |
| 78 if (!site_instance) | 78 if (!site_instance) |
| 79 site_instance = SiteInstance::Create(browser_context); | 79 site_instance = SiteInstance::Create(browser_context); |
| 80 render_view_host_ = static_cast<RenderViewHostImpl*>( | 80 render_view_host_ = static_cast<RenderViewHostImpl*>( |
| 81 RenderViewHostFactory::Create( | 81 RenderViewHostFactory::Create( |
| 82 site_instance, render_view_delegate_, render_widget_delegate_, | 82 site_instance, render_view_delegate_, render_widget_delegate_, |
| 83 routing_id, false, delegate_-> | 83 routing_id, false, delegate_-> |
| 84 GetControllerForRenderManager().GetSessionStorageNamespace())); | 84 GetControllerForRenderManager().GetSessionStorageNamespace( |
| 85 site_instance->GetProcess()->GetID()))); |
| 85 | 86 |
| 86 // Keep track of renderer processes as they start to shut down. | 87 // Keep track of renderer processes as they start to shut down. |
| 87 registrar_.Add(this, content::NOTIFICATION_RENDERER_PROCESS_CLOSING, | 88 registrar_.Add(this, content::NOTIFICATION_RENDERER_PROCESS_CLOSING, |
| 88 content::NotificationService::AllSources()); | 89 content::NotificationService::AllSources()); |
| 89 } | 90 } |
| 90 | 91 |
| 91 RenderViewHostImpl* RenderViewHostManager::current_host() const { | 92 RenderViewHostImpl* RenderViewHostManager::current_host() const { |
| 92 return render_view_host_; | 93 return render_view_host_; |
| 93 } | 94 } |
| 94 | 95 |
| (...skipping 482 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 577 if (new_render_view_host) { | 578 if (new_render_view_host) { |
| 578 // Prevent the process from exiting while we're trying to use it. | 579 // Prevent the process from exiting while we're trying to use it. |
| 579 if (!swapped_out) | 580 if (!swapped_out) |
| 580 new_render_view_host->GetProcess()->AddPendingView(); | 581 new_render_view_host->GetProcess()->AddPendingView(); |
| 581 } else { | 582 } else { |
| 582 // Create a new RenderViewHost if we don't find an existing one. | 583 // Create a new RenderViewHost if we don't find an existing one. |
| 583 new_render_view_host = static_cast<RenderViewHostImpl*>( | 584 new_render_view_host = static_cast<RenderViewHostImpl*>( |
| 584 RenderViewHostFactory::Create(instance, | 585 RenderViewHostFactory::Create(instance, |
| 585 render_view_delegate_, render_widget_delegate_, MSG_ROUTING_NONE, | 586 render_view_delegate_, render_widget_delegate_, MSG_ROUTING_NONE, |
| 586 swapped_out, delegate_-> | 587 swapped_out, delegate_-> |
| 587 GetControllerForRenderManager().GetSessionStorageNamespace())); | 588 GetControllerForRenderManager().GetSessionStorageNamespace( |
| 589 instance->GetProcess()->GetID()))); |
| 588 | 590 |
| 589 // If the new RVH is swapped out already, store it. Otherwise prevent the | 591 // If the new RVH is swapped out already, store it. Otherwise prevent the |
| 590 // process from exiting while we're trying to navigate in it. | 592 // process from exiting while we're trying to navigate in it. |
| 591 if (swapped_out) { | 593 if (swapped_out) { |
| 592 swapped_out_hosts_[instance->GetId()] = new_render_view_host; | 594 swapped_out_hosts_[instance->GetId()] = new_render_view_host; |
| 593 } else { | 595 } else { |
| 594 new_render_view_host->GetProcess()->AddPendingView(); | 596 new_render_view_host->GetProcess()->AddPendingView(); |
| 595 } | 597 } |
| 596 | 598 |
| 597 bool success = InitRenderView(new_render_view_host, opener_route_id); | 599 bool success = InitRenderView(new_render_view_host, opener_route_id); |
| (...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 912 } | 914 } |
| 913 | 915 |
| 914 RenderViewHost* RenderViewHostManager::GetSwappedOutRenderViewHost( | 916 RenderViewHost* RenderViewHostManager::GetSwappedOutRenderViewHost( |
| 915 SiteInstance* instance) { | 917 SiteInstance* instance) { |
| 916 RenderViewHostMap::iterator iter = swapped_out_hosts_.find(instance->GetId()); | 918 RenderViewHostMap::iterator iter = swapped_out_hosts_.find(instance->GetId()); |
| 917 if (iter != swapped_out_hosts_.end()) | 919 if (iter != swapped_out_hosts_.end()) |
| 918 return iter->second; | 920 return iter->second; |
| 919 | 921 |
| 920 return NULL; | 922 return NULL; |
| 921 } | 923 } |
| OLD | NEW |