Index: mojo/services/view_manager/view_manager_init_service_impl.cc |
diff --git a/mojo/services/view_manager/view_manager_init_service_impl.cc b/mojo/services/view_manager/view_manager_init_service_impl.cc |
index 79cc6c48fb91747d70b98e7b3b48ecb9108e1d8d..e375439f46be8c2f95c9ee86d440f1fb898a32b6 100644 |
--- a/mojo/services/view_manager/view_manager_init_service_impl.cc |
+++ b/mojo/services/view_manager/view_manager_init_service_impl.cc |
@@ -7,6 +7,7 @@ |
#include "base/bind.h" |
#include "mojo/public/interfaces/service_provider/service_provider.mojom.h" |
#include "mojo/services/view_manager/ids.h" |
+#include "mojo/services/view_manager/view_manager_init_service_context.h" |
#include "mojo/services/view_manager/view_manager_service_impl.h" |
namespace mojo { |
@@ -19,25 +20,34 @@ ViewManagerInitServiceImpl::ConnectParams::ConnectParams() {} |
ViewManagerInitServiceImpl::ConnectParams::~ConnectParams() {} |
ViewManagerInitServiceImpl::ViewManagerInitServiceImpl( |
- ApplicationConnection* connection) |
- : root_node_manager_( |
- connection, |
- this, |
- base::Bind(&ViewManagerInitServiceImpl::OnNativeViewportDeleted, |
- base::Unretained(this))), |
- is_tree_host_ready_(false) { |
+ ApplicationConnection* connection, |
+ ViewManagerInitServiceContext* context) |
+ : context_(context) { |
+ context_->AddConnection(this); |
} |
ViewManagerInitServiceImpl::~ViewManagerInitServiceImpl() { |
+ context_->RemoveConnection(this); |
+} |
+ |
+void ViewManagerInitServiceImpl::OnNativeViewportDeleted() { |
+ // TODO(beng): Should not have to rely on implementation detail of |
+ // InterfaceImpl to close the connection. Instead should simply |
+ // be able to delete this object. |
+ internal_state()->router()->CloseMessagePipe(); |
+} |
+ |
+void ViewManagerInitServiceImpl::OnRootViewManagerWindowTreeHostCreated() { |
+ MaybeEmbed(); |
} |
void ViewManagerInitServiceImpl::MaybeEmbed() { |
- if (!is_tree_host_ready_) |
+ if (!context_->is_tree_host_ready()) |
return; |
ScopedVector<ConnectParams>::const_iterator it = connect_params_.begin(); |
for (; it != connect_params_.end(); ++it) { |
- root_node_manager_.EmbedRoot((*it)->url); |
+ context_->root_node_manager()->EmbedRoot((*it)->url); |
(*it)->callback.Run(true); |
} |
connect_params_.clear(); |
@@ -53,19 +63,6 @@ void ViewManagerInitServiceImpl::Embed( |
MaybeEmbed(); |
} |
-void ViewManagerInitServiceImpl::OnRootViewManagerWindowTreeHostCreated() { |
- DCHECK(!is_tree_host_ready_); |
- is_tree_host_ready_ = true; |
- MaybeEmbed(); |
-} |
- |
-void ViewManagerInitServiceImpl::OnNativeViewportDeleted() { |
- // TODO(beng): Should not have to rely on implementation detail of |
- // InterfaceImpl to close the connection. Instead should simply |
- // be able to delete this object. |
- internal_state()->router()->CloseMessagePipe(); |
-} |
- |
} // namespace service |
} // namespace view_manager |
} // namespace mojo |