Chromium Code Reviews| 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> |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 46 class ScreenManager; | 46 class ScreenManager; |
| 47 } | 47 } |
| 48 | 48 |
| 49 namespace service_manager { | 49 namespace service_manager { |
| 50 class Connector; | 50 class Connector; |
| 51 class Identity; | 51 class Identity; |
| 52 } | 52 } |
| 53 | 53 |
| 54 namespace ui { | 54 namespace ui { |
| 55 | 55 |
| 56 class ImageCursors; | |
| 56 class InputDeviceController; | 57 class InputDeviceController; |
| 57 class PlatformEventSource; | 58 class PlatformEventSource; |
| 58 | 59 |
| 59 namespace ws { | 60 namespace ws { |
| 60 class WindowServer; | 61 class WindowServer; |
| 61 } | 62 } |
| 62 | 63 |
| 63 class Service : public service_manager::Service, | 64 class Service : public service_manager::Service, |
| 64 public ws::WindowServerDelegate { | 65 public ws::WindowServerDelegate { |
| 65 public: | 66 public: |
| 66 Service(); | 67 // |resource_runner| is the task runner for the thread which can be used to |
| 68 // load resources. Used when UI Service run inside a Window Manager's | |
| 69 // process (and so the resources need to be loaded on the WM's thread). | |
| 70 // When UI Service is run in a separate process, |resource_runner| | |
| 71 // should be null, and resources are loaded on the UI Service's thread. | |
| 72 // |image_cursors_weak_ptr| is also only used when the UI service runs | |
| 73 // in-process. It can only be dereferenced on |resource_runner|. | |
| 74 Service(scoped_refptr<base::SingleThreadTaskRunner> resource_runner, | |
|
sky
2017/06/27 19:58:56
optional: Create a structure named InProcessConfig
mfomitchev
2017/07/11 21:47:00
Done.
| |
| 75 base::WeakPtr<ui::ImageCursors> image_cursors_weak_ptr); | |
| 67 ~Service() override; | 76 ~Service() override; |
| 68 | 77 |
| 69 private: | 78 private: |
| 70 // Holds InterfaceRequests received before the first WindowTreeHost Display | 79 // Holds InterfaceRequests received before the first WindowTreeHost Display |
| 71 // has been established. | 80 // has been established. |
| 72 struct PendingRequest; | 81 struct PendingRequest; |
| 73 struct UserState; | 82 struct UserState; |
| 74 | 83 |
| 75 using UserIdToUserState = std::map<ws::UserId, std::unique_ptr<UserState>>; | 84 using UserIdToUserState = std::map<ws::UserId, std::unique_ptr<UserState>>; |
| 76 | 85 |
| 86 bool in_process() { return in_process_; } | |
|
sky
2017/06/27 19:58:56
bool in_process() const
optional: prefix member an
mfomitchev
2017/07/11 21:46:59
Done.
| |
| 87 | |
| 77 // Attempts to initialize the resource bundle. Returns true if successful, | 88 // Attempts to initialize the resource bundle. Returns true if successful, |
| 78 // otherwise false if resources cannot be loaded. | 89 // otherwise false if resources cannot be loaded. |
| 79 bool InitializeResources(service_manager::Connector* connector); | 90 bool InitializeResources(service_manager::Connector* connector); |
| 80 | 91 |
| 81 // Returns the user specific state for the user id of |remote_identity|. | 92 // Returns the user specific state for the user id of |remote_identity|. |
| 82 // Service owns the return value. | 93 // Service owns the return value. |
| 83 // TODO(sky): if we allow removal of user ids then we need to close anything | 94 // 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. | 95 // associated with the user (all incoming pipes...) on removal. |
| 85 UserState* GetUserState(const service_manager::Identity& remote_identity); | 96 UserState* GetUserState(const service_manager::Identity& remote_identity); |
| 86 | 97 |
| 87 void AddUserIfNecessary(const service_manager::Identity& remote_identity); | 98 void AddUserIfNecessary(const service_manager::Identity& remote_identity); |
| 88 | 99 |
| 89 // service_manager::Service: | 100 // service_manager::Service: |
| 90 void OnStart() override; | 101 void OnStart() override; |
| 91 void OnBindInterface(const service_manager::BindSourceInfo& source_info, | 102 void OnBindInterface(const service_manager::BindSourceInfo& source_info, |
| 92 const std::string& interface_name, | 103 const std::string& interface_name, |
| 93 mojo::ScopedMessagePipeHandle interface_pipe) override; | 104 mojo::ScopedMessagePipeHandle interface_pipe) override; |
| 94 | 105 |
| 95 // WindowServerDelegate: | 106 // WindowServerDelegate: |
| 96 void StartDisplayInit() override; | 107 void StartDisplayInit() override; |
| 97 void OnFirstDisplayReady() override; | 108 void OnFirstDisplayReady() override; |
| 98 void OnNoMoreDisplays() override; | 109 void OnNoMoreDisplays() override; |
| 99 bool IsTestConfig() const override; | 110 bool IsTestConfig() const override; |
| 100 void OnWillCreateTreeForWindowManager( | 111 void OnWillCreateTreeForWindowManager( |
| 101 bool automatically_create_display_roots) override; | 112 bool automatically_create_display_roots) override; |
| 113 scoped_refptr<base::SingleThreadTaskRunner>& GetResourceRunner() override; | |
| 114 base::WeakPtr<ui::ImageCursors> GetImageCursorsWeakPtr() override; | |
| 102 | 115 |
| 103 void BindAccessibilityManagerRequest( | 116 void BindAccessibilityManagerRequest( |
| 104 const service_manager::BindSourceInfo& source_info, | 117 const service_manager::BindSourceInfo& source_info, |
| 105 mojom::AccessibilityManagerRequest request); | 118 mojom::AccessibilityManagerRequest request); |
| 106 | 119 |
| 107 void BindClipboardRequest(const service_manager::BindSourceInfo& source_info, | 120 void BindClipboardRequest(const service_manager::BindSourceInfo& source_info, |
| 108 mojom::ClipboardRequest request); | 121 mojom::ClipboardRequest request); |
| 109 | 122 |
| 110 void BindDisplayManagerRequest( | 123 void BindDisplayManagerRequest( |
| 111 const service_manager::BindSourceInfo& source_info, | 124 const service_manager::BindSourceInfo& source_info, |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 153 std::unique_ptr<ui::PlatformEventSource> event_source_; | 166 std::unique_ptr<ui::PlatformEventSource> event_source_; |
| 154 using PendingRequests = std::vector<std::unique_ptr<PendingRequest>>; | 167 using PendingRequests = std::vector<std::unique_ptr<PendingRequest>>; |
| 155 PendingRequests pending_requests_; | 168 PendingRequests pending_requests_; |
| 156 | 169 |
| 157 UserIdToUserState user_id_to_user_state_; | 170 UserIdToUserState user_id_to_user_state_; |
| 158 | 171 |
| 159 // Provides input-device information via Mojo IPC. Registers Mojo interfaces | 172 // Provides input-device information via Mojo IPC. Registers Mojo interfaces |
| 160 // and must outlive |registry_|. | 173 // and must outlive |registry_|. |
| 161 InputDeviceServer input_device_server_; | 174 InputDeviceServer input_device_server_; |
| 162 | 175 |
| 176 // True if the UI Service runs inside WM's process, false if it runs inside | |
| 177 // its own process. | |
| 178 bool in_process_; | |
| 179 | |
| 180 // Can be used to access resources. Will be null until the service is started | |
|
sky
2017/06/27 19:58:56
Please group in-process related state into a struc
mfomitchev
2017/07/11 21:47:00
Created ThreadedImageCursorsFactory(Impl). I think
| |
| 181 // if the UI Service doesn't run in WM's process. | |
| 182 scoped_refptr<base::SingleThreadTaskRunner> resource_runner_; | |
| 183 | |
| 184 // Used when UI Service runs in-process, and can only be de-referenced on | |
| 185 // |resource_runner_|. When UI Service doesn't run in-process, this points to | |
| 186 // |image_cursors_| (and should be de-referenced on UI Serivice's thread). | |
| 187 base::WeakPtr<ui::ImageCursors> image_cursors_weak_ptr_; | |
| 188 | |
| 189 // Used when UI Service doesn't run in-process. | |
| 190 std::unique_ptr<ui::ImageCursors> image_cursors_; | |
| 191 | |
| 163 bool test_config_; | 192 bool test_config_; |
| 164 #if defined(USE_OZONE) | 193 #if defined(USE_OZONE) |
| 165 std::unique_ptr<gfx::ClientNativePixmapFactory> client_native_pixmap_factory_; | 194 std::unique_ptr<gfx::ClientNativePixmapFactory> client_native_pixmap_factory_; |
| 166 #if defined(OS_CHROMEOS) | 195 #if defined(OS_CHROMEOS) |
| 167 std::unique_ptr<InputDeviceController> input_device_controller_; | 196 std::unique_ptr<InputDeviceController> input_device_controller_; |
| 168 #endif | 197 #endif |
| 169 #endif | 198 #endif |
| 170 | 199 |
| 171 // Manages display hardware and handles display management. May register Mojo | 200 // Manages display hardware and handles display management. May register Mojo |
| 172 // interfaces and must outlive |registry_|. | 201 // interfaces and must outlive |registry_|. |
| 173 std::unique_ptr<display::ScreenManager> screen_manager_; | 202 std::unique_ptr<display::ScreenManager> screen_manager_; |
| 174 | 203 |
| 175 IMERegistrarImpl ime_registrar_; | 204 IMERegistrarImpl ime_registrar_; |
| 176 IMEDriverBridge ime_driver_; | 205 IMEDriverBridge ime_driver_; |
| 177 | 206 |
| 178 std::unique_ptr<discardable_memory::DiscardableSharedMemoryManager> | 207 std::unique_ptr<discardable_memory::DiscardableSharedMemoryManager> |
| 179 discardable_shared_memory_manager_; | 208 discardable_shared_memory_manager_; |
| 180 | 209 |
| 181 service_manager::BinderRegistry registry_; | 210 service_manager::BinderRegistry registry_; |
| 182 | 211 |
| 183 // Set to true in StartDisplayInit(). | 212 // Set to true in StartDisplayInit(). |
| 184 bool is_gpu_ready_ = false; | 213 bool is_gpu_ready_ = false; |
| 185 | 214 |
| 186 DISALLOW_COPY_AND_ASSIGN(Service); | 215 DISALLOW_COPY_AND_ASSIGN(Service); |
| 187 }; | 216 }; |
| 188 | 217 |
| 189 } // namespace ui | 218 } // namespace ui |
| 190 | 219 |
| 191 #endif // SERVICES_UI_SERVICE_H_ | 220 #endif // SERVICES_UI_SERVICE_H_ |
| OLD | NEW |