OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/frame_host/render_widget_host_view_guest.h" | 5 #include "content/browser/frame_host/render_widget_host_view_guest.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/bind_helpers.h" | 9 #include "base/bind_helpers.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
276 | 276 |
277 // Check whether we need to recreate the cc::Surface, which means the child | 277 // Check whether we need to recreate the cc::Surface, which means the child |
278 // frame renderer has changed its output surface, or size, or scale factor. | 278 // frame renderer has changed its output surface, or size, or scale factor. |
279 if (output_surface_id != last_output_surface_id_ && surface_factory_) { | 279 if (output_surface_id != last_output_surface_id_ && surface_factory_) { |
280 surface_factory_->Destroy(surface_id_); | 280 surface_factory_->Destroy(surface_id_); |
281 surface_factory_.reset(); | 281 surface_factory_.reset(); |
282 } | 282 } |
283 if (output_surface_id != last_output_surface_id_ || | 283 if (output_surface_id != last_output_surface_id_ || |
284 frame_size != current_surface_size_ || | 284 frame_size != current_surface_size_ || |
285 scale_factor != current_surface_scale_factor_ || | 285 scale_factor != current_surface_scale_factor_ || |
286 guest_->has_attached_since_surface_set()) { | 286 (guest_ && guest_->has_attached_since_surface_set())) { |
287 ClearCompositorSurfaceIfNecessary(); | 287 ClearCompositorSurfaceIfNecessary(); |
288 last_output_surface_id_ = output_surface_id; | 288 last_output_surface_id_ = output_surface_id; |
289 current_surface_size_ = frame_size; | 289 current_surface_size_ = frame_size; |
290 current_surface_scale_factor_ = scale_factor; | 290 current_surface_scale_factor_ = scale_factor; |
291 } | 291 } |
292 | 292 |
293 if (!surface_factory_) { | 293 if (!surface_factory_) { |
294 cc::SurfaceManager* manager = GetSurfaceManager(); | 294 cc::SurfaceManager* manager = GetSurfaceManager(); |
295 surface_factory_ = base::MakeUnique<cc::SurfaceFactory>(manager, this); | 295 surface_factory_ = base::MakeUnique<cc::SurfaceFactory>(manager, this); |
296 } | 296 } |
297 | 297 |
298 if (surface_id_.is_null()) { | 298 if (surface_id_.is_null()) { |
299 surface_id_ = id_allocator_->GenerateId(); | 299 surface_id_ = id_allocator_->GenerateId(); |
300 surface_factory_->Create(surface_id_); | 300 surface_factory_->Create(surface_id_); |
301 | 301 |
302 cc::SurfaceSequence sequence = cc::SurfaceSequence( | 302 cc::SurfaceSequence sequence = cc::SurfaceSequence( |
303 id_allocator_->client_id(), next_surface_sequence_++); | 303 id_allocator_->client_id(), next_surface_sequence_++); |
304 // The renderer process will satisfy this dependency when it creates a | 304 // The renderer process will satisfy this dependency when it creates a |
305 // SurfaceLayer. | 305 // SurfaceLayer. |
306 cc::SurfaceManager* manager = GetSurfaceManager(); | 306 cc::SurfaceManager* manager = GetSurfaceManager(); |
307 manager->GetSurfaceForId(surface_id_)->AddDestructionDependency(sequence); | 307 manager->GetSurfaceForId(surface_id_)->AddDestructionDependency(sequence); |
308 guest_->SetChildFrameSurface(surface_id_, frame_size, scale_factor, | 308 // TODO(wjmaclean): I'm not sure what it means to create a surface id |
309 sequence); | 309 // without setting it on the child, though since we will in this case be |
310 // guaranteed to call ClearCompositorSurfaceIfNecessary() below, I suspect | |
311 // skipping SetChildFrameSurface() here is irrelevant. | |
312 if (guest_ && !guest_->is_in_destruction()) { | |
Charlie Reis
2016/09/19 17:29:21
If the crash is actually a UaF on guest_, then nei
| |
313 guest_->SetChildFrameSurface(surface_id_, frame_size, scale_factor, | |
314 sequence); | |
315 } | |
310 } | 316 } |
311 | 317 |
312 cc::SurfaceFactory::DrawCallback ack_callback = base::Bind( | 318 cc::SurfaceFactory::DrawCallback ack_callback = base::Bind( |
313 &RenderWidgetHostViewChildFrame::SurfaceDrawn, | 319 &RenderWidgetHostViewChildFrame::SurfaceDrawn, |
314 RenderWidgetHostViewChildFrame::AsWeakPtr(), output_surface_id); | 320 RenderWidgetHostViewChildFrame::AsWeakPtr(), output_surface_id); |
315 ack_pending_count_++; | 321 ack_pending_count_++; |
316 // If this value grows very large, something is going wrong. | 322 // If this value grows very large, something is going wrong. |
317 DCHECK(ack_pending_count_ < 1000); | 323 DCHECK(ack_pending_count_ < 1000); |
318 surface_factory_->SubmitCompositorFrame(surface_id_, std::move(frame), | 324 surface_factory_->SubmitCompositorFrame(surface_id_, std::move(frame), |
319 ack_callback); | 325 ack_callback); |
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
664 gesture_event.data.scrollUpdate.inertialPhase == | 670 gesture_event.data.scrollUpdate.inertialPhase == |
665 blink::WebGestureEvent::MomentumPhase) { | 671 blink::WebGestureEvent::MomentumPhase) { |
666 return; | 672 return; |
667 } | 673 } |
668 host_->ForwardGestureEvent(gesture_event); | 674 host_->ForwardGestureEvent(gesture_event); |
669 return; | 675 return; |
670 } | 676 } |
671 } | 677 } |
672 | 678 |
673 } // namespace content | 679 } // namespace content |
OLD | NEW |