| OLD | NEW |
| (Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "components/mus/ws/window_manager_factory_registry.h" |
| 6 |
| 7 #include "components/mus/ws/connection_manager.h" |
| 8 #include "components/mus/ws/window_manager_factory_service.h" |
| 9 |
| 10 namespace mus { |
| 11 namespace ws { |
| 12 |
| 13 WindowManagerFactoryRegistry::WindowManagerFactoryRegistry( |
| 14 ConnectionManager* connection_manager) |
| 15 : connection_manager_(connection_manager) {} |
| 16 |
| 17 WindowManagerFactoryRegistry::~WindowManagerFactoryRegistry() {} |
| 18 |
| 19 void WindowManagerFactoryRegistry::Register( |
| 20 uint32_t user_id, |
| 21 mojo::InterfaceRequest<mojom::WindowManagerFactoryService> request) { |
| 22 for (auto& service_ptr : services_) { |
| 23 if (service_ptr->user_id() == user_id) { |
| 24 LOG(ERROR) << "WindowManagerFactoryService already registered for " |
| 25 << user_id; |
| 26 return; |
| 27 } |
| 28 } |
| 29 |
| 30 scoped_ptr<WindowManagerFactoryService> service( |
| 31 new WindowManagerFactoryService(this, user_id, std::move(request))); |
| 32 services_.push_back(std::move(service)); |
| 33 } |
| 34 |
| 35 std::vector<WindowManagerFactoryService*> |
| 36 WindowManagerFactoryRegistry::GetServices() { |
| 37 std::vector<WindowManagerFactoryService*> result; |
| 38 for (auto& service_ptr : services_) |
| 39 result.push_back(service_ptr.get()); |
| 40 return result; |
| 41 } |
| 42 |
| 43 void WindowManagerFactoryRegistry::OnWindowManagerFactoryConnectionLost( |
| 44 WindowManagerFactoryService* service) { |
| 45 for (auto it = services_.begin(); it != services_.end(); ++it) { |
| 46 if (it->get() == service) { |
| 47 services_.erase(it); |
| 48 return; |
| 49 } |
| 50 } |
| 51 } |
| 52 |
| 53 void WindowManagerFactoryRegistry::OnWindowManagerFactorySet() { |
| 54 connection_manager_->OnWindowManagerFactorySet(); |
| 55 } |
| 56 |
| 57 } // namespace ws |
| 58 } // namespace mus |
| OLD | NEW |