Index: mojo/examples/surfaces_app/child_impl.cc |
diff --git a/mojo/examples/surfaces_app/child_impl.cc b/mojo/examples/surfaces_app/child_impl.cc |
index 578c65c000ed9225befecf2c008de4bcb9d488bd..90439cf7f27cdd2fb89ededa4312d4a3a02aa3f7 100644 |
--- a/mojo/examples/surfaces_app/child_impl.cc |
+++ b/mojo/examples/surfaces_app/child_impl.cc |
@@ -27,13 +27,16 @@ using cc::SolidColorDrawQuad; |
using cc::DelegatedFrameData; |
using cc::CompositorFrame; |
-ChildImpl::ChildImpl(ApplicationConnection* surfaces_service_connection) { |
- surfaces_service_connection->ConnectToService(&surface_); |
- surface_.set_client(this); |
+ChildImpl::ChildImpl(ApplicationConnection* surfaces_service_connection) |
+ : weak_factory_(this) { |
+ surfaces_service_connection->ConnectToService(&surfaces_service_); |
+ surfaces_service_->CreateSurfaceConnection(base::Bind( |
+ &ChildImpl::SurfaceConnectionCreated, weak_factory_.GetWeakPtr())); |
} |
ChildImpl::~ChildImpl() { |
- surface_->DestroySurface(mojo::SurfaceId::From(id_)); |
+ if (surface_) |
+ surface_->DestroySurface(mojo::SurfaceId::From(id_)); |
} |
void ChildImpl::ProduceFrame( |
@@ -47,7 +50,10 @@ void ChildImpl::ProduceFrame( |
Draw(); |
} |
-void ChildImpl::SetIdNamespace(uint32_t id_namespace) { |
+void ChildImpl::SurfaceConnectionCreated(SurfacePtr surface, |
+ uint32_t id_namespace) { |
+ surface_ = surface.Pass(); |
+ surface_.set_client(this); |
allocator_.reset(new cc::SurfaceIdAllocator(id_namespace)); |
if (!produce_callback_.is_null()) |
Draw(); |