| 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/renderer_host/render_widget_host_impl.h" | 5 #include "content/browser/renderer_host/render_widget_host_impl.h" |
| 6 | 6 |
| 7 #include <math.h> | 7 #include <math.h> |
| 8 #include <set> | 8 #include <set> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 228 if (BrowserPluginGuest::IsGuest(rvh) || | 228 if (BrowserPluginGuest::IsGuest(rvh) || |
| 229 !base::CommandLine::ForCurrentProcess()->HasSwitch( | 229 !base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 230 switches::kDisableHangMonitor)) { | 230 switches::kDisableHangMonitor)) { |
| 231 hang_monitor_timeout_.reset(new TimeoutMonitor( | 231 hang_monitor_timeout_.reset(new TimeoutMonitor( |
| 232 base::Bind(&RenderWidgetHostImpl::RendererIsUnresponsive, | 232 base::Bind(&RenderWidgetHostImpl::RendererIsUnresponsive, |
| 233 weak_factory_.GetWeakPtr()))); | 233 weak_factory_.GetWeakPtr()))); |
| 234 } | 234 } |
| 235 } | 235 } |
| 236 | 236 |
| 237 RenderWidgetHostImpl::~RenderWidgetHostImpl() { | 237 RenderWidgetHostImpl::~RenderWidgetHostImpl() { |
| 238 SetView(NULL); | 238 if (view_) { |
| 239 view_->Destroy(); |
| 240 DCHECK(!view_); |
| 241 } |
| 239 | 242 |
| 240 GpuSurfaceTracker::Get()->RemoveSurface(surface_id_); | 243 GpuSurfaceTracker::Get()->RemoveSurface(surface_id_); |
| 241 surface_id_ = 0; | 244 surface_id_ = 0; |
| 242 | 245 |
| 243 process_->RemoveRoute(routing_id_); | 246 process_->RemoveRoute(routing_id_); |
| 244 g_routing_id_widget_map.Get().erase( | 247 g_routing_id_widget_map.Get().erase( |
| 245 RenderWidgetHostID(process_->GetID(), routing_id_)); | 248 RenderWidgetHostID(process_->GetID(), routing_id_)); |
| 246 | 249 |
| 247 if (delegate_) | 250 if (delegate_) |
| 248 delegate_->RenderWidgetDeleted(this); | 251 delegate_->RenderWidgetDeleted(this); |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 303 | 306 |
| 304 return scoped_ptr<RenderWidgetHostIterator>(hosts); | 307 return scoped_ptr<RenderWidgetHostIterator>(hosts); |
| 305 } | 308 } |
| 306 | 309 |
| 307 // static | 310 // static |
| 308 RenderWidgetHostImpl* RenderWidgetHostImpl::From(RenderWidgetHost* rwh) { | 311 RenderWidgetHostImpl* RenderWidgetHostImpl::From(RenderWidgetHost* rwh) { |
| 309 return rwh->AsRenderWidgetHostImpl(); | 312 return rwh->AsRenderWidgetHostImpl(); |
| 310 } | 313 } |
| 311 | 314 |
| 312 void RenderWidgetHostImpl::SetView(RenderWidgetHostViewBase* view) { | 315 void RenderWidgetHostImpl::SetView(RenderWidgetHostViewBase* view) { |
| 316 DCHECK(view); |
| 313 view_ = view; | 317 view_ = view; |
| 314 | 318 |
| 315 GpuSurfaceTracker::Get()->SetSurfaceHandle( | 319 GpuSurfaceTracker::Get()->SetSurfaceHandle( |
| 316 surface_id_, GetCompositingSurface()); | 320 surface_id_, GetCompositingSurface()); |
| 317 | 321 |
| 318 synthetic_gesture_controller_.reset(); | 322 synthetic_gesture_controller_.reset(); |
| 319 } | 323 } |
| 320 | 324 |
| 321 RenderProcessHost* RenderWidgetHostImpl::GetProcess() const { | 325 RenderProcessHost* RenderWidgetHostImpl::GetProcess() const { |
| 322 return process_; | 326 return process_; |
| (...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 646 } | 650 } |
| 647 | 651 |
| 648 void RenderWidgetHostImpl::SetActive(bool active) { | 652 void RenderWidgetHostImpl::SetActive(bool active) { |
| 649 Send(new ViewMsg_SetActive(routing_id_, active)); | 653 Send(new ViewMsg_SetActive(routing_id_, active)); |
| 650 } | 654 } |
| 651 | 655 |
| 652 void RenderWidgetHostImpl::LostMouseLock() { | 656 void RenderWidgetHostImpl::LostMouseLock() { |
| 653 Send(new ViewMsg_MouseLockLost(routing_id_)); | 657 Send(new ViewMsg_MouseLockLost(routing_id_)); |
| 654 } | 658 } |
| 655 | 659 |
| 656 void RenderWidgetHostImpl::ViewDestroyed() { | 660 void RenderWidgetHostImpl::ViewDestroyed(RenderWidgetHostViewBase* view) { |
| 661 // If the view has been changed, then do not re-set the view pointer when the |
| 662 // old view is destroyed. |
| 663 if (view != view_) |
| 664 return; |
| 657 RejectMouseLockOrUnlockIfNecessary(); | 665 RejectMouseLockOrUnlockIfNecessary(); |
| 658 | 666 view_ = NULL; |
| 659 // TODO(evanm): tracking this may no longer be necessary; | |
| 660 // eliminate this function if so. | |
| 661 SetView(NULL); | |
| 662 } | 667 } |
| 663 | 668 |
| 664 void RenderWidgetHostImpl::CopyFromBackingStore( | 669 void RenderWidgetHostImpl::CopyFromBackingStore( |
| 665 const gfx::Rect& src_subrect, | 670 const gfx::Rect& src_subrect, |
| 666 const gfx::Size& accelerated_dst_size, | 671 const gfx::Size& accelerated_dst_size, |
| 667 const base::Callback<void(bool, const SkBitmap&)>& callback, | 672 const base::Callback<void(bool, const SkBitmap&)>& callback, |
| 668 const SkColorType color_type) { | 673 const SkColorType color_type) { |
| 669 if (view_) { | 674 if (view_) { |
| 670 TRACE_EVENT0("browser", | 675 TRACE_EVENT0("browser", |
| 671 "RenderWidgetHostImpl::CopyFromBackingStore::FromCompositingSurface"); | 676 "RenderWidgetHostImpl::CopyFromBackingStore::FromCompositingSurface"); |
| (...skipping 539 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1211 process_->WidgetRestored(); | 1216 process_->WidgetRestored(); |
| 1212 is_hidden_ = false; | 1217 is_hidden_ = false; |
| 1213 } | 1218 } |
| 1214 | 1219 |
| 1215 // Reset this to ensure the hung renderer mechanism is working properly. | 1220 // Reset this to ensure the hung renderer mechanism is working properly. |
| 1216 in_flight_event_count_ = 0; | 1221 in_flight_event_count_ = 0; |
| 1217 | 1222 |
| 1218 if (view_) { | 1223 if (view_) { |
| 1219 GpuSurfaceTracker::Get()->SetSurfaceHandle(surface_id_, | 1224 GpuSurfaceTracker::Get()->SetSurfaceHandle(surface_id_, |
| 1220 gfx::GLSurfaceHandle()); | 1225 gfx::GLSurfaceHandle()); |
| 1221 view_->RenderProcessGone(status, exit_code); | 1226 view_->Destroy(); |
| 1222 view_ = NULL; // The View should be deleted by RenderProcessGone. | 1227 DCHECK(!view_); |
| 1223 } | 1228 } |
| 1224 | 1229 |
| 1225 // Reconstruct the input router to ensure that it has fresh state for a new | 1230 // Reconstruct the input router to ensure that it has fresh state for a new |
| 1226 // renderer. Otherwise it may be stuck waiting for the old renderer to ack an | 1231 // renderer. Otherwise it may be stuck waiting for the old renderer to ack an |
| 1227 // event. (In particular, the above call to view_->RenderProcessGone will | 1232 // event. (In particular, the above call to view_->RenderProcessGone will |
| 1228 // destroy the aura window, which may dispatch a synthetic mouse move.) | 1233 // destroy the aura window, which may dispatch a synthetic mouse move.) |
| 1229 input_router_.reset(new InputRouterImpl( | 1234 input_router_.reset(new InputRouterImpl( |
| 1230 process_, this, this, routing_id_, GetInputRouterConfigForPlatform())); | 1235 process_, this, this, routing_id_, GetInputRouterConfigForPlatform())); |
| 1231 | 1236 |
| 1232 synthetic_gesture_controller_.reset(); | 1237 synthetic_gesture_controller_.reset(); |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1326 void RenderWidgetHostImpl::Destroy() { | 1331 void RenderWidgetHostImpl::Destroy() { |
| 1327 NotificationService::current()->Notify( | 1332 NotificationService::current()->Notify( |
| 1328 NOTIFICATION_RENDER_WIDGET_HOST_DESTROYED, | 1333 NOTIFICATION_RENDER_WIDGET_HOST_DESTROYED, |
| 1329 Source<RenderWidgetHost>(this), | 1334 Source<RenderWidgetHost>(this), |
| 1330 NotificationService::NoDetails()); | 1335 NotificationService::NoDetails()); |
| 1331 | 1336 |
| 1332 // Tell the view to die. | 1337 // Tell the view to die. |
| 1333 // Note that in the process of the view shutting down, it can call a ton | 1338 // Note that in the process of the view shutting down, it can call a ton |
| 1334 // of other messages on us. So if you do any other deinitialization here, | 1339 // of other messages on us. So if you do any other deinitialization here, |
| 1335 // do it after this call to view_->Destroy(). | 1340 // do it after this call to view_->Destroy(). |
| 1336 if (view_) | 1341 if (view_) { |
| 1337 view_->Destroy(); | 1342 view_->Destroy(); |
| 1343 DCHECK(!view_); |
| 1344 } |
| 1338 | 1345 |
| 1339 delete this; | 1346 delete this; |
| 1340 } | 1347 } |
| 1341 | 1348 |
| 1342 void RenderWidgetHostImpl::RendererIsUnresponsive() { | 1349 void RenderWidgetHostImpl::RendererIsUnresponsive() { |
| 1343 NotificationService::current()->Notify( | 1350 NotificationService::current()->Notify( |
| 1344 NOTIFICATION_RENDER_WIDGET_HOST_HANG, | 1351 NOTIFICATION_RENDER_WIDGET_HOST_HANG, |
| 1345 Source<RenderWidgetHost>(this), | 1352 Source<RenderWidgetHost>(this), |
| 1346 NotificationService::NoDetails()); | 1353 NotificationService::NoDetails()); |
| 1347 is_unresponsive_ = true; | 1354 is_unresponsive_ = true; |
| (...skipping 963 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2311 } | 2318 } |
| 2312 #endif | 2319 #endif |
| 2313 | 2320 |
| 2314 SkColorType RenderWidgetHostImpl::PreferredReadbackFormat() { | 2321 SkColorType RenderWidgetHostImpl::PreferredReadbackFormat() { |
| 2315 if (view_) | 2322 if (view_) |
| 2316 return view_->PreferredReadbackFormat(); | 2323 return view_->PreferredReadbackFormat(); |
| 2317 return kN32_SkColorType; | 2324 return kN32_SkColorType; |
| 2318 } | 2325 } |
| 2319 | 2326 |
| 2320 } // namespace content | 2327 } // namespace content |
| OLD | NEW |