OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 SERVICES_UI_SERVICE_H_ | 5 #ifndef SERVICES_UI_SERVICE_H_ |
6 #define SERVICES_UI_SERVICE_H_ | 6 #define SERVICES_UI_SERVICE_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <map> | 10 #include <map> |
11 #include <memory> | 11 #include <memory> |
12 #include <string> | 12 #include <string> |
13 #include <vector> | 13 #include <vector> |
14 | 14 |
15 #include "base/macros.h" | 15 #include "base/macros.h" |
| 16 #include "base/memory/ref_counted.h" |
| 17 #include "base/memory/weak_ptr.h" |
16 #include "components/discardable_memory/public/interfaces/discardable_shared_mem
ory_manager.mojom.h" | 18 #include "components/discardable_memory/public/interfaces/discardable_shared_mem
ory_manager.mojom.h" |
17 #include "services/service_manager/public/cpp/binder_registry.h" | 19 #include "services/service_manager/public/cpp/binder_registry.h" |
18 #include "services/service_manager/public/cpp/service.h" | 20 #include "services/service_manager/public/cpp/service.h" |
19 #include "services/service_manager/public/cpp/service_runner.h" | 21 #include "services/service_manager/public/cpp/service_runner.h" |
20 #include "services/ui/ime/ime_driver_bridge.h" | 22 #include "services/ui/ime/ime_driver_bridge.h" |
21 #include "services/ui/ime/ime_registrar_impl.h" | 23 #include "services/ui/ime/ime_registrar_impl.h" |
22 #include "services/ui/input_devices/input_device_server.h" | 24 #include "services/ui/input_devices/input_device_server.h" |
23 #include "services/ui/public/interfaces/accessibility_manager.mojom.h" | 25 #include "services/ui/public/interfaces/accessibility_manager.mojom.h" |
24 #include "services/ui/public/interfaces/clipboard.mojom.h" | 26 #include "services/ui/public/interfaces/clipboard.mojom.h" |
25 #include "services/ui/public/interfaces/display_manager.mojom.h" | 27 #include "services/ui/public/interfaces/display_manager.mojom.h" |
(...skipping 20 matching lines...) Expand all Loading... |
46 class ScreenManager; | 48 class ScreenManager; |
47 } | 49 } |
48 | 50 |
49 namespace service_manager { | 51 namespace service_manager { |
50 class Connector; | 52 class Connector; |
51 class Identity; | 53 class Identity; |
52 } | 54 } |
53 | 55 |
54 namespace ui { | 56 namespace ui { |
55 | 57 |
| 58 class ImageCursorsSet; |
56 class InputDeviceController; | 59 class InputDeviceController; |
57 class PlatformEventSource; | 60 class PlatformEventSource; |
58 | 61 |
59 namespace ws { | 62 namespace ws { |
| 63 class ThreadedImageCursorsFactory; |
60 class WindowServer; | 64 class WindowServer; |
61 } | 65 } |
62 | 66 |
63 class Service : public service_manager::Service, | 67 class Service : public service_manager::Service, |
64 public ws::WindowServerDelegate { | 68 public ws::WindowServerDelegate { |
65 public: | 69 public: |
66 Service(); | 70 // Contains the configuration necessary to run the UI Service inside the |
| 71 // Window Manager's process. |
| 72 struct InProcessConfig { |
| 73 InProcessConfig(); |
| 74 InProcessConfig(const InProcessConfig& config); |
| 75 ~InProcessConfig(); |
| 76 |
| 77 // Can be used to load resources. |
| 78 scoped_refptr<base::SingleThreadTaskRunner> resource_runner = nullptr; |
| 79 |
| 80 // Can only be de-referenced on |resource_runner_|. |
| 81 base::WeakPtr<ImageCursorsSet> image_cursors_set_weak_ptr = nullptr; |
| 82 }; |
| 83 |
| 84 // |config| should be null when UI Service runs in it's own separate process, |
| 85 // as opposed to inside the Window Manager's process. |
| 86 explicit Service(InProcessConfig* config); |
67 ~Service() override; | 87 ~Service() override; |
68 | 88 |
69 private: | 89 private: |
70 // Holds InterfaceRequests received before the first WindowTreeHost Display | 90 // Holds InterfaceRequests received before the first WindowTreeHost Display |
71 // has been established. | 91 // has been established. |
72 struct PendingRequest; | 92 struct PendingRequest; |
73 struct UserState; | 93 struct UserState; |
74 | 94 |
75 using UserIdToUserState = std::map<ws::UserId, std::unique_ptr<UserState>>; | 95 using UserIdToUserState = std::map<ws::UserId, std::unique_ptr<UserState>>; |
76 | 96 |
| 97 bool is_in_process() const { return is_in_process_; } |
| 98 |
77 // Attempts to initialize the resource bundle. Returns true if successful, | 99 // Attempts to initialize the resource bundle. Returns true if successful, |
78 // otherwise false if resources cannot be loaded. | 100 // otherwise false if resources cannot be loaded. |
79 bool InitializeResources(service_manager::Connector* connector); | 101 bool InitializeResources(service_manager::Connector* connector); |
80 | 102 |
81 // Returns the user specific state for the user id of |remote_identity|. | 103 // Returns the user specific state for the user id of |remote_identity|. |
82 // Service owns the return value. | 104 // Service owns the return value. |
83 // TODO(sky): if we allow removal of user ids then we need to close anything | 105 // TODO(sky): if we allow removal of user ids then we need to close anything |
84 // associated with the user (all incoming pipes...) on removal. | 106 // associated with the user (all incoming pipes...) on removal. |
85 UserState* GetUserState(const service_manager::Identity& remote_identity); | 107 UserState* GetUserState(const service_manager::Identity& remote_identity); |
86 | 108 |
87 void AddUserIfNecessary(const service_manager::Identity& remote_identity); | 109 void AddUserIfNecessary(const service_manager::Identity& remote_identity); |
88 | 110 |
89 // service_manager::Service: | 111 // service_manager::Service: |
90 void OnStart() override; | 112 void OnStart() override; |
91 void OnBindInterface(const service_manager::BindSourceInfo& source_info, | 113 void OnBindInterface(const service_manager::BindSourceInfo& source_info, |
92 const std::string& interface_name, | 114 const std::string& interface_name, |
93 mojo::ScopedMessagePipeHandle interface_pipe) override; | 115 mojo::ScopedMessagePipeHandle interface_pipe) override; |
94 | 116 |
95 // WindowServerDelegate: | 117 // WindowServerDelegate: |
96 void StartDisplayInit() override; | 118 void StartDisplayInit() override; |
97 void OnFirstDisplayReady() override; | 119 void OnFirstDisplayReady() override; |
98 void OnNoMoreDisplays() override; | 120 void OnNoMoreDisplays() override; |
99 bool IsTestConfig() const override; | 121 bool IsTestConfig() const override; |
100 void OnWillCreateTreeForWindowManager( | 122 void OnWillCreateTreeForWindowManager( |
101 bool automatically_create_display_roots) override; | 123 bool automatically_create_display_roots) override; |
| 124 ws::ThreadedImageCursorsFactory* GetThreadedImageCursorsFactory() override; |
102 | 125 |
103 void BindAccessibilityManagerRequest( | 126 void BindAccessibilityManagerRequest( |
104 const service_manager::BindSourceInfo& source_info, | 127 const service_manager::BindSourceInfo& source_info, |
105 mojom::AccessibilityManagerRequest request); | 128 mojom::AccessibilityManagerRequest request); |
106 | 129 |
107 void BindClipboardRequest(const service_manager::BindSourceInfo& source_info, | 130 void BindClipboardRequest(const service_manager::BindSourceInfo& source_info, |
108 mojom::ClipboardRequest request); | 131 mojom::ClipboardRequest request); |
109 | 132 |
110 void BindDisplayManagerRequest( | 133 void BindDisplayManagerRequest( |
111 const service_manager::BindSourceInfo& source_info, | 134 const service_manager::BindSourceInfo& source_info, |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 | 166 |
144 void BindDiscardableSharedMemoryManagerRequest( | 167 void BindDiscardableSharedMemoryManagerRequest( |
145 const service_manager::BindSourceInfo& source_info, | 168 const service_manager::BindSourceInfo& source_info, |
146 discardable_memory::mojom::DiscardableSharedMemoryManagerRequest request); | 169 discardable_memory::mojom::DiscardableSharedMemoryManagerRequest request); |
147 | 170 |
148 void BindWindowServerTestRequest( | 171 void BindWindowServerTestRequest( |
149 const service_manager::BindSourceInfo& source_info, | 172 const service_manager::BindSourceInfo& source_info, |
150 mojom::WindowServerTestRequest request); | 173 mojom::WindowServerTestRequest request); |
151 | 174 |
152 std::unique_ptr<ws::WindowServer> window_server_; | 175 std::unique_ptr<ws::WindowServer> window_server_; |
153 std::unique_ptr<ui::PlatformEventSource> event_source_; | 176 std::unique_ptr<PlatformEventSource> event_source_; |
154 using PendingRequests = std::vector<std::unique_ptr<PendingRequest>>; | 177 using PendingRequests = std::vector<std::unique_ptr<PendingRequest>>; |
155 PendingRequests pending_requests_; | 178 PendingRequests pending_requests_; |
156 | 179 |
157 UserIdToUserState user_id_to_user_state_; | 180 UserIdToUserState user_id_to_user_state_; |
158 | 181 |
159 // Provides input-device information via Mojo IPC. Registers Mojo interfaces | 182 // Provides input-device information via Mojo IPC. Registers Mojo interfaces |
160 // and must outlive |registry_|. | 183 // and must outlive |registry_|. |
161 InputDeviceServer input_device_server_; | 184 InputDeviceServer input_device_server_; |
162 | 185 |
| 186 // True if the UI Service runs inside WM's process, false if it runs inside |
| 187 // its own process. |
| 188 const bool is_in_process_; |
| 189 |
| 190 std::unique_ptr<ws::ThreadedImageCursorsFactory> |
| 191 threaded_image_cursors_factory_; |
| 192 |
163 bool test_config_; | 193 bool test_config_; |
164 #if defined(USE_OZONE) | 194 #if defined(USE_OZONE) |
165 std::unique_ptr<gfx::ClientNativePixmapFactory> client_native_pixmap_factory_; | 195 std::unique_ptr<gfx::ClientNativePixmapFactory> client_native_pixmap_factory_; |
166 #if defined(OS_CHROMEOS) | 196 #if defined(OS_CHROMEOS) |
167 std::unique_ptr<InputDeviceController> input_device_controller_; | 197 std::unique_ptr<InputDeviceController> input_device_controller_; |
168 #endif | 198 #endif |
169 #endif | 199 #endif |
170 | 200 |
171 // Manages display hardware and handles display management. May register Mojo | 201 // Manages display hardware and handles display management. May register Mojo |
172 // interfaces and must outlive |registry_|. | 202 // interfaces and must outlive |registry_|. |
173 std::unique_ptr<display::ScreenManager> screen_manager_; | 203 std::unique_ptr<display::ScreenManager> screen_manager_; |
174 | 204 |
175 IMERegistrarImpl ime_registrar_; | 205 IMERegistrarImpl ime_registrar_; |
176 IMEDriverBridge ime_driver_; | 206 IMEDriverBridge ime_driver_; |
177 | 207 |
178 std::unique_ptr<discardable_memory::DiscardableSharedMemoryManager> | 208 std::unique_ptr<discardable_memory::DiscardableSharedMemoryManager> |
179 discardable_shared_memory_manager_; | 209 discardable_shared_memory_manager_; |
180 | 210 |
181 service_manager::BinderRegistry registry_; | 211 service_manager::BinderRegistry registry_; |
182 | 212 |
183 // Set to true in StartDisplayInit(). | 213 // Set to true in StartDisplayInit(). |
184 bool is_gpu_ready_ = false; | 214 bool is_gpu_ready_ = false; |
185 | 215 |
186 DISALLOW_COPY_AND_ASSIGN(Service); | 216 DISALLOW_COPY_AND_ASSIGN(Service); |
187 }; | 217 }; |
188 | 218 |
189 } // namespace ui | 219 } // namespace ui |
190 | 220 |
191 #endif // SERVICES_UI_SERVICE_H_ | 221 #endif // SERVICES_UI_SERVICE_H_ |
OLD | NEW |