| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef COMPONENTS_MUS_WS_WINDOW_MANAGER_FACTORY_REGISTRY_H_ | 5 #ifndef COMPONENTS_MUS_WS_WINDOW_MANAGER_FACTORY_REGISTRY_H_ |
| 6 #define COMPONENTS_MUS_WS_WINDOW_MANAGER_FACTORY_REGISTRY_H_ | 6 #define COMPONENTS_MUS_WS_WINDOW_MANAGER_FACTORY_REGISTRY_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "base/macros.h" | 12 #include "base/macros.h" |
| 13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
| 14 #include "base/observer_list.h" |
| 14 #include "components/mus/public/interfaces/window_manager_factory.mojom.h" | 15 #include "components/mus/public/interfaces/window_manager_factory.mojom.h" |
| 16 #include "components/mus/ws/user_id_tracker_observer.h" |
| 15 | 17 |
| 16 namespace mus { | 18 namespace mus { |
| 17 namespace ws { | 19 namespace ws { |
| 18 | 20 |
| 19 class ConnectionManager; | 21 class ConnectionManager; |
| 22 class UserIdTracker; |
| 23 class WindowManagerFactoryRegistryObserver; |
| 20 class WindowManagerFactoryService; | 24 class WindowManagerFactoryService; |
| 21 | 25 |
| 26 namespace test { |
| 27 class WindowManagerFactoryRegistryTestApi; |
| 28 } |
| 29 |
| 22 // WindowManagerFactoryRegistry tracks the set of registered | 30 // WindowManagerFactoryRegistry tracks the set of registered |
| 23 // WindowManagerFactoryServices. | 31 // WindowManagerFactoryServices. |
| 24 class WindowManagerFactoryRegistry { | 32 class WindowManagerFactoryRegistry : public UserIdTrackerObserver { |
| 25 public: | 33 public: |
| 26 explicit WindowManagerFactoryRegistry(ConnectionManager* connection_manager); | 34 explicit WindowManagerFactoryRegistry(ConnectionManager* connection_manager, |
| 27 ~WindowManagerFactoryRegistry(); | 35 UserIdTracker* tracker); |
| 36 ~WindowManagerFactoryRegistry() override; |
| 28 | 37 |
| 29 void Register( | 38 void Register( |
| 30 uint32_t user_id, | 39 UserId user_id, |
| 31 mojo::InterfaceRequest<mojom::WindowManagerFactoryService> request); | 40 mojo::InterfaceRequest<mojom::WindowManagerFactoryService> request); |
| 32 | 41 |
| 33 std::vector<WindowManagerFactoryService*> GetServices(); | 42 std::vector<WindowManagerFactoryService*> GetServices(); |
| 34 | 43 |
| 44 void AddObserver(WindowManagerFactoryRegistryObserver* observer); |
| 45 void RemoveObserver(WindowManagerFactoryRegistryObserver* observer); |
| 46 |
| 35 private: | 47 private: |
| 36 friend class WindowManagerFactoryService; | 48 friend class WindowManagerFactoryService; |
| 49 friend class test::WindowManagerFactoryRegistryTestApi; |
| 37 | 50 |
| 51 void AddServiceImpl(scoped_ptr<WindowManagerFactoryService> service); |
| 52 |
| 53 bool ContainsServiceForUser(UserId user_id) const; |
| 38 void OnWindowManagerFactoryConnectionLost( | 54 void OnWindowManagerFactoryConnectionLost( |
| 39 WindowManagerFactoryService* service); | 55 WindowManagerFactoryService* service); |
| 40 void OnWindowManagerFactorySet(); | 56 void OnWindowManagerFactorySet(WindowManagerFactoryService* service); |
| 41 | 57 |
| 58 // UserIdTrackerObserver: |
| 59 void OnActiveUserIdChanged(UserId id) override; |
| 60 void OnUserIdAdded(UserId id) override; |
| 61 void OnUserIdRemoved(UserId id) override; |
| 62 |
| 63 // Set to true the first time a valid factory has been found. |
| 64 bool got_valid_factory_ = false; |
| 65 UserIdTracker* id_tracker_; |
| 42 ConnectionManager* connection_manager_; | 66 ConnectionManager* connection_manager_; |
| 43 | 67 |
| 44 std::vector<scoped_ptr<WindowManagerFactoryService>> services_; | 68 std::vector<scoped_ptr<WindowManagerFactoryService>> services_; |
| 45 | 69 |
| 70 base::ObserverList<WindowManagerFactoryRegistryObserver> observers_; |
| 71 |
| 46 DISALLOW_COPY_AND_ASSIGN(WindowManagerFactoryRegistry); | 72 DISALLOW_COPY_AND_ASSIGN(WindowManagerFactoryRegistry); |
| 47 }; | 73 }; |
| 48 | 74 |
| 49 } // namespace ws | 75 } // namespace ws |
| 50 } // namespace mus | 76 } // namespace mus |
| 51 | 77 |
| 52 #endif // COMPONENTS_MUS_WS_WINDOW_MANAGER_FACTORY_REGISTRY_H_ | 78 #endif // COMPONENTS_MUS_WS_WINDOW_MANAGER_FACTORY_REGISTRY_H_ |
| OLD | NEW |