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 #include "chromeos/dbus/dbus_client_bundle.h" | 5 #include "chromeos/dbus/dbus_client_bundle.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/strings/string_split.h" | 8 #include "base/strings/string_split.h" |
9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
10 #include "chromeos/chromeos_switches.h" | 10 #include "chromeos/chromeos_switches.h" |
11 #include "chromeos/dbus/bluetooth_adapter_client.h" | 11 #include "chromeos/dbus/bluetooth_adapter_client.h" |
12 #include "chromeos/dbus/bluetooth_agent_manager_client.h" | 12 #include "chromeos/dbus/bluetooth_agent_manager_client.h" |
13 #include "chromeos/dbus/bluetooth_device_client.h" | 13 #include "chromeos/dbus/bluetooth_device_client.h" |
14 #include "chromeos/dbus/bluetooth_gatt_characteristic_client.h" | 14 #include "chromeos/dbus/bluetooth_gatt_characteristic_client.h" |
15 #include "chromeos/dbus/bluetooth_gatt_descriptor_client.h" | 15 #include "chromeos/dbus/bluetooth_gatt_descriptor_client.h" |
16 #include "chromeos/dbus/bluetooth_gatt_manager_client.h" | 16 #include "chromeos/dbus/bluetooth_gatt_manager_client.h" |
17 #include "chromeos/dbus/bluetooth_gatt_service_client.h" | 17 #include "chromeos/dbus/bluetooth_gatt_service_client.h" |
18 #include "chromeos/dbus/bluetooth_input_client.h" | 18 #include "chromeos/dbus/bluetooth_input_client.h" |
19 #include "chromeos/dbus/bluetooth_profile_manager_client.h" | 19 #include "chromeos/dbus/bluetooth_profile_manager_client.h" |
20 #include "chromeos/dbus/cras_audio_client.h" | 20 #include "chromeos/dbus/cras_audio_client.h" |
21 #include "chromeos/dbus/cras_audio_client_stub_impl.h" | 21 #include "chromeos/dbus/cras_audio_client_stub_impl.h" |
22 #include "chromeos/dbus/cros_disks_client.h" | 22 #include "chromeos/dbus/cros_disks_client.h" |
23 #include "chromeos/dbus/cryptohome_client.h" | 23 #include "chromeos/dbus/cryptohome_client.h" |
24 #include "chromeos/dbus/dbus_thread_manager.h" | |
25 #include "chromeos/dbus/debug_daemon_client.h" | 24 #include "chromeos/dbus/debug_daemon_client.h" |
26 #include "chromeos/dbus/easy_unlock_client.h" | 25 #include "chromeos/dbus/easy_unlock_client.h" |
27 #include "chromeos/dbus/fake_bluetooth_adapter_client.h" | 26 #include "chromeos/dbus/fake_bluetooth_adapter_client.h" |
28 #include "chromeos/dbus/fake_bluetooth_agent_manager_client.h" | 27 #include "chromeos/dbus/fake_bluetooth_agent_manager_client.h" |
29 #include "chromeos/dbus/fake_bluetooth_device_client.h" | 28 #include "chromeos/dbus/fake_bluetooth_device_client.h" |
30 #include "chromeos/dbus/fake_bluetooth_gatt_characteristic_client.h" | 29 #include "chromeos/dbus/fake_bluetooth_gatt_characteristic_client.h" |
31 #include "chromeos/dbus/fake_bluetooth_gatt_descriptor_client.h" | 30 #include "chromeos/dbus/fake_bluetooth_gatt_descriptor_client.h" |
32 #include "chromeos/dbus/fake_bluetooth_gatt_manager_client.h" | 31 #include "chromeos/dbus/fake_bluetooth_gatt_manager_client.h" |
33 #include "chromeos/dbus/fake_bluetooth_gatt_service_client.h" | 32 #include "chromeos/dbus/fake_bluetooth_gatt_service_client.h" |
34 #include "chromeos/dbus/fake_bluetooth_input_client.h" | 33 #include "chromeos/dbus/fake_bluetooth_input_client.h" |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
72 #include "chromeos/dbus/shill_ipconfig_client.h" | 71 #include "chromeos/dbus/shill_ipconfig_client.h" |
73 #include "chromeos/dbus/shill_manager_client.h" | 72 #include "chromeos/dbus/shill_manager_client.h" |
74 #include "chromeos/dbus/shill_profile_client.h" | 73 #include "chromeos/dbus/shill_profile_client.h" |
75 #include "chromeos/dbus/shill_service_client.h" | 74 #include "chromeos/dbus/shill_service_client.h" |
76 #include "chromeos/dbus/sms_client.h" | 75 #include "chromeos/dbus/sms_client.h" |
77 #include "chromeos/dbus/system_clock_client.h" | 76 #include "chromeos/dbus/system_clock_client.h" |
78 #include "chromeos/dbus/update_engine_client.h" | 77 #include "chromeos/dbus/update_engine_client.h" |
79 | 78 |
80 namespace chromeos { | 79 namespace chromeos { |
81 | 80 |
81 const DBusClientBundle::DBusClientTypeMask DBusClientBundle::NO_CLIENTS = 0; | |
82 const DBusClientBundle::DBusClientTypeMask DBusClientBundle::ALL_CLIENTS = | |
83 ~static_cast<DBusClientBundle::DBusClientTypeMask>(0); | |
satorux1
2014/09/10 05:25:33
I don't think it's a good idea to move these outsi
pneubeck (no reviews)
2014/09/10 07:58:13
I agree that 'None' makes some sense in the enum i
satorux1
2014/09/11 04:23:30
SGTM
| |
84 | |
82 namespace { | 85 namespace { |
83 | 86 |
84 // Command line switch mapping for --dbus-unstub-clients. | 87 // Command line switch mapping for --dbus-unstub-clients. |
85 const struct { | 88 const struct { |
86 const char* param_name; | 89 const char* param_name; |
87 DBusClientBundle::DBusClientType client_type; | 90 DBusClientBundle::DBusClientType client_type; |
88 } client_type_map[] = { | 91 } client_type_map[] = { |
89 { "bluetooth", DBusClientBundle::BLUETOOTH }, | 92 { "bluetooth", DBusClientBundle::BLUETOOTH }, |
90 { "cras", DBusClientBundle::CRAS }, | 93 { "cras", DBusClientBundle::CRAS }, |
91 { "cros_disks", DBusClientBundle::CROS_DISKS }, | 94 { "cros_disks", DBusClientBundle::CROS_DISKS }, |
92 { "cryptohome", DBusClientBundle::CRYPTOHOME }, | 95 { "cryptohome", DBusClientBundle::CRYPTOHOME }, |
93 { "debug_daemon", DBusClientBundle::DEBUG_DAEMON }, | 96 { "debug_daemon", DBusClientBundle::DEBUG_DAEMON }, |
94 { "easy_unlock", DBusClientBundle::EASY_UNLOCK }, | 97 { "easy_unlock", DBusClientBundle::EASY_UNLOCK }, |
95 { "lorgnette_manager", DBusClientBundle::LORGNETTE_MANAGER }, | 98 { "lorgnette_manager", DBusClientBundle::LORGNETTE_MANAGER }, |
96 { "shill", DBusClientBundle::SHILL }, | 99 { "shill", DBusClientBundle::SHILL }, |
97 { "gsm_sms", DBusClientBundle::GSM_SMS }, | 100 { "gsm_sms", DBusClientBundle::GSM_SMS }, |
98 { "image_burner", DBusClientBundle::IMAGE_BURNER }, | 101 { "image_burner", DBusClientBundle::IMAGE_BURNER }, |
99 { "introspectable", DBusClientBundle::INTROSPECTABLE }, | 102 { "introspectable", DBusClientBundle::INTROSPECTABLE }, |
100 { "modem_messaging", DBusClientBundle::MODEM_MESSAGING }, | 103 { "modem_messaging", DBusClientBundle::MODEM_MESSAGING }, |
101 { "nfc", DBusClientBundle::NFC }, | 104 { "nfc", DBusClientBundle::NFC }, |
102 { "permission_broker", DBusClientBundle::PERMISSION_BROKER }, | 105 { "permission_broker", DBusClientBundle::PERMISSION_BROKER }, |
103 { "power_manager", DBusClientBundle::POWER_MANAGER }, | 106 { "power_manager", DBusClientBundle::POWER_MANAGER }, |
104 { "session_manager", DBusClientBundle::SESSION_MANAGER }, | 107 { "session_manager", DBusClientBundle::SESSION_MANAGER }, |
105 { "sms", DBusClientBundle::SMS }, | 108 { "sms", DBusClientBundle::SMS }, |
106 { "system_clock", DBusClientBundle::SYSTEM_CLOCK }, | 109 { "system_clock", DBusClientBundle::SYSTEM_CLOCK }, |
107 { "update_engine", DBusClientBundle::UPDATE_ENGINE }, | 110 { "update_engine", DBusClientBundle::UPDATE_ENGINE }, |
108 }; | 111 }; |
109 | 112 |
110 // Parses single command line param value for dbus subsystem and returns its | 113 // Parses single command line param value for dbus subsystem. If successful, |
111 // enum representation. DBusClientType::UNKWNOWN is returned if |client_type| | 114 // assigns its enum representation to |client_type| and returns true. Otherwise |
112 // does not match any known dbus client. | 115 // returns false. |
113 DBusClientBundle::DBusClientType GetDBusClientType( | 116 bool GetDBusClientType(const std::string& client_type_name, |
114 const std::string& client_type) { | 117 DBusClientBundle::DBusClientType* client_type) { |
115 for (size_t i = 0; i < arraysize(client_type_map); i++) { | 118 for (size_t i = 0; i < arraysize(client_type_map); i++) { |
116 if (LowerCaseEqualsASCII(client_type, client_type_map[i].param_name)) | 119 if (LowerCaseEqualsASCII(client_type_name, client_type_map[i].param_name)) { |
117 return client_type_map[i].client_type; | 120 *client_type = client_type_map[i].client_type; |
121 return true; | |
122 } | |
118 } | 123 } |
119 return DBusClientBundle::NO_CLIENTS; | 124 return false; |
120 } | 125 } |
121 | 126 |
122 } // namespace | 127 } // namespace |
123 | 128 |
124 DBusClientBundle::DBusClientBundle() { | 129 DBusClientBundle::DBusClientBundle(DBusClientTypeMask unstub_client_mask) |
125 if (!DBusThreadManager::IsUsingStub(BLUETOOTH)) { | 130 : unstub_client_mask_(unstub_client_mask) { |
131 if (!IsUsingStub(BLUETOOTH)) { | |
126 bluetooth_adapter_client_.reset(BluetoothAdapterClient::Create()); | 132 bluetooth_adapter_client_.reset(BluetoothAdapterClient::Create()); |
127 bluetooth_agent_manager_client_.reset( | 133 bluetooth_agent_manager_client_.reset( |
128 BluetoothAgentManagerClient::Create()); | 134 BluetoothAgentManagerClient::Create()); |
129 bluetooth_device_client_.reset(BluetoothDeviceClient::Create()); | 135 bluetooth_device_client_.reset(BluetoothDeviceClient::Create()); |
130 bluetooth_input_client_.reset(BluetoothInputClient::Create()); | 136 bluetooth_input_client_.reset(BluetoothInputClient::Create()); |
131 bluetooth_profile_manager_client_.reset( | 137 bluetooth_profile_manager_client_.reset( |
132 BluetoothProfileManagerClient::Create()); | 138 BluetoothProfileManagerClient::Create()); |
133 bluetooth_gatt_characteristic_client_.reset( | 139 bluetooth_gatt_characteristic_client_.reset( |
134 BluetoothGattCharacteristicClient::Create()); | 140 BluetoothGattCharacteristicClient::Create()); |
135 bluetooth_gatt_descriptor_client_.reset( | 141 bluetooth_gatt_descriptor_client_.reset( |
(...skipping 10 matching lines...) Expand all Loading... | |
146 bluetooth_profile_manager_client_.reset( | 152 bluetooth_profile_manager_client_.reset( |
147 new FakeBluetoothProfileManagerClient); | 153 new FakeBluetoothProfileManagerClient); |
148 bluetooth_gatt_characteristic_client_.reset( | 154 bluetooth_gatt_characteristic_client_.reset( |
149 new FakeBluetoothGattCharacteristicClient); | 155 new FakeBluetoothGattCharacteristicClient); |
150 bluetooth_gatt_descriptor_client_.reset( | 156 bluetooth_gatt_descriptor_client_.reset( |
151 new FakeBluetoothGattDescriptorClient); | 157 new FakeBluetoothGattDescriptorClient); |
152 bluetooth_gatt_manager_client_.reset(new FakeBluetoothGattManagerClient); | 158 bluetooth_gatt_manager_client_.reset(new FakeBluetoothGattManagerClient); |
153 bluetooth_gatt_service_client_.reset(new FakeBluetoothGattServiceClient); | 159 bluetooth_gatt_service_client_.reset(new FakeBluetoothGattServiceClient); |
154 } | 160 } |
155 | 161 |
156 if (!DBusThreadManager::IsUsingStub(CRAS)) | 162 if (!IsUsingStub(CRAS)) |
157 cras_audio_client_.reset(CrasAudioClient::Create()); | 163 cras_audio_client_.reset(CrasAudioClient::Create()); |
158 else | 164 else |
159 cras_audio_client_.reset(new CrasAudioClientStubImpl); | 165 cras_audio_client_.reset(new CrasAudioClientStubImpl); |
160 | 166 |
161 cros_disks_client_.reset(CrosDisksClient::Create( | 167 cros_disks_client_.reset(CrosDisksClient::Create( |
162 DBusThreadManager::IsUsingStub(CROS_DISKS) ? | 168 IsUsingStub(CROS_DISKS) ? STUB_DBUS_CLIENT_IMPLEMENTATION |
163 STUB_DBUS_CLIENT_IMPLEMENTATION : | 169 : REAL_DBUS_CLIENT_IMPLEMENTATION)); |
164 REAL_DBUS_CLIENT_IMPLEMENTATION)); | |
165 | 170 |
166 if (!DBusThreadManager::IsUsingStub(CRYPTOHOME)) | 171 if (!IsUsingStub(CRYPTOHOME)) |
167 cryptohome_client_.reset(CryptohomeClient::Create()); | 172 cryptohome_client_.reset(CryptohomeClient::Create()); |
168 else | 173 else |
169 cryptohome_client_.reset(new FakeCryptohomeClient); | 174 cryptohome_client_.reset(new FakeCryptohomeClient); |
170 | 175 |
171 if (!DBusThreadManager::IsUsingStub(DEBUG_DAEMON)) | 176 if (!IsUsingStub(DEBUG_DAEMON)) |
172 debug_daemon_client_.reset(DebugDaemonClient::Create()); | 177 debug_daemon_client_.reset(DebugDaemonClient::Create()); |
173 else | 178 else |
174 debug_daemon_client_.reset(new FakeDebugDaemonClient); | 179 debug_daemon_client_.reset(new FakeDebugDaemonClient); |
175 | 180 |
176 if (!DBusThreadManager::IsUsingStub(EASY_UNLOCK)) | 181 if (!IsUsingStub(EASY_UNLOCK)) |
177 easy_unlock_client_.reset(EasyUnlockClient::Create()); | 182 easy_unlock_client_.reset(EasyUnlockClient::Create()); |
178 else | 183 else |
179 easy_unlock_client_.reset(new FakeEasyUnlockClient); | 184 easy_unlock_client_.reset(new FakeEasyUnlockClient); |
180 | 185 |
181 if (!DBusThreadManager::IsUsingStub(LORGNETTE_MANAGER)) | 186 if (!IsUsingStub(LORGNETTE_MANAGER)) |
182 lorgnette_manager_client_.reset(LorgnetteManagerClient::Create()); | 187 lorgnette_manager_client_.reset(LorgnetteManagerClient::Create()); |
183 else | 188 else |
184 lorgnette_manager_client_.reset(new FakeLorgnetteManagerClient); | 189 lorgnette_manager_client_.reset(new FakeLorgnetteManagerClient); |
185 | 190 |
186 if (!DBusThreadManager::IsUsingStub(SHILL)) { | 191 if (!IsUsingStub(SHILL)) { |
187 shill_manager_client_.reset(ShillManagerClient::Create()); | 192 shill_manager_client_.reset(ShillManagerClient::Create()); |
188 shill_device_client_.reset(ShillDeviceClient::Create()); | 193 shill_device_client_.reset(ShillDeviceClient::Create()); |
189 shill_ipconfig_client_.reset(ShillIPConfigClient::Create()); | 194 shill_ipconfig_client_.reset(ShillIPConfigClient::Create()); |
190 shill_service_client_.reset(ShillServiceClient::Create()); | 195 shill_service_client_.reset(ShillServiceClient::Create()); |
191 shill_profile_client_.reset(ShillProfileClient::Create()); | 196 shill_profile_client_.reset(ShillProfileClient::Create()); |
192 } else { | 197 } else { |
193 shill_manager_client_.reset(new FakeShillManagerClient); | 198 shill_manager_client_.reset(new FakeShillManagerClient); |
194 shill_device_client_.reset(new FakeShillDeviceClient); | 199 shill_device_client_.reset(new FakeShillDeviceClient); |
195 shill_ipconfig_client_.reset(new FakeShillIPConfigClient); | 200 shill_ipconfig_client_.reset(new FakeShillIPConfigClient); |
196 shill_service_client_.reset(new FakeShillServiceClient); | 201 shill_service_client_.reset(new FakeShillServiceClient); |
197 shill_profile_client_.reset(new FakeShillProfileClient); | 202 shill_profile_client_.reset(new FakeShillProfileClient); |
198 } | 203 } |
199 | 204 |
200 if (!DBusThreadManager::IsUsingStub(GSM_SMS)) { | 205 if (!IsUsingStub(GSM_SMS)) { |
201 gsm_sms_client_.reset(GsmSMSClient::Create()); | 206 gsm_sms_client_.reset(GsmSMSClient::Create()); |
202 } else { | 207 } else { |
203 FakeGsmSMSClient* gsm_sms_client = new FakeGsmSMSClient(); | 208 FakeGsmSMSClient* gsm_sms_client = new FakeGsmSMSClient(); |
204 gsm_sms_client->set_sms_test_message_switch_present( | 209 gsm_sms_client->set_sms_test_message_switch_present( |
205 CommandLine::ForCurrentProcess()->HasSwitch( | 210 CommandLine::ForCurrentProcess()->HasSwitch( |
206 chromeos::switches::kSmsTestMessages)); | 211 chromeos::switches::kSmsTestMessages)); |
207 gsm_sms_client_.reset(gsm_sms_client); | 212 gsm_sms_client_.reset(gsm_sms_client); |
208 } | 213 } |
209 | 214 |
210 if (!DBusThreadManager::IsUsingStub(IMAGE_BURNER)) | 215 if (!IsUsingStub(IMAGE_BURNER)) |
211 image_burner_client_.reset(ImageBurnerClient::Create()); | 216 image_burner_client_.reset(ImageBurnerClient::Create()); |
212 else | 217 else |
213 image_burner_client_.reset(new FakeImageBurnerClient); | 218 image_burner_client_.reset(new FakeImageBurnerClient); |
214 | 219 |
215 if (!DBusThreadManager::IsUsingStub(INTROSPECTABLE)) | 220 if (!IsUsingStub(INTROSPECTABLE)) |
216 introspectable_client_.reset(IntrospectableClient::Create()); | 221 introspectable_client_.reset(IntrospectableClient::Create()); |
217 else | 222 else |
218 introspectable_client_.reset(new FakeIntrospectableClient); | 223 introspectable_client_.reset(new FakeIntrospectableClient); |
219 | 224 |
220 if (!DBusThreadManager::IsUsingStub(MODEM_MESSAGING)) | 225 if (!IsUsingStub(MODEM_MESSAGING)) |
221 modem_messaging_client_.reset(ModemMessagingClient::Create()); | 226 modem_messaging_client_.reset(ModemMessagingClient::Create()); |
222 else | 227 else |
223 modem_messaging_client_.reset(new FakeModemMessagingClient); | 228 modem_messaging_client_.reset(new FakeModemMessagingClient); |
224 | 229 |
225 // Create the NFC clients in the correct order based on their dependencies. | 230 // Create the NFC clients in the correct order based on their dependencies. |
226 if (!DBusThreadManager::IsUsingStub(NFC)) { | 231 if (!IsUsingStub(NFC)) { |
227 nfc_manager_client_.reset(NfcManagerClient::Create()); | 232 nfc_manager_client_.reset(NfcManagerClient::Create()); |
228 nfc_adapter_client_.reset( | 233 nfc_adapter_client_.reset( |
229 NfcAdapterClient::Create(nfc_manager_client_.get())); | 234 NfcAdapterClient::Create(nfc_manager_client_.get())); |
230 nfc_device_client_.reset( | 235 nfc_device_client_.reset( |
231 NfcDeviceClient::Create(nfc_adapter_client_.get())); | 236 NfcDeviceClient::Create(nfc_adapter_client_.get())); |
232 nfc_tag_client_.reset(NfcTagClient::Create(nfc_adapter_client_.get())); | 237 nfc_tag_client_.reset(NfcTagClient::Create(nfc_adapter_client_.get())); |
233 nfc_record_client_.reset(NfcRecordClient::Create(nfc_device_client_.get(), | 238 nfc_record_client_.reset(NfcRecordClient::Create(nfc_device_client_.get(), |
234 nfc_tag_client_.get())); | 239 nfc_tag_client_.get())); |
235 } else { | 240 } else { |
236 nfc_manager_client_.reset(new FakeNfcManagerClient); | 241 nfc_manager_client_.reset(new FakeNfcManagerClient); |
237 nfc_adapter_client_.reset(new FakeNfcAdapterClient); | 242 nfc_adapter_client_.reset(new FakeNfcAdapterClient); |
238 nfc_device_client_.reset(new FakeNfcDeviceClient); | 243 nfc_device_client_.reset(new FakeNfcDeviceClient); |
239 nfc_tag_client_.reset(new FakeNfcTagClient); | 244 nfc_tag_client_.reset(new FakeNfcTagClient); |
240 nfc_record_client_.reset(new FakeNfcRecordClient); | 245 nfc_record_client_.reset(new FakeNfcRecordClient); |
241 } | 246 } |
242 | 247 |
243 if (!DBusThreadManager::IsUsingStub(PERMISSION_BROKER)) | 248 if (!IsUsingStub(PERMISSION_BROKER)) |
244 permission_broker_client_.reset(PermissionBrokerClient::Create()); | 249 permission_broker_client_.reset(PermissionBrokerClient::Create()); |
245 else | 250 else |
246 permission_broker_client_.reset(new FakePermissionBrokerClient); | 251 permission_broker_client_.reset(new FakePermissionBrokerClient); |
247 | 252 |
248 power_manager_client_.reset(PowerManagerClient::Create( | 253 power_manager_client_.reset(PowerManagerClient::Create( |
249 DBusThreadManager::IsUsingStub(POWER_MANAGER) ? | 254 IsUsingStub(POWER_MANAGER) ? STUB_DBUS_CLIENT_IMPLEMENTATION |
250 STUB_DBUS_CLIENT_IMPLEMENTATION : | 255 : REAL_DBUS_CLIENT_IMPLEMENTATION)); |
251 REAL_DBUS_CLIENT_IMPLEMENTATION)); | |
252 | 256 |
253 session_manager_client_.reset(SessionManagerClient::Create( | 257 session_manager_client_.reset(SessionManagerClient::Create( |
254 DBusThreadManager::IsUsingStub(SESSION_MANAGER) ? | 258 IsUsingStub(SESSION_MANAGER) ? STUB_DBUS_CLIENT_IMPLEMENTATION |
255 STUB_DBUS_CLIENT_IMPLEMENTATION : | 259 : REAL_DBUS_CLIENT_IMPLEMENTATION)); |
256 REAL_DBUS_CLIENT_IMPLEMENTATION)); | |
257 | 260 |
258 if (!DBusThreadManager::IsUsingStub(SMS)) | 261 if (!IsUsingStub(SMS)) |
259 sms_client_.reset(SMSClient::Create()); | 262 sms_client_.reset(SMSClient::Create()); |
260 else | 263 else |
261 sms_client_.reset(new FakeSMSClient); | 264 sms_client_.reset(new FakeSMSClient); |
262 | 265 |
263 if (!DBusThreadManager::IsUsingStub(SYSTEM_CLOCK)) | 266 if (!IsUsingStub(SYSTEM_CLOCK)) |
264 system_clock_client_.reset(SystemClockClient::Create()); | 267 system_clock_client_.reset(SystemClockClient::Create()); |
265 else | 268 else |
266 system_clock_client_.reset(new FakeSystemClockClient); | 269 system_clock_client_.reset(new FakeSystemClockClient); |
267 | 270 |
268 update_engine_client_.reset(UpdateEngineClient::Create( | 271 update_engine_client_.reset(UpdateEngineClient::Create( |
269 DBusThreadManager::IsUsingStub(UPDATE_ENGINE) ? | 272 IsUsingStub(UPDATE_ENGINE) ? STUB_DBUS_CLIENT_IMPLEMENTATION |
270 STUB_DBUS_CLIENT_IMPLEMENTATION : | 273 : REAL_DBUS_CLIENT_IMPLEMENTATION)); |
271 REAL_DBUS_CLIENT_IMPLEMENTATION)); | |
272 } | 274 } |
273 | 275 |
274 DBusClientBundle::~DBusClientBundle() { | 276 DBusClientBundle::~DBusClientBundle() { |
275 } | 277 } |
276 | 278 |
279 bool DBusClientBundle::IsUsingStub(DBusClientType client) { | |
280 return !(unstub_client_mask_ & client); | |
281 } | |
282 | |
283 bool DBusClientBundle::IsUsingAnyRegularClient() { | |
284 // 'Using any regular client' is equivalent to 'Unstubbed any client'. | |
285 return unstub_client_mask_ != 0; | |
286 } | |
287 | |
277 void DBusClientBundle::SetupDefaultEnvironment() { | 288 void DBusClientBundle::SetupDefaultEnvironment() { |
278 ShillManagerClient::TestInterface* manager = | 289 ShillManagerClient::TestInterface* manager = |
279 shill_manager_client_->GetTestInterface(); | 290 shill_manager_client_->GetTestInterface(); |
280 if (manager) | 291 if (manager) |
281 manager->SetupDefaultEnvironment(); | 292 manager->SetupDefaultEnvironment(); |
282 } | 293 } |
283 | 294 |
284 // static | 295 // static |
285 DBusClientBundle::DBusClientTypeMask DBusClientBundle::ParseUnstubList( | 296 DBusClientBundle::DBusClientTypeMask DBusClientBundle::ParseUnstubList( |
286 const std::string& unstub_list) { | 297 const std::string& unstub_list) { |
287 DBusClientTypeMask unstub_mask = 0; | 298 DBusClientTypeMask unstub_mask = 0; |
288 std::vector<std::string> unstub_components; | 299 std::vector<std::string> unstub_components; |
289 base::SplitString(unstub_list, ',', &unstub_components); | 300 base::SplitString(unstub_list, ',', &unstub_components); |
290 for (std::vector<std::string>::const_iterator iter = | 301 for (std::vector<std::string>::const_iterator iter = |
291 unstub_components.begin(); | 302 unstub_components.begin(); |
292 iter != unstub_components.end(); ++iter) { | 303 iter != unstub_components.end(); ++iter) { |
293 DBusClientBundle::DBusClientType client = GetDBusClientType(*iter); | 304 DBusClientBundle::DBusClientType client = BLUETOOTH; // any default value |
294 if (client != DBusClientBundle::NO_CLIENTS) { | 305 if (GetDBusClientType(*iter, &client)) { |
295 LOG(WARNING) << "Unstubbing dbus client for " << *iter; | 306 LOG(WARNING) << "Unstubbing dbus client for " << *iter; |
296 unstub_mask |= client; | 307 unstub_mask |= client; |
297 } else { | 308 } else { |
298 LOG(ERROR) << "Unknown dbus client: " << *iter; | 309 LOG(ERROR) << "Unknown dbus client: " << *iter; |
299 } | 310 } |
300 } | 311 } |
301 | 312 |
302 return unstub_mask; | 313 return unstub_mask; |
303 } | 314 } |
304 | 315 |
305 } // namespace chromeos | 316 } // namespace chromeos |
OLD | NEW |