| 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 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 177 ignore_input_events_(false), | 177 ignore_input_events_(false), |
| 178 input_method_active_(false), | 178 input_method_active_(false), |
| 179 text_direction_updated_(false), | 179 text_direction_updated_(false), |
| 180 text_direction_(blink::WebTextDirectionLeftToRight), | 180 text_direction_(blink::WebTextDirectionLeftToRight), |
| 181 text_direction_canceled_(false), | 181 text_direction_canceled_(false), |
| 182 suppress_next_char_events_(false), | 182 suppress_next_char_events_(false), |
| 183 pending_mouse_lock_request_(false), | 183 pending_mouse_lock_request_(false), |
| 184 allow_privileged_mouse_lock_(false), | 184 allow_privileged_mouse_lock_(false), |
| 185 has_touch_handler_(false), | 185 has_touch_handler_(false), |
| 186 next_browser_snapshot_id_(1), | 186 next_browser_snapshot_id_(1), |
| 187 owned_by_render_frame_host_(false), |
| 187 weak_factory_(this) { | 188 weak_factory_(this) { |
| 188 CHECK(delegate_); | 189 CHECK(delegate_); |
| 189 if (routing_id_ == MSG_ROUTING_NONE) { | 190 if (routing_id_ == MSG_ROUTING_NONE) { |
| 190 routing_id_ = process_->GetNextRoutingID(); | 191 routing_id_ = process_->GetNextRoutingID(); |
| 191 surface_id_ = GpuSurfaceTracker::Get()->AddSurfaceForRenderer( | 192 surface_id_ = GpuSurfaceTracker::Get()->AddSurfaceForRenderer( |
| 192 process_->GetID(), | 193 process_->GetID(), |
| 193 routing_id_); | 194 routing_id_); |
| 194 } else { | 195 } else { |
| 195 // TODO(piman): This is a O(N) lookup, where we could forward the | 196 // TODO(piman): This is a O(N) lookup, where we could forward the |
| 196 // information from the RenderWidgetHelper. The problem is that doing so | 197 // information from the RenderWidgetHelper. The problem is that doing so |
| (...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 407 GpuSurfaceTracker::Get()->SetSurfaceHandle( | 408 GpuSurfaceTracker::Get()->SetSurfaceHandle( |
| 408 surface_id_, GetCompositingSurface()); | 409 surface_id_, GetCompositingSurface()); |
| 409 | 410 |
| 410 // Send the ack along with the information on placement. | 411 // Send the ack along with the information on placement. |
| 411 Send(new ViewMsg_CreatingNew_ACK(routing_id_)); | 412 Send(new ViewMsg_CreatingNew_ACK(routing_id_)); |
| 412 GetProcess()->ResumeRequestsForView(routing_id_); | 413 GetProcess()->ResumeRequestsForView(routing_id_); |
| 413 | 414 |
| 414 WasResized(); | 415 WasResized(); |
| 415 } | 416 } |
| 416 | 417 |
| 418 void RenderWidgetHostImpl::InitForFrame() { |
| 419 DCHECK(process_->HasConnection()); |
| 420 owned_by_render_frame_host_ = true; |
| 421 renderer_initialized_ = true; |
| 422 } |
| 423 |
| 417 void RenderWidgetHostImpl::Shutdown() { | 424 void RenderWidgetHostImpl::Shutdown() { |
| 418 RejectMouseLockOrUnlockIfNecessary(); | 425 RejectMouseLockOrUnlockIfNecessary(); |
| 419 | 426 |
| 420 if (process_->HasConnection()) { | 427 if (process_->HasConnection()) { |
| 421 // Tell the renderer object to close. | 428 // Tell the renderer object to close. |
| 422 bool rv = Send(new ViewMsg_Close(routing_id_)); | 429 bool rv = Send(new ViewMsg_Close(routing_id_)); |
| 423 DCHECK(rv); | 430 DCHECK(rv); |
| 424 } | 431 } |
| 425 | 432 |
| 426 Destroy(); | 433 Destroy(); |
| (...skipping 897 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1324 Source<RenderWidgetHost>(this), | 1331 Source<RenderWidgetHost>(this), |
| 1325 NotificationService::NoDetails()); | 1332 NotificationService::NoDetails()); |
| 1326 | 1333 |
| 1327 // Tell the view to die. | 1334 // Tell the view to die. |
| 1328 // Note that in the process of the view shutting down, it can call a ton | 1335 // Note that in the process of the view shutting down, it can call a ton |
| 1329 // of other messages on us. So if you do any other deinitialization here, | 1336 // of other messages on us. So if you do any other deinitialization here, |
| 1330 // do it after this call to view_->Destroy(). | 1337 // do it after this call to view_->Destroy(). |
| 1331 if (view_) | 1338 if (view_) |
| 1332 view_->Destroy(); | 1339 view_->Destroy(); |
| 1333 | 1340 |
| 1334 delete this; | 1341 // RenderFrameHost owns a RenderWidgetHost when it needs one, in which case |
| 1342 // it handles destruction. |
| 1343 if (!owned_by_render_frame_host_) |
| 1344 delete this; |
| 1335 } | 1345 } |
| 1336 | 1346 |
| 1337 void RenderWidgetHostImpl::RendererIsUnresponsive() { | 1347 void RenderWidgetHostImpl::RendererIsUnresponsive() { |
| 1338 NotificationService::current()->Notify( | 1348 NotificationService::current()->Notify( |
| 1339 NOTIFICATION_RENDER_WIDGET_HOST_HANG, | 1349 NOTIFICATION_RENDER_WIDGET_HOST_HANG, |
| 1340 Source<RenderWidgetHost>(this), | 1350 Source<RenderWidgetHost>(this), |
| 1341 NotificationService::NoDetails()); | 1351 NotificationService::NoDetails()); |
| 1342 is_unresponsive_ = true; | 1352 is_unresponsive_ = true; |
| 1343 NotifyRendererUnresponsive(); | 1353 NotifyRendererUnresponsive(); |
| 1344 } | 1354 } |
| (...skipping 819 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2164 } | 2174 } |
| 2165 #endif | 2175 #endif |
| 2166 | 2176 |
| 2167 SkColorType RenderWidgetHostImpl::PreferredReadbackFormat() { | 2177 SkColorType RenderWidgetHostImpl::PreferredReadbackFormat() { |
| 2168 if (view_) | 2178 if (view_) |
| 2169 return view_->PreferredReadbackFormat(); | 2179 return view_->PreferredReadbackFormat(); |
| 2170 return kN32_SkColorType; | 2180 return kN32_SkColorType; |
| 2171 } | 2181 } |
| 2172 | 2182 |
| 2173 } // namespace content | 2183 } // namespace content |
| OLD | NEW |