OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 "chrome/browser/renderer_host/render_view_host.h" | 5 #include "chrome/browser/renderer_host/render_view_host.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "app/resource_bundle.h" | 10 #include "app/resource_bundle.h" |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 run_modal_reply_msg_(NULL), | 105 run_modal_reply_msg_(NULL), |
106 is_waiting_for_unload_ack_(false), | 106 is_waiting_for_unload_ack_(false), |
107 are_javascript_messages_suppressed_(false), | 107 are_javascript_messages_suppressed_(false), |
108 sudden_termination_allowed_(false) { | 108 sudden_termination_allowed_(false) { |
109 DCHECK(instance_); | 109 DCHECK(instance_); |
110 DCHECK(delegate_); | 110 DCHECK(delegate_); |
111 if (modal_dialog_event == NULL) | 111 if (modal_dialog_event == NULL) |
112 modal_dialog_event = new base::WaitableEvent(true, false); | 112 modal_dialog_event = new base::WaitableEvent(true, false); |
113 | 113 |
114 modal_dialog_event_.reset(modal_dialog_event); | 114 modal_dialog_event_.reset(modal_dialog_event); |
| 115 |
| 116 // TODO(mpcomplete): remove this notification (and registrar) when we figure |
| 117 // out why we're crashing on process()->Init(). |
| 118 // http://code.google.com/p/chromium/issues/detail?id=15607 |
| 119 registrar_.Add(this, NotificationType::RENDERER_PROCESS_TERMINATED, |
| 120 NotificationService::AllSources()); |
115 } | 121 } |
116 | 122 |
117 RenderViewHost::~RenderViewHost() { | 123 RenderViewHost::~RenderViewHost() { |
118 DevToolsManager* devtools_manager = DevToolsManager::GetInstance(); | 124 DevToolsManager* devtools_manager = DevToolsManager::GetInstance(); |
119 if (devtools_manager) // NULL in tests | 125 if (devtools_manager) // NULL in tests |
120 devtools_manager->UnregisterDevToolsClientHostFor(this); | 126 devtools_manager->UnregisterDevToolsClientHostFor(this); |
121 | 127 |
122 // Be sure to clean up any leftover state from cross-site requests. | 128 // Be sure to clean up any leftover state from cross-site requests. |
123 Singleton<CrossSiteRequestManager>()->SetHasPendingCrossSiteRequest( | 129 Singleton<CrossSiteRequestManager>()->SetHasPendingCrossSiteRequest( |
124 process()->pid(), routing_id(), false); | 130 process()->pid(), routing_id(), false); |
125 | 131 |
126 NotificationService::current()->Notify( | 132 NotificationService::current()->Notify( |
127 NotificationType::RENDER_VIEW_HOST_DELETED, | 133 NotificationType::RENDER_VIEW_HOST_DELETED, |
128 Source<RenderViewHost>(this), | 134 Source<RenderViewHost>(this), |
129 NotificationService::NoDetails()); | 135 NotificationService::NoDetails()); |
130 } | 136 } |
131 | 137 |
| 138 void RenderViewHost::Observe(NotificationType type, |
| 139 const NotificationSource& source, |
| 140 const NotificationDetails& details) { |
| 141 DCHECK(type == NotificationType::RENDERER_PROCESS_TERMINATED); |
| 142 RenderProcessHost* rph = Source<RenderProcessHost>(source).ptr(); |
| 143 if (rph == process()) { |
| 144 // Try to get some debugging information on the stack. |
| 145 size_t num_hosts = RenderProcessHost::size(); |
| 146 bool no_listeners = rph->listeners_begin() == rph->listeners_end(); |
| 147 bool live_instance = site_instance() != NULL; |
| 148 CHECK(live_instance); |
| 149 bool live_process = site_instance()->GetProcess() != NULL; |
| 150 bool same_process = site_instance()->GetProcess() == rph; |
| 151 CHECK(no_listeners); |
| 152 CHECK(live_process); |
| 153 CHECK(same_process); |
| 154 CHECK(num_hosts > 0); |
| 155 CHECK(false) << "RenderViewHost should outlive its RenderProcessHost."; |
| 156 } |
| 157 } |
| 158 |
132 bool RenderViewHost::CreateRenderView() { | 159 bool RenderViewHost::CreateRenderView() { |
133 DCHECK(!IsRenderViewLive()) << "Creating view twice"; | 160 DCHECK(!IsRenderViewLive()) << "Creating view twice"; |
| 161 CHECK(process()); |
| 162 CHECK(process()->listeners_begin() != process()->listeners_end()) << |
| 163 "Our process should have us as a listener."; |
134 | 164 |
135 // The process may (if we're sharing a process with another host that already | 165 // The process may (if we're sharing a process with another host that already |
136 // initialized it) or may not (we have our own process or the old process | 166 // initialized it) or may not (we have our own process or the old process |
137 // crashed) have been initialized. Calling Init multiple times will be | 167 // crashed) have been initialized. Calling Init multiple times will be |
138 // ignored, so this is safe. | 168 // ignored, so this is safe. |
139 if (!process()->Init()) | 169 if (!process()->Init()) |
140 return false; | 170 return false; |
141 DCHECK(process()->HasConnection()); | 171 DCHECK(process()->HasConnection()); |
142 DCHECK(process()->profile()); | 172 DCHECK(process()->profile()); |
143 | 173 |
(...skipping 1246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1390 BrowserAccessibilityManager::GetInstance()-> | 1420 BrowserAccessibilityManager::GetInstance()-> |
1391 ChangeAccessibilityFocus(acc_obj_id, process()->pid(), routing_id()); | 1421 ChangeAccessibilityFocus(acc_obj_id, process()->pid(), routing_id()); |
1392 #else | 1422 #else |
1393 // TODO(port): accessibility not yet implemented. See http://crbug.com/8288. | 1423 // TODO(port): accessibility not yet implemented. See http://crbug.com/8288. |
1394 #endif | 1424 #endif |
1395 } | 1425 } |
1396 | 1426 |
1397 void RenderViewHost::OnCSSInserted() { | 1427 void RenderViewHost::OnCSSInserted() { |
1398 delegate_->DidInsertCSS(); | 1428 delegate_->DidInsertCSS(); |
1399 } | 1429 } |
OLD | NEW |