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

Side by Side Diff: chromeos/dbus/dbus_client_bundle.cc

Issue 444263002: Added switch that let us 'un-stub' certain dbus clients. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 4 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 | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chromeos/dbus/dbus_client_bundle.h"
6
7 #include "base/strings/string_split.h"
8 #include "base/strings/string_util.h"
9 #include "chromeos/dbus/bluetooth_adapter_client.h"
10 #include "chromeos/dbus/bluetooth_agent_manager_client.h"
11 #include "chromeos/dbus/bluetooth_device_client.h"
12 #include "chromeos/dbus/bluetooth_gatt_characteristic_client.h"
13 #include "chromeos/dbus/bluetooth_gatt_descriptor_client.h"
14 #include "chromeos/dbus/bluetooth_gatt_manager_client.h"
15 #include "chromeos/dbus/bluetooth_gatt_service_client.h"
16 #include "chromeos/dbus/bluetooth_input_client.h"
17 #include "chromeos/dbus/bluetooth_profile_manager_client.h"
18 #include "chromeos/dbus/cras_audio_client.h"
19 #include "chromeos/dbus/cros_disks_client.h"
20 #include "chromeos/dbus/cryptohome_client.h"
21 #include "chromeos/dbus/dbus_thread_manager.h"
22 #include "chromeos/dbus/debug_daemon_client.h"
23 #include "chromeos/dbus/easy_unlock_client.h"
24 #include "chromeos/dbus/gsm_sms_client.h"
25 #include "chromeos/dbus/image_burner_client.h"
26 #include "chromeos/dbus/introspectable_client.h"
27 #include "chromeos/dbus/lorgnette_manager_client.h"
28 #include "chromeos/dbus/modem_messaging_client.h"
29 #include "chromeos/dbus/nfc_adapter_client.h"
30 #include "chromeos/dbus/nfc_device_client.h"
31 #include "chromeos/dbus/nfc_manager_client.h"
32 #include "chromeos/dbus/nfc_record_client.h"
33 #include "chromeos/dbus/nfc_tag_client.h"
34 #include "chromeos/dbus/permission_broker_client.h"
35 #include "chromeos/dbus/power_manager_client.h"
36 #include "chromeos/dbus/power_policy_controller.h"
37 #include "chromeos/dbus/session_manager_client.h"
38 #include "chromeos/dbus/shill_device_client.h"
39 #include "chromeos/dbus/shill_ipconfig_client.h"
40 #include "chromeos/dbus/shill_manager_client.h"
41 #include "chromeos/dbus/shill_profile_client.h"
42 #include "chromeos/dbus/shill_service_client.h"
43 #include "chromeos/dbus/sms_client.h"
44 #include "chromeos/dbus/system_clock_client.h"
45 #include "chromeos/dbus/update_engine_client.h"
46
47 namespace chromeos {
48
49 namespace {
50
51 // Command line switch mapping for --dbus-unstub-clients.
52 struct {
53 const char* param_name;
54 DBusClientBundle::DBusClientType client_type;
55 } client_type_map[] = {
56 { "bluetooth", DBusClientBundle::BLUETOOTH },
57 { "bluetoothlowenergy", DBusClientBundle::BLUETOOTH_LOW_ENERGY },
satorux1 2014/08/11 01:52:09 bluetooth_low_energy to be consistent with the enu
zel 2014/08/12 17:32:32 Done.
58 { "cras", DBusClientBundle::CRAS },
59 { "crosdisks", DBusClientBundle::CROS_DISKS },
60 { "cryptohome", DBusClientBundle::CRYPTOHOME },
61 { "debugdaemon", DBusClientBundle::DEBUG_DAEMON },
62 { "easyunlock", DBusClientBundle::EASY_UNLOCK },
63 { "lorgnettemanager", DBusClientBundle::LORGNETTE_MANAGER },
64 { "shill", DBusClientBundle::SHILL },
65 { "gsmsms", DBusClientBundle::GSM_SMS },
66 { "imageburner", DBusClientBundle::IMAGE_BURNER },
67 { "introspectable", DBusClientBundle::INTROSPECTABLE },
68 { "modemmessaging", DBusClientBundle::MODEM_MESSAGING },
69 { "nfc", DBusClientBundle::NFC },
70 { "permissionbroker", DBusClientBundle::PERMISSION_BROKER },
71 { "powermanager", DBusClientBundle::POWER_MANAGER },
72 { "powerpolicy", DBusClientBundle::POWER_POLICY },
73 { "sessionmanager", DBusClientBundle::SESSION_MANAGER },
74 { "sms", DBusClientBundle::SMS },
75 { "systemclock", DBusClientBundle::SYSTEM_CLOCK },
76 { "updateengine", DBusClientBundle::UPDATE_ENGINE },
77 };
78
79 // Parses single command line param value for dbus subsystem and returns its
80 // enum representation. DBusClientType::UNKWNOWN is returned if |client_type|
81 // does not match any known dbus client.
82 DBusClientBundle::DBusClientType GetDBusClientType(
83 const std::string& client_type) {
84 for (size_t i = 0; i < arraysize(client_type_map); i++) {
85 if (LowerCaseEqualsASCII(client_type, client_type_map[i].param_name))
86 return client_type_map[i].client_type;
87 }
88 return DBusClientBundle::UNKNOWN;
89 }
90
91 } // namespace
92 DBusClientBundle::DBusClientBundle() {
93 const DBusClientImplementationType type = REAL_DBUS_CLIENT_IMPLEMENTATION;
94
95 if (!DBusThreadManager::IsUsingStub(BLUETOOTH)) {
96 bluetooth_adapter_client_.reset(BluetoothAdapterClient::Create());
97 bluetooth_agent_manager_client_.reset(
98 BluetoothAgentManagerClient::Create());
99 bluetooth_device_client_.reset(BluetoothDeviceClient::Create());
100 bluetooth_input_client_.reset(BluetoothInputClient::Create());
101 bluetooth_profile_manager_client_.reset(
102 BluetoothProfileManagerClient::Create());
103 }
104
105 if (!DBusThreadManager::IsUsingStub(BLUETOOTH_LOW_ENERGY)) {
106 bluetooth_gatt_characteristic_client_.reset(
107 BluetoothGattCharacteristicClient::Create());
108 bluetooth_gatt_descriptor_client_.reset(
109 BluetoothGattDescriptorClient::Create());
110 bluetooth_gatt_manager_client_.reset(
111 BluetoothGattManagerClient::Create());
112 bluetooth_gatt_service_client_.reset(
113 BluetoothGattServiceClient::Create());
114 }
115
116 if (!DBusThreadManager::IsUsingStub(CRAS))
117 cras_audio_client_.reset(CrasAudioClient::Create());
118
119 if (!DBusThreadManager::IsUsingStub(CROS_DISKS))
120 cros_disks_client_.reset(CrosDisksClient::Create(type));
121
122 if (!DBusThreadManager::IsUsingStub(CRYPTOHOME))
123 cryptohome_client_.reset(CryptohomeClient::Create());
124
125 if (!DBusThreadManager::IsUsingStub(DEBUG_DAEMON))
126 debug_daemon_client_.reset(DebugDaemonClient::Create());
127
128 if (!DBusThreadManager::IsUsingStub(EASY_UNLOCK))
129 easy_unlock_client_.reset(EasyUnlockClient::Create());
130
131 if (!DBusThreadManager::IsUsingStub(LORGNETTE_MANAGER))
132 lorgnette_manager_client_.reset(LorgnetteManagerClient::Create());
133
134 if (!DBusThreadManager::IsUsingStub(SHILL)) {
135 shill_manager_client_.reset(ShillManagerClient::Create());
136 shill_device_client_.reset(ShillDeviceClient::Create());
137 shill_ipconfig_client_.reset(ShillIPConfigClient::Create());
138 shill_service_client_.reset(ShillServiceClient::Create());
139 shill_profile_client_.reset(ShillProfileClient::Create());
140 }
141
142 if (!DBusThreadManager::IsUsingStub(GSM_SMS))
143 gsm_sms_client_.reset(GsmSMSClient::Create());
144
145 if (!DBusThreadManager::IsUsingStub(IMAGE_BURNER))
146 image_burner_client_.reset(ImageBurnerClient::Create());
147
148 if (!DBusThreadManager::IsUsingStub(INTROSPECTABLE))
149 introspectable_client_.reset(IntrospectableClient::Create());
150
151 if (!DBusThreadManager::IsUsingStub(MODEM_MESSAGING))
152 modem_messaging_client_.reset(ModemMessagingClient::Create());
153
154 // Create the NFC clients in the correct order based on their dependencies.
155 if (!DBusThreadManager::IsUsingStub(NFC)) {
156 nfc_manager_client_.reset(NfcManagerClient::Create());
157 nfc_adapter_client_.reset(
158 NfcAdapterClient::Create(nfc_manager_client_.get()));
159 nfc_device_client_.reset(
160 NfcDeviceClient::Create(nfc_adapter_client_.get()));
161 nfc_tag_client_.reset(NfcTagClient::Create(nfc_adapter_client_.get()));
162 nfc_record_client_.reset(NfcRecordClient::Create(nfc_device_client_.get(),
163 nfc_tag_client_.get()));
164 }
165
166 if (!DBusThreadManager::IsUsingStub(PERMISSION_BROKER))
167 permission_broker_client_.reset(PermissionBrokerClient::Create());
168
169 if (!DBusThreadManager::IsUsingStub(POWER_MANAGER))
170 power_manager_client_.reset(PowerManagerClient::Create(type));
171
172 if (!DBusThreadManager::IsUsingStub(SESSION_MANAGER))
173 session_manager_client_.reset(SessionManagerClient::Create(type));
174
175 if (!DBusThreadManager::IsUsingStub(SMS))
176 sms_client_.reset(SMSClient::Create());
177
178 if (!DBusThreadManager::IsUsingStub(SYSTEM_CLOCK))
179 system_clock_client_.reset(SystemClockClient::Create());
180
181 if (!DBusThreadManager::IsUsingStub(UPDATE_ENGINE))
182 update_engine_client_.reset(UpdateEngineClient::Create(type));
183 }
184
185 DBusClientBundle::~DBusClientBundle() {
186 }
187
188 // static
189 DBusClientBundle::DBusClientTypeMask DBusClientBundle::ParseUnstubList(
190 const std::string& unstub_list) {
191 DBusClientTypeMask unstub_mask = 0;
192 std::vector<std::string> unstub_components;
193 base::SplitString(unstub_list, ',', &unstub_components);
194 for (std::vector<std::string>::const_iterator iter =
195 unstub_components.begin();
196 iter != unstub_components.end(); ++iter) {
197 DBusClientBundle::DBusClientType client = GetDBusClientType(*iter);
198 if (client != DBusClientBundle::UNKNOWN) {
199 LOG(WARNING) << "Unstubbing dbus client for " << *iter;
200 unstub_mask |= client;
201 } else {
202 LOG(ERROR) << "Unknown dbus client: " << *iter;
203 }
204 }
205
206 return unstub_mask;
207 }
208
209 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698