OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #include "chromeos/dbus/dbus_thread_manager.h" | 5 #include "chromeos/dbus/dbus_thread_manager.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
11 #include "base/sys_info.h" | 11 #include "base/sys_info.h" |
12 #include "base/threading/thread.h" | 12 #include "base/threading/thread.h" |
13 #include "chromeos/chromeos_switches.h" | 13 #include "chromeos/chromeos_switches.h" |
14 #include "chromeos/dbus/arc_obb_mounter_client.h" | 14 #include "chromeos/dbus/arc_obb_mounter_client.h" |
15 #include "chromeos/dbus/cras_audio_client.h" | 15 #include "chromeos/dbus/cras_audio_client.h" |
16 #include "chromeos/dbus/cros_disks_client.h" | 16 #include "chromeos/dbus/cros_disks_client.h" |
17 #include "chromeos/dbus/cryptohome_client.h" | 17 #include "chromeos/dbus/cryptohome_client.h" |
18 #include "chromeos/dbus/dbus_client.h" | 18 #include "chromeos/dbus/dbus_client.h" |
19 #include "chromeos/dbus/dbus_client_bundle.h" | 19 #include "chromeos/dbus/dbus_clients_ash.h" |
| 20 #include "chromeos/dbus/dbus_clients_browser.h" |
| 21 #include "chromeos/dbus/dbus_clients_common.h" |
20 #include "chromeos/dbus/debug_daemon_client.h" | 22 #include "chromeos/dbus/debug_daemon_client.h" |
21 #include "chromeos/dbus/easy_unlock_client.h" | 23 #include "chromeos/dbus/easy_unlock_client.h" |
22 #include "chromeos/dbus/gsm_sms_client.h" | 24 #include "chromeos/dbus/gsm_sms_client.h" |
23 #include "chromeos/dbus/image_burner_client.h" | 25 #include "chromeos/dbus/image_burner_client.h" |
24 #include "chromeos/dbus/lorgnette_manager_client.h" | 26 #include "chromeos/dbus/lorgnette_manager_client.h" |
25 #include "chromeos/dbus/modem_messaging_client.h" | 27 #include "chromeos/dbus/modem_messaging_client.h" |
26 #include "chromeos/dbus/permission_broker_client.h" | 28 #include "chromeos/dbus/permission_broker_client.h" |
27 #include "chromeos/dbus/power_manager_client.h" | 29 #include "chromeos/dbus/power_manager_client.h" |
28 #include "chromeos/dbus/session_manager_client.h" | 30 #include "chromeos/dbus/session_manager_client.h" |
29 #include "chromeos/dbus/shill_device_client.h" | 31 #include "chromeos/dbus/shill_device_client.h" |
30 #include "chromeos/dbus/shill_ipconfig_client.h" | 32 #include "chromeos/dbus/shill_ipconfig_client.h" |
31 #include "chromeos/dbus/shill_manager_client.h" | 33 #include "chromeos/dbus/shill_manager_client.h" |
32 #include "chromeos/dbus/shill_profile_client.h" | 34 #include "chromeos/dbus/shill_profile_client.h" |
33 #include "chromeos/dbus/shill_service_client.h" | 35 #include "chromeos/dbus/shill_service_client.h" |
34 #include "chromeos/dbus/shill_third_party_vpn_driver_client.h" | 36 #include "chromeos/dbus/shill_third_party_vpn_driver_client.h" |
35 #include "chromeos/dbus/sms_client.h" | 37 #include "chromeos/dbus/sms_client.h" |
36 #include "chromeos/dbus/system_clock_client.h" | 38 #include "chromeos/dbus/system_clock_client.h" |
37 #include "chromeos/dbus/update_engine_client.h" | 39 #include "chromeos/dbus/update_engine_client.h" |
38 #include "dbus/bus.h" | 40 #include "dbus/bus.h" |
39 #include "dbus/dbus_statistics.h" | 41 #include "dbus/dbus_statistics.h" |
40 | 42 |
41 namespace chromeos { | 43 namespace chromeos { |
42 | 44 |
43 static DBusThreadManager* g_dbus_thread_manager = NULL; | 45 static DBusThreadManager* g_dbus_thread_manager = NULL; |
44 static bool g_using_dbus_thread_manager_for_testing = false; | 46 static bool g_using_dbus_thread_manager_for_testing = false; |
45 | 47 |
46 DBusThreadManager::DBusThreadManager( | 48 DBusThreadManager::DBusThreadManager(ProcessMask process_mask, |
47 std::unique_ptr<DBusClientBundle> client_bundle) | 49 DBusClientTypeMask real_client_mask) |
48 : client_bundle_(std::move(client_bundle)) { | 50 : clients_common_(new DBusClientsCommon(real_client_mask)) { |
| 51 if (process_mask & PROCESS_BROWSER) |
| 52 clients_browser_.reset(new DBusClientsBrowser(real_client_mask)); |
| 53 if (process_mask & PROCESS_ASH) |
| 54 clients_ash_.reset(new DBusClientsAsh(real_client_mask)); |
| 55 |
49 dbus::statistics::Initialize(); | 56 dbus::statistics::Initialize(); |
50 | 57 |
51 if (client_bundle_->IsUsingAnyRealClient()) { | 58 if (real_client_mask != 0) { |
52 // At least one real DBusClient is used. | 59 // At least one real DBusClient is used. |
53 // Create the D-Bus thread. | 60 // Create the D-Bus thread. |
54 base::Thread::Options thread_options; | 61 base::Thread::Options thread_options; |
55 thread_options.message_loop_type = base::MessageLoop::TYPE_IO; | 62 thread_options.message_loop_type = base::MessageLoop::TYPE_IO; |
56 dbus_thread_.reset(new base::Thread("D-Bus thread")); | 63 dbus_thread_.reset(new base::Thread("D-Bus thread")); |
57 dbus_thread_->StartWithOptions(thread_options); | 64 dbus_thread_->StartWithOptions(thread_options); |
58 | 65 |
59 // Create the connection to the system bus. | 66 // Create the connection to the system bus. |
60 dbus::Bus::Options system_bus_options; | 67 dbus::Bus::Options system_bus_options; |
61 system_bus_options.bus_type = dbus::Bus::SYSTEM; | 68 system_bus_options.bus_type = dbus::Bus::SYSTEM; |
62 system_bus_options.connection_type = dbus::Bus::PRIVATE; | 69 system_bus_options.connection_type = dbus::Bus::PRIVATE; |
63 system_bus_options.dbus_task_runner = dbus_thread_->task_runner(); | 70 system_bus_options.dbus_task_runner = dbus_thread_->task_runner(); |
64 system_bus_ = new dbus::Bus(system_bus_options); | 71 system_bus_ = new dbus::Bus(system_bus_options); |
65 } | 72 } |
66 } | 73 } |
67 | 74 |
68 DBusThreadManager::~DBusThreadManager() { | 75 DBusThreadManager::~DBusThreadManager() { |
69 // Delete all D-Bus clients before shutting down the system bus. | 76 // Delete all D-Bus clients before shutting down the system bus. |
70 client_bundle_.reset(); | 77 clients_ash_.reset(); |
| 78 clients_browser_.reset(); |
| 79 clients_common_.reset(); |
71 | 80 |
72 // Shut down the bus. During the browser shutdown, it's ok to shut down | 81 // Shut down the bus. During the browser shutdown, it's ok to shut down |
73 // the bus synchronously. | 82 // the bus synchronously. |
74 if (system_bus_.get()) | 83 if (system_bus_.get()) |
75 system_bus_->ShutdownOnDBusThreadAndBlock(); | 84 system_bus_->ShutdownOnDBusThreadAndBlock(); |
76 | 85 |
77 // Stop the D-Bus thread. | 86 // Stop the D-Bus thread. |
78 if (dbus_thread_) | 87 if (dbus_thread_) |
79 dbus_thread_->Stop(); | 88 dbus_thread_->Stop(); |
80 | 89 |
(...skipping 11 matching lines...) Expand all Loading... |
92 } else { | 101 } else { |
93 LOG(FATAL) << "~DBusThreadManager() called outside of Shutdown()"; | 102 LOG(FATAL) << "~DBusThreadManager() called outside of Shutdown()"; |
94 } | 103 } |
95 } | 104 } |
96 | 105 |
97 dbus::Bus* DBusThreadManager::GetSystemBus() { | 106 dbus::Bus* DBusThreadManager::GetSystemBus() { |
98 return system_bus_.get(); | 107 return system_bus_.get(); |
99 } | 108 } |
100 | 109 |
101 ArcObbMounterClient* DBusThreadManager::GetArcObbMounterClient() { | 110 ArcObbMounterClient* DBusThreadManager::GetArcObbMounterClient() { |
102 return client_bundle_->arc_obb_mounter_client(); | 111 return clients_browser_ ? clients_browser_->arc_obb_mounter_client_.get() |
| 112 : nullptr; |
103 } | 113 } |
104 | 114 |
105 CrasAudioClient* DBusThreadManager::GetCrasAudioClient() { | 115 CrasAudioClient* DBusThreadManager::GetCrasAudioClient() { |
106 return client_bundle_->cras_audio_client(); | 116 return clients_common_->cras_audio_client_.get(); |
107 } | 117 } |
108 | 118 |
109 CrosDisksClient* DBusThreadManager::GetCrosDisksClient() { | 119 CrosDisksClient* DBusThreadManager::GetCrosDisksClient() { |
110 return client_bundle_->cros_disks_client(); | 120 return clients_browser_ ? clients_browser_->cros_disks_client_.get() |
| 121 : nullptr; |
111 } | 122 } |
112 | 123 |
113 CryptohomeClient* DBusThreadManager::GetCryptohomeClient() { | 124 CryptohomeClient* DBusThreadManager::GetCryptohomeClient() { |
114 return client_bundle_->cryptohome_client(); | 125 return clients_common_->cryptohome_client_.get(); |
115 } | 126 } |
116 | 127 |
117 DebugDaemonClient* DBusThreadManager::GetDebugDaemonClient() { | 128 DebugDaemonClient* DBusThreadManager::GetDebugDaemonClient() { |
118 return client_bundle_->debug_daemon_client(); | 129 return clients_browser_ ? clients_browser_->debug_daemon_client_.get() |
| 130 : nullptr; |
119 } | 131 } |
120 | 132 |
121 EasyUnlockClient* DBusThreadManager::GetEasyUnlockClient() { | 133 EasyUnlockClient* DBusThreadManager::GetEasyUnlockClient() { |
122 return client_bundle_->easy_unlock_client(); | 134 return clients_browser_ ? clients_browser_->easy_unlock_client_.get() |
| 135 : nullptr; |
123 } | 136 } |
124 | 137 |
125 LorgnetteManagerClient* | 138 LorgnetteManagerClient* DBusThreadManager::GetLorgnetteManagerClient() { |
126 DBusThreadManager::GetLorgnetteManagerClient() { | 139 return clients_browser_ ? clients_browser_->lorgnette_manager_client_.get() |
127 return client_bundle_->lorgnette_manager_client(); | 140 : nullptr; |
128 } | 141 } |
129 | 142 |
130 ShillDeviceClient* | 143 ShillDeviceClient* DBusThreadManager::GetShillDeviceClient() { |
131 DBusThreadManager::GetShillDeviceClient() { | 144 return clients_common_->shill_device_client_.get(); |
132 return client_bundle_->shill_device_client(); | |
133 } | 145 } |
134 | 146 |
135 ShillIPConfigClient* | 147 ShillIPConfigClient* DBusThreadManager::GetShillIPConfigClient() { |
136 DBusThreadManager::GetShillIPConfigClient() { | 148 return clients_common_->shill_ipconfig_client_.get(); |
137 return client_bundle_->shill_ipconfig_client(); | |
138 } | 149 } |
139 | 150 |
140 ShillManagerClient* | 151 ShillManagerClient* DBusThreadManager::GetShillManagerClient() { |
141 DBusThreadManager::GetShillManagerClient() { | 152 return clients_common_->shill_manager_client_.get(); |
142 return client_bundle_->shill_manager_client(); | |
143 } | 153 } |
144 | 154 |
145 ShillServiceClient* | 155 ShillServiceClient* DBusThreadManager::GetShillServiceClient() { |
146 DBusThreadManager::GetShillServiceClient() { | 156 return clients_common_->shill_service_client_.get(); |
147 return client_bundle_->shill_service_client(); | |
148 } | 157 } |
149 | 158 |
150 ShillProfileClient* | 159 ShillProfileClient* DBusThreadManager::GetShillProfileClient() { |
151 DBusThreadManager::GetShillProfileClient() { | 160 return clients_common_->shill_profile_client_.get(); |
152 return client_bundle_->shill_profile_client(); | |
153 } | 161 } |
154 | 162 |
155 ShillThirdPartyVpnDriverClient* | 163 ShillThirdPartyVpnDriverClient* |
156 DBusThreadManager::GetShillThirdPartyVpnDriverClient() { | 164 DBusThreadManager::GetShillThirdPartyVpnDriverClient() { |
157 return client_bundle_->shill_third_party_vpn_driver_client(); | 165 return clients_common_->shill_third_party_vpn_driver_client_.get(); |
158 } | 166 } |
159 | 167 |
160 GsmSMSClient* DBusThreadManager::GetGsmSMSClient() { | 168 GsmSMSClient* DBusThreadManager::GetGsmSMSClient() { |
161 return client_bundle_->gsm_sms_client(); | 169 return clients_ash_ ? clients_ash_->gsm_sms_client_.get() : nullptr; |
162 } | 170 } |
163 | 171 |
164 ImageBurnerClient* DBusThreadManager::GetImageBurnerClient() { | 172 ImageBurnerClient* DBusThreadManager::GetImageBurnerClient() { |
165 return client_bundle_->image_burner_client(); | 173 return clients_browser_ ? clients_browser_->image_burner_client_.get() |
| 174 : nullptr; |
166 } | 175 } |
167 | 176 |
168 ModemMessagingClient* DBusThreadManager::GetModemMessagingClient() { | 177 ModemMessagingClient* DBusThreadManager::GetModemMessagingClient() { |
169 return client_bundle_->modem_messaging_client(); | 178 return clients_ash_ ? clients_ash_->modem_messaging_client_.get() : nullptr; |
170 } | 179 } |
171 | 180 |
172 PermissionBrokerClient* DBusThreadManager::GetPermissionBrokerClient() { | 181 PermissionBrokerClient* DBusThreadManager::GetPermissionBrokerClient() { |
173 return client_bundle_->permission_broker_client(); | 182 return clients_common_->permission_broker_client_.get(); |
174 } | 183 } |
175 | 184 |
176 PowerManagerClient* DBusThreadManager::GetPowerManagerClient() { | 185 PowerManagerClient* DBusThreadManager::GetPowerManagerClient() { |
177 return client_bundle_->power_manager_client(); | 186 return clients_common_->power_manager_client_.get(); |
178 } | 187 } |
179 | 188 |
180 SessionManagerClient* DBusThreadManager::GetSessionManagerClient() { | 189 SessionManagerClient* DBusThreadManager::GetSessionManagerClient() { |
181 return client_bundle_->session_manager_client(); | 190 return clients_common_->session_manager_client_.get(); |
182 } | 191 } |
183 | 192 |
184 SMSClient* DBusThreadManager::GetSMSClient() { | 193 SMSClient* DBusThreadManager::GetSMSClient() { |
185 return client_bundle_->sms_client(); | 194 return clients_ash_ ? clients_ash_->sms_client_.get() : nullptr; |
186 } | 195 } |
187 | 196 |
188 SystemClockClient* DBusThreadManager::GetSystemClockClient() { | 197 SystemClockClient* DBusThreadManager::GetSystemClockClient() { |
189 return client_bundle_->system_clock_client(); | 198 return clients_common_->system_clock_client_.get(); |
190 } | 199 } |
191 | 200 |
192 UpdateEngineClient* DBusThreadManager::GetUpdateEngineClient() { | 201 UpdateEngineClient* DBusThreadManager::GetUpdateEngineClient() { |
193 return client_bundle_->update_engine_client(); | 202 return clients_common_->update_engine_client_.get(); |
194 } | 203 } |
195 | 204 |
196 void DBusThreadManager::InitializeClients() { | 205 void DBusThreadManager::InitializeClients() { |
197 GetArcObbMounterClient()->Init(GetSystemBus()); | 206 clients_common_->Initialize(GetSystemBus()); |
198 GetCrasAudioClient()->Init(GetSystemBus()); | 207 if (clients_ash_) |
199 GetCrosDisksClient()->Init(GetSystemBus()); | 208 clients_ash_->Initialize(GetSystemBus()); |
200 GetCryptohomeClient()->Init(GetSystemBus()); | 209 if (clients_browser_) |
201 GetDebugDaemonClient()->Init(GetSystemBus()); | 210 clients_browser_->Initialize(GetSystemBus()); |
202 GetEasyUnlockClient()->Init(GetSystemBus()); | |
203 GetGsmSMSClient()->Init(GetSystemBus()); | |
204 GetImageBurnerClient()->Init(GetSystemBus()); | |
205 GetLorgnetteManagerClient()->Init(GetSystemBus()); | |
206 GetModemMessagingClient()->Init(GetSystemBus()); | |
207 GetPermissionBrokerClient()->Init(GetSystemBus()); | |
208 GetPowerManagerClient()->Init(GetSystemBus()); | |
209 GetSessionManagerClient()->Init(GetSystemBus()); | |
210 GetShillDeviceClient()->Init(GetSystemBus()); | |
211 GetShillIPConfigClient()->Init(GetSystemBus()); | |
212 GetShillManagerClient()->Init(GetSystemBus()); | |
213 GetShillServiceClient()->Init(GetSystemBus()); | |
214 GetShillProfileClient()->Init(GetSystemBus()); | |
215 GetShillThirdPartyVpnDriverClient()->Init(GetSystemBus()); | |
216 GetSMSClient()->Init(GetSystemBus()); | |
217 GetSystemClockClient()->Init(GetSystemBus()); | |
218 GetUpdateEngineClient()->Init(GetSystemBus()); | |
219 | |
220 client_bundle_->SetupDefaultEnvironment(); | |
221 } | 211 } |
222 | 212 |
223 bool DBusThreadManager::IsUsingFake(DBusClientType client) { | 213 bool DBusThreadManager::IsUsingFake(DBusClientType client) { |
224 return !client_bundle_->IsUsingReal(client); | 214 return !clients_common_->IsUsingReal(client); |
225 } | 215 } |
226 | 216 |
227 // static | 217 // static |
228 void DBusThreadManager::Initialize() { | 218 void DBusThreadManager::Initialize(ProcessMask process_mask) { |
229 // If we initialize DBusThreadManager twice we may also be shutting it down | 219 // If we initialize DBusThreadManager twice we may also be shutting it down |
230 // early; do not allow that. | 220 // early; do not allow that. |
231 if (g_using_dbus_thread_manager_for_testing) | 221 if (g_using_dbus_thread_manager_for_testing) |
232 return; | 222 return; |
233 | 223 |
234 CHECK(!g_dbus_thread_manager); | 224 CHECK(!g_dbus_thread_manager); |
235 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); | 225 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
236 bool use_fakes = !base::SysInfo::IsRunningOnChromeOS() || | 226 bool use_fakes = !base::SysInfo::IsRunningOnChromeOS() || |
237 command_line->HasSwitch(chromeos::switches::kDbusStub); | 227 command_line->HasSwitch(chromeos::switches::kDbusStub); |
238 // TODO(jamescook): Delete this after M56 branches. | 228 // TODO(jamescook): Delete this after M56 branches. |
239 if (command_line->HasSwitch(chromeos::switches::kDbusUnstubClients)) | 229 if (command_line->HasSwitch(chromeos::switches::kDbusUnstubClients)) |
240 LOG(FATAL) << "Use --dbus-real-clients instead of --dbus-unstub-clients."; | 230 LOG(FATAL) << "Use --dbus-real-clients instead of --dbus-unstub-clients."; |
241 bool force_real_clients = | 231 bool force_real_clients = |
242 command_line->HasSwitch(chromeos::switches::kDbusRealClients); | 232 command_line->HasSwitch(chromeos::switches::kDbusRealClients); |
243 // Determine whether we use fake or real client implementations. | 233 // Determine whether we use fake or real client implementations. |
244 if (force_real_clients) { | 234 if (force_real_clients) { |
245 InitializeWithPartialFakes(command_line->GetSwitchValueASCII( | 235 InitializeWithPartialFakes(process_mask, |
246 chromeos::switches::kDbusRealClients)); | 236 command_line->GetSwitchValueASCII( |
| 237 chromeos::switches::kDbusRealClients)); |
247 } else if (use_fakes) { | 238 } else if (use_fakes) { |
248 InitializeWithFakeClients(); | 239 InitializeWithFakeClients(process_mask); |
249 } else { | 240 } else { |
250 InitializeWithRealClients(); | 241 InitializeWithRealClients(process_mask); |
251 } | 242 } |
252 } | 243 } |
253 | 244 |
254 // static | 245 // static |
| 246 void DBusThreadManager::Initialize() { |
| 247 Initialize(PROCESS_ALL); |
| 248 } |
| 249 |
| 250 // static |
255 std::unique_ptr<DBusThreadManagerSetter> | 251 std::unique_ptr<DBusThreadManagerSetter> |
256 DBusThreadManager::GetSetterForTesting() { | 252 DBusThreadManager::GetSetterForTesting() { |
257 if (!g_using_dbus_thread_manager_for_testing) { | 253 if (!g_using_dbus_thread_manager_for_testing) { |
258 g_using_dbus_thread_manager_for_testing = true; | 254 g_using_dbus_thread_manager_for_testing = true; |
259 InitializeWithFakeClients(); | 255 // TODO(jamescook): Don't initialize clients as a side-effect of using a |
| 256 // test API. For now, assume the caller wants all clients. |
| 257 InitializeWithFakeClients(PROCESS_ALL); |
260 } | 258 } |
261 | 259 |
262 return base::WrapUnique(new DBusThreadManagerSetter()); | 260 return base::WrapUnique(new DBusThreadManagerSetter()); |
263 } | 261 } |
264 | 262 |
265 // static | 263 // static |
266 void DBusThreadManager::CreateGlobalInstance( | 264 void DBusThreadManager::CreateGlobalInstance( |
| 265 ProcessMask process_mask, |
267 DBusClientTypeMask real_client_mask) { | 266 DBusClientTypeMask real_client_mask) { |
268 CHECK(!g_dbus_thread_manager); | 267 CHECK(!g_dbus_thread_manager); |
269 g_dbus_thread_manager = new DBusThreadManager( | 268 g_dbus_thread_manager = new DBusThreadManager(process_mask, real_client_mask); |
270 base::MakeUnique<DBusClientBundle>(real_client_mask)); | |
271 g_dbus_thread_manager->InitializeClients(); | 269 g_dbus_thread_manager->InitializeClients(); |
272 } | 270 } |
273 | 271 |
274 // static | 272 // static |
275 void DBusThreadManager::InitializeWithRealClients() { | 273 void DBusThreadManager::InitializeWithRealClients(ProcessMask process_mask) { |
276 CreateGlobalInstance(static_cast<DBusClientTypeMask>(DBusClientType::ALL)); | 274 CreateGlobalInstance(process_mask, |
| 275 static_cast<DBusClientTypeMask>(DBusClientType::ALL)); |
277 VLOG(1) << "DBusThreadManager initialized for Chrome OS"; | 276 VLOG(1) << "DBusThreadManager initialized for Chrome OS"; |
278 } | 277 } |
279 | 278 |
280 // static | 279 // static |
281 void DBusThreadManager::InitializeWithFakeClients() { | 280 void DBusThreadManager::InitializeWithFakeClients(ProcessMask process_mask) { |
282 CreateGlobalInstance(static_cast<DBusClientTypeMask>(DBusClientType::NONE)); | 281 CreateGlobalInstance(process_mask, |
| 282 static_cast<DBusClientTypeMask>(DBusClientType::NONE)); |
283 VLOG(1) << "DBusThreadManager created for testing"; | 283 VLOG(1) << "DBusThreadManager created for testing"; |
284 } | 284 } |
285 | 285 |
286 // static | 286 // static |
287 void DBusThreadManager::InitializeWithPartialFakes( | 287 void DBusThreadManager::InitializeWithPartialFakes( |
| 288 ProcessMask process_mask, |
288 const std::string& force_real_clients) { | 289 const std::string& force_real_clients) { |
289 DBusClientTypeMask real_client_mask = | 290 DBusClientTypeMask real_client_mask = |
290 ParseDBusRealClientsList(force_real_clients); | 291 ParseDBusRealClientsList(force_real_clients); |
291 // We should have something parsed correctly here. | 292 // We should have something parsed correctly here. |
292 LOG_IF(FATAL, real_client_mask == 0) | 293 LOG_IF(FATAL, real_client_mask == 0) |
293 << "Switch values for --" << chromeos::switches::kDbusRealClients | 294 << "Switch values for --" << chromeos::switches::kDbusRealClients |
294 << " cannot be parsed: " << real_client_mask; | 295 << " cannot be parsed: " << real_client_mask; |
295 VLOG(1) << "DBusThreadManager initialized for mixed runtime environment"; | 296 VLOG(1) << "DBusThreadManager initialized for mixed runtime environment"; |
296 CreateGlobalInstance(real_client_mask); | 297 CreateGlobalInstance(process_mask, real_client_mask); |
297 } | 298 } |
298 | 299 |
299 // static | 300 // static |
300 bool DBusThreadManager::IsInitialized() { | 301 bool DBusThreadManager::IsInitialized() { |
301 return g_dbus_thread_manager != NULL; | 302 return g_dbus_thread_manager != NULL; |
302 } | 303 } |
303 | 304 |
304 // static | 305 // static |
305 void DBusThreadManager::Shutdown() { | 306 void DBusThreadManager::Shutdown() { |
306 // Ensure that we only shutdown DBusThreadManager once. | 307 // Ensure that we only shutdown DBusThreadManager once. |
307 CHECK(g_dbus_thread_manager); | 308 CHECK(g_dbus_thread_manager); |
308 DBusThreadManager* dbus_thread_manager = g_dbus_thread_manager; | 309 DBusThreadManager* dbus_thread_manager = g_dbus_thread_manager; |
309 g_dbus_thread_manager = NULL; | 310 g_dbus_thread_manager = NULL; |
310 g_using_dbus_thread_manager_for_testing = false; | 311 g_using_dbus_thread_manager_for_testing = false; |
311 delete dbus_thread_manager; | 312 delete dbus_thread_manager; |
312 VLOG(1) << "DBusThreadManager Shutdown completed"; | 313 VLOG(1) << "DBusThreadManager Shutdown completed"; |
313 } | 314 } |
314 | 315 |
315 // static | 316 // static |
316 DBusThreadManager* DBusThreadManager::Get() { | 317 DBusThreadManager* DBusThreadManager::Get() { |
317 CHECK(g_dbus_thread_manager) | 318 CHECK(g_dbus_thread_manager) |
318 << "DBusThreadManager::Get() called before Initialize()"; | 319 << "DBusThreadManager::Get() called before Initialize()"; |
319 return g_dbus_thread_manager; | 320 return g_dbus_thread_manager; |
320 } | 321 } |
321 | 322 |
322 DBusThreadManagerSetter::DBusThreadManagerSetter() { | 323 DBusThreadManagerSetter::DBusThreadManagerSetter() {} |
323 } | |
324 | 324 |
325 DBusThreadManagerSetter::~DBusThreadManagerSetter() { | 325 DBusThreadManagerSetter::~DBusThreadManagerSetter() {} |
326 } | |
327 | 326 |
328 void DBusThreadManagerSetter::SetCrasAudioClient( | 327 void DBusThreadManagerSetter::SetCrasAudioClient( |
329 std::unique_ptr<CrasAudioClient> client) { | 328 std::unique_ptr<CrasAudioClient> client) { |
330 DBusThreadManager::Get()->client_bundle_->cras_audio_client_ = | 329 DBusThreadManager::Get()->clients_common_->cras_audio_client_ = |
331 std::move(client); | 330 std::move(client); |
332 } | 331 } |
333 | 332 |
334 void DBusThreadManagerSetter::SetCrosDisksClient( | 333 void DBusThreadManagerSetter::SetCrosDisksClient( |
335 std::unique_ptr<CrosDisksClient> client) { | 334 std::unique_ptr<CrosDisksClient> client) { |
336 DBusThreadManager::Get()->client_bundle_->cros_disks_client_ = | 335 DBusThreadManager::Get()->clients_browser_->cros_disks_client_ = |
337 std::move(client); | 336 std::move(client); |
338 } | 337 } |
339 | 338 |
340 void DBusThreadManagerSetter::SetCryptohomeClient( | 339 void DBusThreadManagerSetter::SetCryptohomeClient( |
341 std::unique_ptr<CryptohomeClient> client) { | 340 std::unique_ptr<CryptohomeClient> client) { |
342 DBusThreadManager::Get()->client_bundle_->cryptohome_client_ = | 341 DBusThreadManager::Get()->clients_common_->cryptohome_client_ = |
343 std::move(client); | 342 std::move(client); |
344 } | 343 } |
345 | 344 |
346 void DBusThreadManagerSetter::SetDebugDaemonClient( | 345 void DBusThreadManagerSetter::SetDebugDaemonClient( |
347 std::unique_ptr<DebugDaemonClient> client) { | 346 std::unique_ptr<DebugDaemonClient> client) { |
348 DBusThreadManager::Get()->client_bundle_->debug_daemon_client_ = | 347 DBusThreadManager::Get()->clients_browser_->debug_daemon_client_ = |
349 std::move(client); | |
350 } | |
351 | |
352 void DBusThreadManagerSetter::SetEasyUnlockClient( | |
353 std::unique_ptr<EasyUnlockClient> client) { | |
354 DBusThreadManager::Get()->client_bundle_->easy_unlock_client_ = | |
355 std::move(client); | |
356 } | |
357 | |
358 void DBusThreadManagerSetter::SetLorgnetteManagerClient( | |
359 std::unique_ptr<LorgnetteManagerClient> client) { | |
360 DBusThreadManager::Get()->client_bundle_->lorgnette_manager_client_ = | |
361 std::move(client); | 348 std::move(client); |
362 } | 349 } |
363 | 350 |
364 void DBusThreadManagerSetter::SetShillDeviceClient( | 351 void DBusThreadManagerSetter::SetShillDeviceClient( |
365 std::unique_ptr<ShillDeviceClient> client) { | 352 std::unique_ptr<ShillDeviceClient> client) { |
366 DBusThreadManager::Get()->client_bundle_->shill_device_client_ = | 353 DBusThreadManager::Get()->clients_common_->shill_device_client_ = |
367 std::move(client); | 354 std::move(client); |
368 } | 355 } |
369 | 356 |
370 void DBusThreadManagerSetter::SetShillIPConfigClient( | 357 void DBusThreadManagerSetter::SetShillIPConfigClient( |
371 std::unique_ptr<ShillIPConfigClient> client) { | 358 std::unique_ptr<ShillIPConfigClient> client) { |
372 DBusThreadManager::Get()->client_bundle_->shill_ipconfig_client_ = | 359 DBusThreadManager::Get()->clients_common_->shill_ipconfig_client_ = |
373 std::move(client); | 360 std::move(client); |
374 } | 361 } |
375 | 362 |
376 void DBusThreadManagerSetter::SetShillManagerClient( | 363 void DBusThreadManagerSetter::SetShillManagerClient( |
377 std::unique_ptr<ShillManagerClient> client) { | 364 std::unique_ptr<ShillManagerClient> client) { |
378 DBusThreadManager::Get()->client_bundle_->shill_manager_client_ = | 365 DBusThreadManager::Get()->clients_common_->shill_manager_client_ = |
379 std::move(client); | 366 std::move(client); |
380 } | 367 } |
381 | 368 |
382 void DBusThreadManagerSetter::SetShillServiceClient( | 369 void DBusThreadManagerSetter::SetShillServiceClient( |
383 std::unique_ptr<ShillServiceClient> client) { | 370 std::unique_ptr<ShillServiceClient> client) { |
384 DBusThreadManager::Get()->client_bundle_->shill_service_client_ = | 371 DBusThreadManager::Get()->clients_common_->shill_service_client_ = |
385 std::move(client); | 372 std::move(client); |
386 } | 373 } |
387 | 374 |
388 void DBusThreadManagerSetter::SetShillProfileClient( | 375 void DBusThreadManagerSetter::SetShillProfileClient( |
389 std::unique_ptr<ShillProfileClient> client) { | 376 std::unique_ptr<ShillProfileClient> client) { |
390 DBusThreadManager::Get()->client_bundle_->shill_profile_client_ = | 377 DBusThreadManager::Get()->clients_common_->shill_profile_client_ = |
391 std::move(client); | 378 std::move(client); |
392 } | 379 } |
393 | 380 |
394 void DBusThreadManagerSetter::SetShillThirdPartyVpnDriverClient( | 381 void DBusThreadManagerSetter::SetShillThirdPartyVpnDriverClient( |
395 std::unique_ptr<ShillThirdPartyVpnDriverClient> client) { | 382 std::unique_ptr<ShillThirdPartyVpnDriverClient> client) { |
396 DBusThreadManager::Get() | 383 DBusThreadManager::Get() |
397 ->client_bundle_->shill_third_party_vpn_driver_client_ = | 384 ->clients_common_->shill_third_party_vpn_driver_client_ = |
398 std::move(client); | 385 std::move(client); |
399 } | 386 } |
400 | 387 |
401 void DBusThreadManagerSetter::SetGsmSMSClient( | |
402 std::unique_ptr<GsmSMSClient> client) { | |
403 DBusThreadManager::Get()->client_bundle_->gsm_sms_client_ = std::move(client); | |
404 } | |
405 | |
406 void DBusThreadManagerSetter::SetImageBurnerClient( | 388 void DBusThreadManagerSetter::SetImageBurnerClient( |
407 std::unique_ptr<ImageBurnerClient> client) { | 389 std::unique_ptr<ImageBurnerClient> client) { |
408 DBusThreadManager::Get()->client_bundle_->image_burner_client_ = | 390 DBusThreadManager::Get()->clients_browser_->image_burner_client_ = |
409 std::move(client); | |
410 } | |
411 | |
412 void DBusThreadManagerSetter::SetModemMessagingClient( | |
413 std::unique_ptr<ModemMessagingClient> client) { | |
414 DBusThreadManager::Get()->client_bundle_->modem_messaging_client_ = | |
415 std::move(client); | 391 std::move(client); |
416 } | 392 } |
417 | 393 |
418 void DBusThreadManagerSetter::SetPermissionBrokerClient( | 394 void DBusThreadManagerSetter::SetPermissionBrokerClient( |
419 std::unique_ptr<PermissionBrokerClient> client) { | 395 std::unique_ptr<PermissionBrokerClient> client) { |
420 DBusThreadManager::Get()->client_bundle_->permission_broker_client_ = | 396 DBusThreadManager::Get()->clients_common_->permission_broker_client_ = |
421 std::move(client); | 397 std::move(client); |
422 } | 398 } |
423 | 399 |
424 void DBusThreadManagerSetter::SetPowerManagerClient( | 400 void DBusThreadManagerSetter::SetPowerManagerClient( |
425 std::unique_ptr<PowerManagerClient> client) { | 401 std::unique_ptr<PowerManagerClient> client) { |
426 DBusThreadManager::Get()->client_bundle_->power_manager_client_ = | 402 DBusThreadManager::Get()->clients_common_->power_manager_client_ = |
427 std::move(client); | 403 std::move(client); |
428 } | 404 } |
429 | 405 |
430 void DBusThreadManagerSetter::SetSessionManagerClient( | 406 void DBusThreadManagerSetter::SetSessionManagerClient( |
431 std::unique_ptr<SessionManagerClient> client) { | 407 std::unique_ptr<SessionManagerClient> client) { |
432 DBusThreadManager::Get()->client_bundle_->session_manager_client_ = | 408 DBusThreadManager::Get()->clients_common_->session_manager_client_ = |
433 std::move(client); | |
434 } | |
435 | |
436 void DBusThreadManagerSetter::SetSMSClient(std::unique_ptr<SMSClient> client) { | |
437 DBusThreadManager::Get()->client_bundle_->sms_client_ = std::move(client); | |
438 } | |
439 | |
440 void DBusThreadManagerSetter::SetSystemClockClient( | |
441 std::unique_ptr<SystemClockClient> client) { | |
442 DBusThreadManager::Get()->client_bundle_->system_clock_client_ = | |
443 std::move(client); | 409 std::move(client); |
444 } | 410 } |
445 | 411 |
446 void DBusThreadManagerSetter::SetUpdateEngineClient( | 412 void DBusThreadManagerSetter::SetUpdateEngineClient( |
447 std::unique_ptr<UpdateEngineClient> client) { | 413 std::unique_ptr<UpdateEngineClient> client) { |
448 DBusThreadManager::Get()->client_bundle_->update_engine_client_ = | 414 DBusThreadManager::Get()->clients_common_->update_engine_client_ = |
449 std::move(client); | 415 std::move(client); |
450 } | 416 } |
451 | 417 |
452 } // namespace chromeos | 418 } // namespace chromeos |
OLD | NEW |