| 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 if (view_weak_) |
| 239 view_weak_->RenderWidgetHostGone(); |
| 238 SetView(NULL); | 240 SetView(NULL); |
| 239 | 241 |
| 240 GpuSurfaceTracker::Get()->RemoveSurface(surface_id_); | 242 GpuSurfaceTracker::Get()->RemoveSurface(surface_id_); |
| 241 surface_id_ = 0; | 243 surface_id_ = 0; |
| 242 | 244 |
| 243 process_->RemoveRoute(routing_id_); | 245 process_->RemoveRoute(routing_id_); |
| 244 g_routing_id_widget_map.Get().erase( | 246 g_routing_id_widget_map.Get().erase( |
| 245 RenderWidgetHostID(process_->GetID(), routing_id_)); | 247 RenderWidgetHostID(process_->GetID(), routing_id_)); |
| 246 | 248 |
| 247 if (delegate_) | 249 if (delegate_) |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 303 | 305 |
| 304 return scoped_ptr<RenderWidgetHostIterator>(hosts); | 306 return scoped_ptr<RenderWidgetHostIterator>(hosts); |
| 305 } | 307 } |
| 306 | 308 |
| 307 // static | 309 // static |
| 308 RenderWidgetHostImpl* RenderWidgetHostImpl::From(RenderWidgetHost* rwh) { | 310 RenderWidgetHostImpl* RenderWidgetHostImpl::From(RenderWidgetHost* rwh) { |
| 309 return rwh->AsRenderWidgetHostImpl(); | 311 return rwh->AsRenderWidgetHostImpl(); |
| 310 } | 312 } |
| 311 | 313 |
| 312 void RenderWidgetHostImpl::SetView(RenderWidgetHostViewBase* view) { | 314 void RenderWidgetHostImpl::SetView(RenderWidgetHostViewBase* view) { |
| 315 if (view) |
| 316 view_weak_ = view->GetWeakPtr(); |
| 317 else |
| 318 view_weak_.reset(); |
| 313 view_ = view; | 319 view_ = view; |
| 314 | 320 |
| 315 GpuSurfaceTracker::Get()->SetSurfaceHandle( | 321 GpuSurfaceTracker::Get()->SetSurfaceHandle( |
| 316 surface_id_, GetCompositingSurface()); | 322 surface_id_, GetCompositingSurface()); |
| 317 | 323 |
| 318 synthetic_gesture_controller_.reset(); | 324 synthetic_gesture_controller_.reset(); |
| 319 } | 325 } |
| 320 | 326 |
| 321 RenderProcessHost* RenderWidgetHostImpl::GetProcess() const { | 327 RenderProcessHost* RenderWidgetHostImpl::GetProcess() const { |
| 322 return process_; | 328 return process_; |
| (...skipping 889 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1212 is_hidden_ = false; | 1218 is_hidden_ = false; |
| 1213 } | 1219 } |
| 1214 | 1220 |
| 1215 // Reset this to ensure the hung renderer mechanism is working properly. | 1221 // Reset this to ensure the hung renderer mechanism is working properly. |
| 1216 in_flight_event_count_ = 0; | 1222 in_flight_event_count_ = 0; |
| 1217 | 1223 |
| 1218 if (view_) { | 1224 if (view_) { |
| 1219 GpuSurfaceTracker::Get()->SetSurfaceHandle(surface_id_, | 1225 GpuSurfaceTracker::Get()->SetSurfaceHandle(surface_id_, |
| 1220 gfx::GLSurfaceHandle()); | 1226 gfx::GLSurfaceHandle()); |
| 1221 view_->RenderProcessGone(status, exit_code); | 1227 view_->RenderProcessGone(status, exit_code); |
| 1222 view_ = NULL; // The View should be deleted by RenderProcessGone. | 1228 view_ = NULL; // The View should be deleted by RenderProcessGone. |
| 1229 view_weak_.reset(); |
| 1223 } | 1230 } |
| 1224 | 1231 |
| 1225 // Reconstruct the input router to ensure that it has fresh state for a new | 1232 // 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 | 1233 // 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 | 1234 // event. (In particular, the above call to view_->RenderProcessGone will |
| 1228 // destroy the aura window, which may dispatch a synthetic mouse move.) | 1235 // destroy the aura window, which may dispatch a synthetic mouse move.) |
| 1229 input_router_.reset(new InputRouterImpl( | 1236 input_router_.reset(new InputRouterImpl( |
| 1230 process_, this, this, routing_id_, GetInputRouterConfigForPlatform())); | 1237 process_, this, this, routing_id_, GetInputRouterConfigForPlatform())); |
| 1231 | 1238 |
| 1232 synthetic_gesture_controller_.reset(); | 1239 synthetic_gesture_controller_.reset(); |
| (...skipping 1082 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2315 } | 2322 } |
| 2316 #endif | 2323 #endif |
| 2317 | 2324 |
| 2318 SkColorType RenderWidgetHostImpl::PreferredReadbackFormat() { | 2325 SkColorType RenderWidgetHostImpl::PreferredReadbackFormat() { |
| 2319 if (view_) | 2326 if (view_) |
| 2320 return view_->PreferredReadbackFormat(); | 2327 return view_->PreferredReadbackFormat(); |
| 2321 return kN32_SkColorType; | 2328 return kN32_SkColorType; |
| 2322 } | 2329 } |
| 2323 | 2330 |
| 2324 } // namespace content | 2331 } // namespace content |
| OLD | NEW |