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

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
« no previous file with comments | « chromeos/dbus/dbus_client_bundle.h ('k') | chromeos/dbus/dbus_client_bundle_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 const struct {
53 const char* param_name;
54 DBusClientBundle::DBusClientType client_type;
55 } client_type_map[] = {
56 { "bluetooth", DBusClientBundle::BLUETOOTH },
57 { "cras", DBusClientBundle::CRAS },
58 { "cros_disks", DBusClientBundle::CROS_DISKS },
59 { "cryptohome", DBusClientBundle::CRYPTOHOME },
60 { "debug_daemon", DBusClientBundle::DEBUG_DAEMON },
61 { "easy_unlock", DBusClientBundle::EASY_UNLOCK },
62 { "lorgnette_manager", DBusClientBundle::LORGNETTE_MANAGER },
63 { "shill", DBusClientBundle::SHILL },
64 { "gsm_sms", DBusClientBundle::GSM_SMS },
65 { "image_burner", DBusClientBundle::IMAGE_BURNER },
66 { "introspectable", DBusClientBundle::INTROSPECTABLE },
67 { "modem_messaging", DBusClientBundle::MODEM_MESSAGING },
68 { "nfc", DBusClientBundle::NFC },
69 { "permission_broker", DBusClientBundle::PERMISSION_BROKER },
70 { "power_manager", DBusClientBundle::POWER_MANAGER },
71 { "session_manager", DBusClientBundle::SESSION_MANAGER },
72 { "sms", DBusClientBundle::SMS },
73 { "system_clock", DBusClientBundle::SYSTEM_CLOCK },
74 { "update_engine", DBusClientBundle::UPDATE_ENGINE },
75 };
76
77 // Parses single command line param value for dbus subsystem and returns its
78 // enum representation. DBusClientType::UNKWNOWN is returned if |client_type|
79 // does not match any known dbus client.
80 DBusClientBundle::DBusClientType GetDBusClientType(
81 const std::string& client_type) {
82 for (size_t i = 0; i < arraysize(client_type_map); i++) {
83 if (LowerCaseEqualsASCII(client_type, client_type_map[i].param_name))
84 return client_type_map[i].client_type;
85 }
86 return DBusClientBundle::NO_CLIENTS;
87 }
88
89 } // namespace
90
91 DBusClientBundle::DBusClientBundle() {
92 const DBusClientImplementationType type = REAL_DBUS_CLIENT_IMPLEMENTATION;
93
94 if (!DBusThreadManager::IsUsingStub(BLUETOOTH)) {
95 bluetooth_adapter_client_.reset(BluetoothAdapterClient::Create());
96 bluetooth_agent_manager_client_.reset(
97 BluetoothAgentManagerClient::Create());
98 bluetooth_device_client_.reset(BluetoothDeviceClient::Create());
99 bluetooth_input_client_.reset(BluetoothInputClient::Create());
100 bluetooth_profile_manager_client_.reset(
101 BluetoothProfileManagerClient::Create());
102 bluetooth_gatt_characteristic_client_.reset(
103 BluetoothGattCharacteristicClient::Create());
104 bluetooth_gatt_descriptor_client_.reset(
105 BluetoothGattDescriptorClient::Create());
106 bluetooth_gatt_manager_client_.reset(
107 BluetoothGattManagerClient::Create());
108 bluetooth_gatt_service_client_.reset(
109 BluetoothGattServiceClient::Create());
110 }
111
112 if (!DBusThreadManager::IsUsingStub(CRAS))
113 cras_audio_client_.reset(CrasAudioClient::Create());
114
115 if (!DBusThreadManager::IsUsingStub(CROS_DISKS))
116 cros_disks_client_.reset(CrosDisksClient::Create(type));
117
118 if (!DBusThreadManager::IsUsingStub(CRYPTOHOME))
119 cryptohome_client_.reset(CryptohomeClient::Create());
120
121 if (!DBusThreadManager::IsUsingStub(DEBUG_DAEMON))
122 debug_daemon_client_.reset(DebugDaemonClient::Create());
123
124 if (!DBusThreadManager::IsUsingStub(EASY_UNLOCK))
125 easy_unlock_client_.reset(EasyUnlockClient::Create());
126
127 if (!DBusThreadManager::IsUsingStub(LORGNETTE_MANAGER))
128 lorgnette_manager_client_.reset(LorgnetteManagerClient::Create());
129
130 if (!DBusThreadManager::IsUsingStub(SHILL)) {
131 shill_manager_client_.reset(ShillManagerClient::Create());
132 shill_device_client_.reset(ShillDeviceClient::Create());
133 shill_ipconfig_client_.reset(ShillIPConfigClient::Create());
134 shill_service_client_.reset(ShillServiceClient::Create());
135 shill_profile_client_.reset(ShillProfileClient::Create());
136 }
137
138 if (!DBusThreadManager::IsUsingStub(GSM_SMS))
139 gsm_sms_client_.reset(GsmSMSClient::Create());
140
141 if (!DBusThreadManager::IsUsingStub(IMAGE_BURNER))
142 image_burner_client_.reset(ImageBurnerClient::Create());
143
144 if (!DBusThreadManager::IsUsingStub(INTROSPECTABLE))
145 introspectable_client_.reset(IntrospectableClient::Create());
146
147 if (!DBusThreadManager::IsUsingStub(MODEM_MESSAGING))
148 modem_messaging_client_.reset(ModemMessagingClient::Create());
149
150 // Create the NFC clients in the correct order based on their dependencies.
151 if (!DBusThreadManager::IsUsingStub(NFC)) {
152 nfc_manager_client_.reset(NfcManagerClient::Create());
153 nfc_adapter_client_.reset(
154 NfcAdapterClient::Create(nfc_manager_client_.get()));
155 nfc_device_client_.reset(
156 NfcDeviceClient::Create(nfc_adapter_client_.get()));
157 nfc_tag_client_.reset(NfcTagClient::Create(nfc_adapter_client_.get()));
158 nfc_record_client_.reset(NfcRecordClient::Create(nfc_device_client_.get(),
159 nfc_tag_client_.get()));
160 }
161
162 if (!DBusThreadManager::IsUsingStub(PERMISSION_BROKER))
163 permission_broker_client_.reset(PermissionBrokerClient::Create());
164
165 if (!DBusThreadManager::IsUsingStub(POWER_MANAGER))
166 power_manager_client_.reset(PowerManagerClient::Create(type));
167
168 if (!DBusThreadManager::IsUsingStub(SESSION_MANAGER))
169 session_manager_client_.reset(SessionManagerClient::Create(type));
170
171 if (!DBusThreadManager::IsUsingStub(SMS))
172 sms_client_.reset(SMSClient::Create());
173
174 if (!DBusThreadManager::IsUsingStub(SYSTEM_CLOCK))
175 system_clock_client_.reset(SystemClockClient::Create());
176
177 if (!DBusThreadManager::IsUsingStub(UPDATE_ENGINE))
178 update_engine_client_.reset(UpdateEngineClient::Create(type));
179 }
180
181 DBusClientBundle::~DBusClientBundle() {
182 }
183
184 // static
185 DBusClientBundle::DBusClientTypeMask DBusClientBundle::ParseUnstubList(
186 const std::string& unstub_list) {
187 DBusClientTypeMask unstub_mask = 0;
188 std::vector<std::string> unstub_components;
189 base::SplitString(unstub_list, ',', &unstub_components);
190 for (std::vector<std::string>::const_iterator iter =
191 unstub_components.begin();
192 iter != unstub_components.end(); ++iter) {
193 DBusClientBundle::DBusClientType client = GetDBusClientType(*iter);
194 if (client != DBusClientBundle::NO_CLIENTS) {
195 LOG(WARNING) << "Unstubbing dbus client for " << *iter;
196 unstub_mask |= client;
197 } else {
198 LOG(ERROR) << "Unknown dbus client: " << *iter;
199 }
200 }
201
202 return unstub_mask;
203 }
204
205 } // namespace chromeos
OLDNEW
« no previous file with comments | « chromeos/dbus/dbus_client_bundle.h ('k') | chromeos/dbus/dbus_client_bundle_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698