Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: services/ui/service.h

Issue 2979933002: Add support to the UI Service to run it inside the browser's process. (Closed)
Patch Set: Addressing review feedback Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « services/ui/main.cc ('k') | services/ui/service.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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();
75
76 // Can be used to load resources.
77 scoped_refptr<base::SingleThreadTaskRunner> resource_runner = nullptr;
78
79 // Can only be de-referenced on |resource_runner_|.
80 base::WeakPtr<ImageCursorsSet> image_cursors_set_weak_ptr = nullptr;
81
82 private:
83 DISALLOW_COPY_AND_ASSIGN(InProcessConfig);
84 };
85
86 // |config| should be null when UI Service runs in it's own separate process,
87 // as opposed to inside the Window Manager's process.
88 explicit Service(const InProcessConfig* config = nullptr);
67 ~Service() override; 89 ~Service() override;
68 90
69 private: 91 private:
70 // Holds InterfaceRequests received before the first WindowTreeHost Display 92 // Holds InterfaceRequests received before the first WindowTreeHost Display
71 // has been established. 93 // has been established.
72 struct PendingRequest; 94 struct PendingRequest;
73 struct UserState; 95 struct UserState;
74 96
75 using UserIdToUserState = std::map<ws::UserId, std::unique_ptr<UserState>>; 97 using UserIdToUserState = std::map<ws::UserId, std::unique_ptr<UserState>>;
76 98
99 bool is_in_process() const { return is_in_process_; }
100
77 // Attempts to initialize the resource bundle. Returns true if successful, 101 // Attempts to initialize the resource bundle. Returns true if successful,
78 // otherwise false if resources cannot be loaded. 102 // otherwise false if resources cannot be loaded.
79 bool InitializeResources(service_manager::Connector* connector); 103 bool InitializeResources(service_manager::Connector* connector);
80 104
81 // Returns the user specific state for the user id of |remote_identity|. 105 // Returns the user specific state for the user id of |remote_identity|.
82 // Service owns the return value. 106 // Service owns the return value.
83 // TODO(sky): if we allow removal of user ids then we need to close anything 107 // 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. 108 // associated with the user (all incoming pipes...) on removal.
85 UserState* GetUserState(const service_manager::Identity& remote_identity); 109 UserState* GetUserState(const service_manager::Identity& remote_identity);
86 110
87 void AddUserIfNecessary(const service_manager::Identity& remote_identity); 111 void AddUserIfNecessary(const service_manager::Identity& remote_identity);
88 112
89 // service_manager::Service: 113 // service_manager::Service:
90 void OnStart() override; 114 void OnStart() override;
91 void OnBindInterface(const service_manager::BindSourceInfo& source_info, 115 void OnBindInterface(const service_manager::BindSourceInfo& source_info,
92 const std::string& interface_name, 116 const std::string& interface_name,
93 mojo::ScopedMessagePipeHandle interface_pipe) override; 117 mojo::ScopedMessagePipeHandle interface_pipe) override;
94 118
95 // WindowServerDelegate: 119 // WindowServerDelegate:
96 void StartDisplayInit() override; 120 void StartDisplayInit() override;
97 void OnFirstDisplayReady() override; 121 void OnFirstDisplayReady() override;
98 void OnNoMoreDisplays() override; 122 void OnNoMoreDisplays() override;
99 bool IsTestConfig() const override; 123 bool IsTestConfig() const override;
100 void OnWillCreateTreeForWindowManager( 124 void OnWillCreateTreeForWindowManager(
101 bool automatically_create_display_roots) override; 125 bool automatically_create_display_roots) override;
126 ws::ThreadedImageCursorsFactory* GetThreadedImageCursorsFactory() override;
102 127
103 void BindAccessibilityManagerRequest( 128 void BindAccessibilityManagerRequest(
104 const service_manager::BindSourceInfo& source_info, 129 const service_manager::BindSourceInfo& source_info,
105 mojom::AccessibilityManagerRequest request); 130 mojom::AccessibilityManagerRequest request);
106 131
107 void BindClipboardRequest(const service_manager::BindSourceInfo& source_info, 132 void BindClipboardRequest(const service_manager::BindSourceInfo& source_info,
108 mojom::ClipboardRequest request); 133 mojom::ClipboardRequest request);
109 134
110 void BindDisplayManagerRequest( 135 void BindDisplayManagerRequest(
111 const service_manager::BindSourceInfo& source_info, 136 const service_manager::BindSourceInfo& source_info,
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 168
144 void BindDiscardableSharedMemoryManagerRequest( 169 void BindDiscardableSharedMemoryManagerRequest(
145 const service_manager::BindSourceInfo& source_info, 170 const service_manager::BindSourceInfo& source_info,
146 discardable_memory::mojom::DiscardableSharedMemoryManagerRequest request); 171 discardable_memory::mojom::DiscardableSharedMemoryManagerRequest request);
147 172
148 void BindWindowServerTestRequest( 173 void BindWindowServerTestRequest(
149 const service_manager::BindSourceInfo& source_info, 174 const service_manager::BindSourceInfo& source_info,
150 mojom::WindowServerTestRequest request); 175 mojom::WindowServerTestRequest request);
151 176
152 std::unique_ptr<ws::WindowServer> window_server_; 177 std::unique_ptr<ws::WindowServer> window_server_;
153 std::unique_ptr<ui::PlatformEventSource> event_source_; 178 std::unique_ptr<PlatformEventSource> event_source_;
154 using PendingRequests = std::vector<std::unique_ptr<PendingRequest>>; 179 using PendingRequests = std::vector<std::unique_ptr<PendingRequest>>;
155 PendingRequests pending_requests_; 180 PendingRequests pending_requests_;
156 181
157 UserIdToUserState user_id_to_user_state_; 182 UserIdToUserState user_id_to_user_state_;
158 183
159 // Provides input-device information via Mojo IPC. Registers Mojo interfaces 184 // Provides input-device information via Mojo IPC. Registers Mojo interfaces
160 // and must outlive |registry_|. 185 // and must outlive |registry_|.
161 InputDeviceServer input_device_server_; 186 InputDeviceServer input_device_server_;
162 187
188 // True if the UI Service runs inside WM's process, false if it runs inside
189 // its own process.
190 const bool is_in_process_;
191
192 std::unique_ptr<ws::ThreadedImageCursorsFactory>
193 threaded_image_cursors_factory_;
194
163 bool test_config_; 195 bool test_config_;
164 #if defined(USE_OZONE) 196 #if defined(USE_OZONE)
165 std::unique_ptr<gfx::ClientNativePixmapFactory> client_native_pixmap_factory_; 197 std::unique_ptr<gfx::ClientNativePixmapFactory> client_native_pixmap_factory_;
166 #if defined(OS_CHROMEOS) 198 #if defined(OS_CHROMEOS)
167 std::unique_ptr<InputDeviceController> input_device_controller_; 199 std::unique_ptr<InputDeviceController> input_device_controller_;
168 #endif 200 #endif
169 #endif 201 #endif
170 202
171 // Manages display hardware and handles display management. May register Mojo 203 // Manages display hardware and handles display management. May register Mojo
172 // interfaces and must outlive |registry_|. 204 // interfaces and must outlive |registry_|.
173 std::unique_ptr<display::ScreenManager> screen_manager_; 205 std::unique_ptr<display::ScreenManager> screen_manager_;
174 206
175 IMERegistrarImpl ime_registrar_; 207 IMERegistrarImpl ime_registrar_;
176 IMEDriverBridge ime_driver_; 208 IMEDriverBridge ime_driver_;
177 209
178 std::unique_ptr<discardable_memory::DiscardableSharedMemoryManager> 210 std::unique_ptr<discardable_memory::DiscardableSharedMemoryManager>
179 discardable_shared_memory_manager_; 211 discardable_shared_memory_manager_;
180 212
181 service_manager::BinderRegistry registry_; 213 service_manager::BinderRegistry registry_;
182 214
183 // Set to true in StartDisplayInit(). 215 // Set to true in StartDisplayInit().
184 bool is_gpu_ready_ = false; 216 bool is_gpu_ready_ = false;
185 217
186 DISALLOW_COPY_AND_ASSIGN(Service); 218 DISALLOW_COPY_AND_ASSIGN(Service);
187 }; 219 };
188 220
189 } // namespace ui 221 } // namespace ui
190 222
191 #endif // SERVICES_UI_SERVICE_H_ 223 #endif // SERVICES_UI_SERVICE_H_
OLDNEW
« no previous file with comments | « services/ui/main.cc ('k') | services/ui/service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698