| Index: mojo/services/view_manager/connection_manager.cc
|
| diff --git a/mojo/services/view_manager/connection_manager.cc b/mojo/services/view_manager/connection_manager.cc
|
| index 24a497ed963067bd88388fa2bbc810e6ccc9bfed..ddac108fd6bc9c9c5f07eb02cef650771cb9991c 100644
|
| --- a/mojo/services/view_manager/connection_manager.cc
|
| +++ b/mojo/services/view_manager/connection_manager.cc
|
| @@ -10,6 +10,7 @@
|
| #include "mojo/converters/input_events/input_events_type_converters.h"
|
| #include "mojo/public/cpp/application/application_connection.h"
|
| #include "mojo/public/interfaces/application/service_provider.mojom.h"
|
| +#include "mojo/services/view_manager/client_connection.h"
|
| #include "mojo/services/view_manager/connection_manager_delegate.h"
|
| #include "mojo/services/view_manager/view_manager_service_impl.h"
|
|
|
| @@ -19,9 +20,9 @@ namespace service {
|
| class WindowManagerInternalClientImpl
|
| : public InterfaceImpl<WindowManagerInternalClient> {
|
| public:
|
| - WindowManagerInternalClientImpl(WindowManagerInternalClient* real_client,
|
| - ErrorHandler* error_handler)
|
| - : real_client_(real_client), error_handler_(error_handler) {}
|
| + explicit WindowManagerInternalClientImpl(
|
| + WindowManagerInternalClient* real_client)
|
| + : real_client_(real_client) {}
|
| ~WindowManagerInternalClientImpl() override {}
|
|
|
| // WindowManagerInternalClient:
|
| @@ -33,12 +34,10 @@ class WindowManagerInternalClientImpl
|
| real_client_->SetViewportSize(size.Pass());
|
| }
|
|
|
| - // InterfaceImpl:
|
| - void OnConnectionError() override { error_handler_->OnConnectionError(); }
|
| + // TODO(sky): ErrorHandling temporarily nuked. Will be fixed shortly.
|
|
|
| private:
|
| WindowManagerInternalClient* real_client_;
|
| - ErrorHandler* error_handler_;
|
|
|
| DISALLOW_COPY_AND_ASSIGN(WindowManagerInternalClientImpl);
|
| };
|
| @@ -61,7 +60,7 @@ ConnectionManager::ConnectionManager(ApplicationConnection* app_connection,
|
| ConnectionManagerDelegate* delegate)
|
| : app_connection_(app_connection),
|
| delegate_(delegate),
|
| - window_manager_vm_service_(nullptr),
|
| + window_manager_client_connection_(nullptr),
|
| next_connection_id_(1),
|
| display_manager_(
|
| app_connection,
|
| @@ -96,23 +95,22 @@ ConnectionSpecificId ConnectionManager::GetAndAdvanceNextConnectionId() {
|
| return id;
|
| }
|
|
|
| -void ConnectionManager::OnConnectionError(ViewManagerServiceImpl* connection) {
|
| - if (connection == window_manager_vm_service_) {
|
| - window_manager_vm_service_ = nullptr;
|
| +void ConnectionManager::OnConnectionError(ClientConnection* connection) {
|
| + if (connection == window_manager_client_connection_) {
|
| + window_manager_client_connection_ = nullptr;
|
| delegate_->OnLostConnectionToWindowManager();
|
| // Assume we've been destroyed.
|
| return;
|
| }
|
|
|
| - scoped_ptr<ViewManagerServiceImpl> connection_owner(connection);
|
| + scoped_ptr<ClientConnection> connection_owner(connection);
|
|
|
| - connection_map_.erase(connection->id());
|
| + connection_map_.erase(connection->service()->id());
|
|
|
| // Notify remaining connections so that they can cleanup.
|
| - for (ConnectionMap::const_iterator i = connection_map_.begin();
|
| - i != connection_map_.end();
|
| - ++i) {
|
| - i->second->OnWillDestroyViewManagerServiceImpl(connection);
|
| + for (auto& pair : connection_map_) {
|
| + pair.second->service()->OnWillDestroyViewManagerServiceImpl(
|
| + connection->service());
|
| }
|
| }
|
|
|
| @@ -121,42 +119,41 @@ void ConnectionManager::EmbedAtView(
|
| const String& url,
|
| Id transport_view_id,
|
| InterfaceRequest<ServiceProvider> service_provider) {
|
| + std::string creator_url;
|
| + ConnectionMap::const_iterator it = connection_map_.find(creator_id);
|
| + if (it != connection_map_.end())
|
| + creator_url = it->second->service()->url();
|
| +
|
| MessagePipe pipe;
|
|
|
| ServiceProvider* view_manager_service_provider =
|
| app_connection_->ConnectToApplication(url)->GetServiceProvider();
|
| -
|
| view_manager_service_provider->ConnectToService(
|
| ViewManagerServiceImpl::Client::Name_, pipe.handle1.Pass());
|
| -
|
| - std::string creator_url;
|
| - ConnectionMap::const_iterator it = connection_map_.find(creator_id);
|
| - if (it != connection_map_.end())
|
| - creator_url = it->second->url();
|
| -
|
| - ViewManagerServiceImpl* connection =
|
| - new ViewManagerServiceImpl(this,
|
| - creator_id,
|
| - creator_url,
|
| - url.To<std::string>(),
|
| - ViewIdFromTransportId(transport_view_id));
|
| - AddConnection(connection);
|
| - WeakBindToPipe(connection, pipe.handle0.Pass());
|
| - connection->Init(service_provider.Pass());
|
| - OnConnectionMessagedClient(connection->id());
|
| + scoped_ptr<ViewManagerServiceImpl> service(
|
| + new ViewManagerServiceImpl(this, creator_id, creator_url, url,
|
| + ViewIdFromTransportId(transport_view_id)));
|
| + DefaultClientConnection* client_connection =
|
| + new DefaultClientConnection(this, service.Pass());
|
| + client_connection->binding()->Bind(pipe.handle0.Pass());
|
| + client_connection->SetClient();
|
| + AddConnection(client_connection);
|
| + client_connection->service()->Init(client_connection->client(),
|
| + service_provider.Pass());
|
| + OnConnectionMessagedClient(client_connection->service()->id());
|
| }
|
|
|
| ViewManagerServiceImpl* ConnectionManager::GetConnection(
|
| ConnectionSpecificId connection_id) {
|
| ConnectionMap::iterator i = connection_map_.find(connection_id);
|
| - return i == connection_map_.end() ? NULL : i->second;
|
| + return i == connection_map_.end() ? nullptr : i->second->service();
|
| }
|
|
|
| ServerView* ConnectionManager::GetView(const ViewId& id) {
|
| if (id == root_->id())
|
| return root_.get();
|
| - ConnectionMap::iterator i = connection_map_.find(id.connection_id);
|
| - return i == connection_map_.end() ? NULL : i->second->GetView(id);
|
| + ViewManagerServiceImpl* service = GetConnection(id.connection_id);
|
| + return service ? service->GetView(id) : nullptr;
|
| }
|
|
|
| void ConnectionManager::OnConnectionMessagedClient(ConnectionSpecificId id) {
|
| @@ -171,23 +168,19 @@ bool ConnectionManager::DidConnectionMessageClient(
|
|
|
| const ViewManagerServiceImpl* ConnectionManager::GetConnectionWithRoot(
|
| const ViewId& id) const {
|
| - for (ConnectionMap::const_iterator i = connection_map_.begin();
|
| - i != connection_map_.end();
|
| - ++i) {
|
| - if (i->second->IsRoot(id))
|
| - return i->second;
|
| + for (auto& pair : connection_map_) {
|
| + if (pair.second->service()->IsRoot(id))
|
| + return pair.second->service();
|
| }
|
| - return NULL;
|
| + return nullptr;
|
| }
|
|
|
| void ConnectionManager::ProcessViewBoundsChanged(const ServerView* view,
|
| const gfx::Rect& old_bounds,
|
| const gfx::Rect& new_bounds) {
|
| - for (ConnectionMap::iterator i = connection_map_.begin();
|
| - i != connection_map_.end();
|
| - ++i) {
|
| - i->second->ProcessViewBoundsChanged(
|
| - view, old_bounds, new_bounds, IsChangeSource(i->first));
|
| + for (auto& pair : connection_map_) {
|
| + pair.second->service()->ProcessViewBoundsChanged(
|
| + view, old_bounds, new_bounds, IsChangeSource(pair.first));
|
| }
|
| }
|
|
|
| @@ -195,11 +188,9 @@ void ConnectionManager::ProcessWillChangeViewHierarchy(
|
| const ServerView* view,
|
| const ServerView* new_parent,
|
| const ServerView* old_parent) {
|
| - for (ConnectionMap::iterator i = connection_map_.begin();
|
| - i != connection_map_.end();
|
| - ++i) {
|
| - i->second->ProcessWillChangeViewHierarchy(
|
| - view, new_parent, old_parent, IsChangeSource(i->first));
|
| + for (auto& pair : connection_map_) {
|
| + pair.second->service()->ProcessWillChangeViewHierarchy(
|
| + view, new_parent, old_parent, IsChangeSource(pair.first));
|
| }
|
| }
|
|
|
| @@ -207,30 +198,25 @@ void ConnectionManager::ProcessViewHierarchyChanged(
|
| const ServerView* view,
|
| const ServerView* new_parent,
|
| const ServerView* old_parent) {
|
| - for (ConnectionMap::iterator i = connection_map_.begin();
|
| - i != connection_map_.end();
|
| - ++i) {
|
| - i->second->ProcessViewHierarchyChanged(
|
| - view, new_parent, old_parent, IsChangeSource(i->first));
|
| + for (auto& pair : connection_map_) {
|
| + pair.second->service()->ProcessViewHierarchyChanged(
|
| + view, new_parent, old_parent, IsChangeSource(pair.first));
|
| }
|
| }
|
|
|
| void ConnectionManager::ProcessViewReorder(const ServerView* view,
|
| const ServerView* relative_view,
|
| const OrderDirection direction) {
|
| - for (ConnectionMap::iterator i = connection_map_.begin();
|
| - i != connection_map_.end();
|
| - ++i) {
|
| - i->second->ProcessViewReorder(
|
| - view, relative_view, direction, IsChangeSource(i->first));
|
| + for (auto& pair : connection_map_) {
|
| + pair.second->service()->ProcessViewReorder(view, relative_view, direction,
|
| + IsChangeSource(pair.first));
|
| }
|
| }
|
|
|
| void ConnectionManager::ProcessViewDeleted(const ViewId& view) {
|
| - for (ConnectionMap::iterator i = connection_map_.begin();
|
| - i != connection_map_.end();
|
| - ++i) {
|
| - i->second->ProcessViewDeleted(view, IsChangeSource(i->first));
|
| + for (auto& pair : connection_map_) {
|
| + pair.second->service()->ProcessViewDeleted(view,
|
| + IsChangeSource(pair.first));
|
| }
|
| }
|
|
|
| @@ -246,9 +232,9 @@ void ConnectionManager::FinishChange() {
|
| current_change_ = NULL;
|
| }
|
|
|
| -void ConnectionManager::AddConnection(ViewManagerServiceImpl* connection) {
|
| - DCHECK_EQ(0u, connection_map_.count(connection->id()));
|
| - connection_map_[connection->id()] = connection;
|
| +void ConnectionManager::AddConnection(ClientConnection* connection) {
|
| + DCHECK_EQ(0u, connection_map_.count(connection->service()->id()));
|
| + connection_map_[connection->service()->id()] = connection;
|
| }
|
|
|
| void ConnectionManager::OnViewDestroyed(const ServerView* view) {
|
| @@ -314,10 +300,9 @@ void ConnectionManager::OnWillChangeViewVisibility(const ServerView* view) {
|
| if (in_destructor_)
|
| return;
|
|
|
| - for (ConnectionMap::iterator i = connection_map_.begin();
|
| - i != connection_map_.end();
|
| - ++i) {
|
| - i->second->ProcessWillChangeViewVisibility(view, IsChangeSource(i->first));
|
| + for (auto& pair : connection_map_) {
|
| + pair.second->service()->ProcessWillChangeViewVisibility(
|
| + view, IsChangeSource(pair.first));
|
| }
|
| }
|
|
|
| @@ -326,7 +311,7 @@ void ConnectionManager::OnViewPropertyChanged(
|
| const std::string& name,
|
| const std::vector<uint8_t>* new_data) {
|
| for (auto& pair : connection_map_) {
|
| - pair.second->ProcessViewPropertyChanged(
|
| + pair.second->service()->ProcessViewPropertyChanged(
|
| view, name, new_data, IsChangeSource(pair.first));
|
| }
|
| }
|
| @@ -351,20 +336,23 @@ void ConnectionManager::DispatchInputEventToView(Id transport_view_id,
|
|
|
| void ConnectionManager::Create(ApplicationConnection* connection,
|
| InterfaceRequest<ViewManagerService> request) {
|
| - if (window_manager_vm_service_) {
|
| + if (window_manager_client_connection_) {
|
| VLOG(1) << "ViewManager interface requested more than once.";
|
| return;
|
| }
|
|
|
| - window_manager_vm_service_ =
|
| - new ViewManagerServiceImpl(this,
|
| - kInvalidConnectionId,
|
| - std::string(),
|
| - std::string("mojo:window_manager"),
|
| - RootViewId());
|
| - AddConnection(window_manager_vm_service_);
|
| - WeakBindToRequest(window_manager_vm_service_, &request);
|
| - window_manager_vm_service_->Init(InterfaceRequest<ServiceProvider>());
|
| + scoped_ptr<ViewManagerServiceImpl> service(new ViewManagerServiceImpl(
|
| + this, kInvalidConnectionId, std::string(),
|
| + std::string("mojo:window_manager"), RootViewId()));
|
| + DefaultClientConnection* client_connection =
|
| + new DefaultClientConnection(this, service.Pass());
|
| + client_connection->binding()->Bind(request.Pass());
|
| + client_connection->SetClient();
|
| + window_manager_client_connection_ = client_connection;
|
| + AddConnection(window_manager_client_connection_);
|
| + window_manager_client_connection_->service()->Init(
|
| + window_manager_client_connection_->client(),
|
| + InterfaceRequest<ServiceProvider>());
|
| }
|
|
|
| void ConnectionManager::Create(
|
| @@ -375,14 +363,9 @@ void ConnectionManager::Create(
|
| return;
|
| }
|
|
|
| - wm_internal_client_impl_.reset(
|
| - new WindowManagerInternalClientImpl(this, this));
|
| + wm_internal_client_impl_.reset(new WindowManagerInternalClientImpl(this));
|
| WeakBindToRequest(wm_internal_client_impl_.get(), &request);
|
| }
|
|
|
| -void ConnectionManager::OnConnectionError() {
|
| - delegate_->OnLostConnectionToWindowManager();
|
| -}
|
| -
|
| } // namespace service
|
| } // namespace mojo
|
|
|