Minor cleanup of ViewManagerServiceImpl

Removes override of OnConnectionEstablished and puts into Init()
function.

R=ben@chromium.org

Review URL: https://codereview.chromium.org/707633005
diff --git a/mojo/services/view_manager/connection_manager.cc b/mojo/services/view_manager/connection_manager.cc
index f093dca..d5916ee 100644
--- a/mojo/services/view_manager/connection_manager.cc
+++ b/mojo/services/view_manager/connection_manager.cc
@@ -139,10 +139,10 @@
                                  creator_id,
                                  creator_url,
                                  url.To<std::string>(),
-                                 ViewIdFromTransportId(transport_view_id),
-                                 service_provider.Pass());
+                                 ViewIdFromTransportId(transport_view_id));
   AddConnection(connection);
   WeakBindToPipe(connection, pipe.handle0.Pass());
+  connection->Init(service_provider.Pass());
   OnConnectionMessagedClient(connection->id());
 }
 
@@ -362,10 +362,10 @@
                                  kInvalidConnectionId,
                                  std::string(),
                                  std::string("mojo:window_manager"),
-                                 RootViewId(),
-                                 InterfaceRequest<ServiceProvider>());
+                                 RootViewId());
   AddConnection(window_manager_vm_service_);
   WeakBindToRequest(window_manager_vm_service_, &request);
+  window_manager_vm_service_->Init(InterfaceRequest<ServiceProvider>());
 }
 
 void ConnectionManager::Create(
diff --git a/mojo/services/view_manager/view_manager_service_impl.cc b/mojo/services/view_manager/view_manager_service_impl.cc
index 07bf803..323d2db 100644
--- a/mojo/services/view_manager/view_manager_service_impl.cc
+++ b/mojo/services/view_manager/view_manager_service_impl.cc
@@ -22,14 +22,12 @@
     ConnectionSpecificId creator_id,
     const std::string& creator_url,
     const std::string& url,
-    const ViewId& root_id,
-    InterfaceRequest<ServiceProvider> service_provider)
+    const ViewId& root_id)
     : connection_manager_(connection_manager),
       id_(connection_manager_->GetAndAdvanceNextConnectionId()),
       url_(url),
       creator_id_(creator_id),
-      creator_url_(creator_url),
-      service_provider_(service_provider.Pass()) {
+      creator_url_(creator_url) {
   CHECK(GetView(root_id));
   root_.reset(new ViewId(root_id));
   if (root_id == RootViewId())
@@ -42,6 +40,22 @@
   DestroyViews();
 }
 
+void ViewManagerServiceImpl::Init(
+    InterfaceRequest<ServiceProvider> service_provider) {
+  std::vector<const ServerView*> to_send;
+  if (root_.get())
+    GetUnknownViewsFrom(GetView(*root_), &to_send);
+
+  MessagePipe pipe;
+  connection_manager_->wm_internal()->CreateWindowManagerForViewManagerClient(
+      id_, pipe.handle1.Pass());
+  client()->OnEmbed(id_,
+                    creator_url_,
+                    ViewToViewData(to_send.front()),
+                    service_provider.Pass(),
+                    pipe.handle0.Pass());
+}
+
 const ServerView* ViewManagerServiceImpl::GetView(const ViewId& id) const {
   if (id_ == id.connection_id) {
     ViewMap::const_iterator i = view_map_.find(id.view_id);
@@ -550,21 +564,6 @@
   callback.Run(true);
 }
 
-void ViewManagerServiceImpl::OnConnectionEstablished() {
-  std::vector<const ServerView*> to_send;
-  if (root_.get())
-    GetUnknownViewsFrom(GetView(*root_), &to_send);
-
-  MessagePipe pipe;
-  connection_manager_->wm_internal()->CreateWindowManagerForViewManagerClient(
-      id_, pipe.handle1.Pass());
-  client()->OnEmbed(id_,
-                    creator_url_,
-                    ViewToViewData(to_send.front()),
-                    service_provider_.Pass(),
-                    pipe.handle0.Pass());
-}
-
 bool ViewManagerServiceImpl::IsRootForAccessPolicy(const ViewId& id) const {
   return IsRoot(id);
 }
diff --git a/mojo/services/view_manager/view_manager_service_impl.h b/mojo/services/view_manager/view_manager_service_impl.h
index 4d89b75..61186c8 100644
--- a/mojo/services/view_manager/view_manager_service_impl.h
+++ b/mojo/services/view_manager/view_manager_service_impl.h
@@ -47,10 +47,13 @@
                          ConnectionSpecificId creator_id,
                          const std::string& creator_url,
                          const std::string& url,
-                         const ViewId& root_id,
-                         InterfaceRequest<ServiceProvider> service_provider);
+                         const ViewId& root_id);
   ~ViewManagerServiceImpl() override;
 
+  // Called after bound. |service_provider| is the ServiceProvider to pass to
+  // the client via OnEmbed().
+  void Init(InterfaceRequest<ServiceProvider> service_provider);
+
   ConnectionSpecificId id() const { return id_; }
   ConnectionSpecificId creator_id() const { return creator_id_; }
   const std::string& url() const { return url_; }
@@ -186,9 +189,6 @@
              ServiceProviderPtr service_provider,
              const Callback<void(bool)>& callback) override;
 
-  // InterfaceImpl:
-  void OnConnectionEstablished() override;
-
   // AccessPolicyDelegate:
   bool IsRootForAccessPolicy(const ViewId& id) const override;
   bool IsViewKnownForAccessPolicy(const ServerView* view) const override;
@@ -224,8 +224,6 @@
   // is destroyed or Embed() is invoked on the root.
   scoped_ptr<ViewId> root_;
 
-  InterfaceRequest<ServiceProvider> service_provider_;
-
   DISALLOW_COPY_AND_ASSIGN(ViewManagerServiceImpl);
 };