Index: cc/test/test_compositor_frame_sink.cc |
diff --git a/cc/test/test_compositor_frame_sink.cc b/cc/test/test_compositor_frame_sink.cc |
index c06eac6b38a026e5644602c9d5032d685383d592..5930e3a9d7b18311496d3e0cafdd32baf29f8ac8 100644 |
--- a/cc/test/test_compositor_frame_sink.cc |
+++ b/cc/test/test_compositor_frame_sink.cc |
@@ -34,7 +34,8 @@ TestCompositorFrameSink::TestCompositorFrameSink( |
surface_manager_(new SurfaceManager), |
surface_id_allocator_(new SurfaceIdAllocator( |
FrameSinkId(kCompositorClientId, kCompositorSinkId))), |
- surface_factory_(new SurfaceFactory(surface_manager_.get(), this)) { |
+ surface_factory_(new SurfaceFactory(surface_manager_.get(), this)), |
+ weak_ptrs_(this) { |
std::unique_ptr<SyntheticBeginFrameSource> begin_frame_source; |
std::unique_ptr<DisplayScheduler> scheduler; |
if (!synchronous_composite) { |
@@ -116,6 +117,7 @@ void TestCompositorFrameSink::DetachFromClient() { |
surface_factory_ = nullptr; |
surface_id_allocator_ = nullptr; |
surface_manager_ = nullptr; |
+ weak_ptrs_.InvalidateWeakPtrs(); |
CompositorFrameSink::DetachFromClient(); |
} |
@@ -139,7 +141,7 @@ void TestCompositorFrameSink::SwapBuffers(CompositorFrame frame) { |
surface_factory_->SubmitCompositorFrame( |
delegated_surface_id_, std::move(frame), |
base::Bind(&TestCompositorFrameSink::DidDrawCallback, |
- base::Unretained(this))); |
+ weak_ptrs_.GetWeakPtr(), synchronous)); |
for (std::unique_ptr<CopyOutputRequest>& copy_request : copy_requests_) |
surface_factory_->RequestCopyOfSurface(delegated_surface_id_, |
@@ -150,10 +152,17 @@ void TestCompositorFrameSink::SwapBuffers(CompositorFrame frame) { |
display_->DrawAndSwap(); |
} |
-void TestCompositorFrameSink::DidDrawCallback() { |
+void TestCompositorFrameSink::DidDrawCallback(bool synchronous) { |
// This is the frame ack to unthrottle the next frame, not actually a notice |
// that drawing is done. |
- CompositorFrameSink::PostSwapBuffersComplete(); |
+ if (synchronous) { |
+ // For synchronous draws, this must be posted to a new stack because we are |
+ // still the original call to SwapBuffers, and we want to leave that before |
+ // saying that it is done. |
+ CompositorFrameSink::PostSwapBuffersComplete(); |
+ } else { |
+ client_->DidSwapBuffersComplete(); |
+ } |
} |
void TestCompositorFrameSink::ForceReclaimResources() { |