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 21 matching lines...) Expand all Loading... |
32 using content::NavigationEntryImpl; | 32 using content::NavigationEntryImpl; |
33 using content::RenderViewHost; | 33 using content::RenderViewHost; |
34 using content::RenderViewHostImpl; | 34 using content::RenderViewHostImpl; |
35 using content::RenderWidgetHostView; | 35 using content::RenderWidgetHostView; |
36 using content::RenderWidgetHostViewPort; | 36 using content::RenderWidgetHostViewPort; |
37 using content::SiteInstance; | 37 using content::SiteInstance; |
38 using content::WebUIControllerFactory; | 38 using content::WebUIControllerFactory; |
39 | 39 |
40 RenderViewHostManager::RenderViewHostManager( | 40 RenderViewHostManager::RenderViewHostManager( |
41 content::RenderViewHostDelegate* render_view_delegate, | 41 content::RenderViewHostDelegate* render_view_delegate, |
| 42 content::RenderWidgetHostDelegate* render_widget_delegate, |
42 Delegate* delegate) | 43 Delegate* delegate) |
43 : delegate_(delegate), | 44 : delegate_(delegate), |
44 cross_navigation_pending_(false), | 45 cross_navigation_pending_(false), |
45 render_view_delegate_(render_view_delegate), | 46 render_view_delegate_(render_view_delegate), |
| 47 render_widget_delegate_(render_widget_delegate), |
46 render_view_host_(NULL), | 48 render_view_host_(NULL), |
47 pending_render_view_host_(NULL), | 49 pending_render_view_host_(NULL), |
48 interstitial_page_(NULL) { | 50 interstitial_page_(NULL) { |
49 } | 51 } |
50 | 52 |
51 RenderViewHostManager::~RenderViewHostManager() { | 53 RenderViewHostManager::~RenderViewHostManager() { |
52 if (pending_render_view_host_) | 54 if (pending_render_view_host_) |
53 CancelPending(); | 55 CancelPending(); |
54 | 56 |
55 // We should always have a main RenderViewHost. | 57 // We should always have a main RenderViewHost. |
(...skipping 12 matching lines...) Expand all Loading... |
68 void RenderViewHostManager::Init(content::BrowserContext* browser_context, | 70 void RenderViewHostManager::Init(content::BrowserContext* browser_context, |
69 SiteInstance* site_instance, | 71 SiteInstance* site_instance, |
70 int routing_id) { | 72 int routing_id) { |
71 // Create a RenderViewHost, once we have an instance. It is important to | 73 // Create a RenderViewHost, once we have an instance. It is important to |
72 // immediately give this SiteInstance to a RenderViewHost so that it is | 74 // immediately give this SiteInstance to a RenderViewHost so that it is |
73 // ref counted. | 75 // ref counted. |
74 if (!site_instance) | 76 if (!site_instance) |
75 site_instance = SiteInstance::Create(browser_context); | 77 site_instance = SiteInstance::Create(browser_context); |
76 render_view_host_ = static_cast<RenderViewHostImpl*>( | 78 render_view_host_ = static_cast<RenderViewHostImpl*>( |
77 RenderViewHostFactory::Create( | 79 RenderViewHostFactory::Create( |
78 site_instance, render_view_delegate_, routing_id, false, delegate_-> | 80 site_instance, render_view_delegate_, render_widget_delegate_, |
| 81 routing_id, false, delegate_-> |
79 GetControllerForRenderManager().GetSessionStorageNamespace())); | 82 GetControllerForRenderManager().GetSessionStorageNamespace())); |
80 | 83 |
81 // Keep track of renderer processes as they start to shut down. | 84 // Keep track of renderer processes as they start to shut down. |
82 registrar_.Add(this, content::NOTIFICATION_RENDERER_PROCESS_CLOSING, | 85 registrar_.Add(this, content::NOTIFICATION_RENDERER_PROCESS_CLOSING, |
83 content::NotificationService::AllSources()); | 86 content::NotificationService::AllSources()); |
84 } | 87 } |
85 | 88 |
86 RenderViewHostImpl* RenderViewHostManager::current_host() const { | 89 RenderViewHostImpl* RenderViewHostManager::current_host() const { |
87 return render_view_host_; | 90 return render_view_host_; |
88 } | 91 } |
(...skipping 470 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
559 RenderViewHostImpl* new_render_view_host = static_cast<RenderViewHostImpl*>( | 562 RenderViewHostImpl* new_render_view_host = static_cast<RenderViewHostImpl*>( |
560 GetSwappedOutRenderViewHost(instance)); | 563 GetSwappedOutRenderViewHost(instance)); |
561 if (new_render_view_host) { | 564 if (new_render_view_host) { |
562 // Prevent the process from exiting while we're trying to use it. | 565 // Prevent the process from exiting while we're trying to use it. |
563 if (!swapped_out) | 566 if (!swapped_out) |
564 new_render_view_host->GetProcess()->AddPendingView(); | 567 new_render_view_host->GetProcess()->AddPendingView(); |
565 } else { | 568 } else { |
566 // Create a new RenderViewHost if we don't find an existing one. | 569 // Create a new RenderViewHost if we don't find an existing one. |
567 new_render_view_host = static_cast<RenderViewHostImpl*>( | 570 new_render_view_host = static_cast<RenderViewHostImpl*>( |
568 RenderViewHostFactory::Create(instance, | 571 RenderViewHostFactory::Create(instance, |
569 render_view_delegate_, MSG_ROUTING_NONE, swapped_out, delegate_-> | 572 render_view_delegate_, render_widget_delegate_, MSG_ROUTING_NONE, |
| 573 swapped_out, delegate_-> |
570 GetControllerForRenderManager().GetSessionStorageNamespace())); | 574 GetControllerForRenderManager().GetSessionStorageNamespace())); |
571 | 575 |
572 // If the new RVH is swapped out already, store it. Otherwise prevent the | 576 // If the new RVH is swapped out already, store it. Otherwise prevent the |
573 // process from exiting while we're trying to navigate in it. | 577 // process from exiting while we're trying to navigate in it. |
574 if (swapped_out) { | 578 if (swapped_out) { |
575 swapped_out_hosts_[instance->GetId()] = new_render_view_host; | 579 swapped_out_hosts_[instance->GetId()] = new_render_view_host; |
576 } else { | 580 } else { |
577 new_render_view_host->GetProcess()->AddPendingView(); | 581 new_render_view_host->GetProcess()->AddPendingView(); |
578 } | 582 } |
579 | 583 |
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
893 } | 897 } |
894 | 898 |
895 RenderViewHost* RenderViewHostManager::GetSwappedOutRenderViewHost( | 899 RenderViewHost* RenderViewHostManager::GetSwappedOutRenderViewHost( |
896 SiteInstance* instance) { | 900 SiteInstance* instance) { |
897 RenderViewHostMap::iterator iter = swapped_out_hosts_.find(instance->GetId()); | 901 RenderViewHostMap::iterator iter = swapped_out_hosts_.find(instance->GetId()); |
898 if (iter != swapped_out_hosts_.end()) | 902 if (iter != swapped_out_hosts_.end()) |
899 return iter->second; | 903 return iter->second; |
900 | 904 |
901 return NULL; | 905 return NULL; |
902 } | 906 } |
OLD | NEW |