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

Unified Diff: chromeos/dbus/dbus_client_types.cc

Issue 2338063002: chromeos: Refactor D-Bus client type enum and stub vs. fake naming (Closed)
Patch Set: review comments Created 4 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chromeos/dbus/dbus_client_types.h ('k') | chromeos/dbus/dbus_thread_manager.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chromeos/dbus/dbus_client_types.cc
diff --git a/chromeos/dbus/dbus_client_types.cc b/chromeos/dbus/dbus_client_types.cc
new file mode 100644
index 0000000000000000000000000000000000000000..f21d973a7b4067d04d3c21c50405cd3713e2a5f1
--- /dev/null
+++ b/chromeos/dbus/dbus_client_types.cc
@@ -0,0 +1,69 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chromeos/dbus/dbus_client_types.h"
+
+#include "base/macros.h"
+#include "base/strings/string_split.h"
+#include "base/strings/string_util.h"
+
+namespace chromeos {
+
+namespace {
+
+// Command line switch mapping for --dbus-real-clients.
+const struct {
+ const char* param_name;
+ DBusClientType client_type;
+} kClientTypeMap[] = {
+ {"bluetooth", DBusClientType::BLUETOOTH},
+ {"cras", DBusClientType::CRAS},
+ {"cros_disks", DBusClientType::CROS_DISKS},
+ {"cryptohome", DBusClientType::CRYPTOHOME},
+ {"debug_daemon", DBusClientType::DEBUG_DAEMON},
+ {"easy_unlock", DBusClientType::EASY_UNLOCK},
+ {"lorgnette_manager", DBusClientType::LORGNETTE_MANAGER},
+ {"shill", DBusClientType::SHILL},
+ {"gsm_sms", DBusClientType::GSM_SMS},
+ {"image_burner", DBusClientType::IMAGE_BURNER},
+ {"modem_messaging", DBusClientType::MODEM_MESSAGING},
+ {"permission_broker", DBusClientType::PERMISSION_BROKER},
+ {"power_manager", DBusClientType::POWER_MANAGER},
+ {"session_manager", DBusClientType::SESSION_MANAGER},
+ {"sms", DBusClientType::SMS},
+ {"system_clock", DBusClientType::SYSTEM_CLOCK},
+ {"update_engine", DBusClientType::UPDATE_ENGINE},
+ {"arc_obb_mounter", DBusClientType::ARC_OBB_MOUNTER},
+};
+
+// Parses single command line param value for dbus subsystem. If successful,
+// returns its enum representation. Otherwise returns NONE.
+DBusClientType GetDBusClientType(const std::string& client_type_name) {
+ for (size_t i = 0; i < arraysize(kClientTypeMap); i++) {
+ if (base::LowerCaseEqualsASCII(client_type_name,
+ kClientTypeMap[i].param_name))
+ return kClientTypeMap[i].client_type;
+ }
+ return DBusClientType::NONE;
+}
+
+} // namespace
+
+DBusClientTypeMask ParseDBusRealClientsList(const std::string& clients_list) {
+ DBusClientTypeMask real_client_mask = 0;
+ for (const std::string& cur : base::SplitString(
+ clients_list, ",", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL)) {
+ DBusClientType client = GetDBusClientType(cur);
+ if (client != DBusClientType::NONE) {
+ LOG(WARNING) << "Forcing real dbus client for " << cur;
+ real_client_mask |= static_cast<int>(client);
+ } else {
+ LOG(ERROR) << "Unknown dbus client: " << cur;
+ }
+ }
+
+ return real_client_mask;
+}
+
+} // namespace chromeos
« no previous file with comments | « chromeos/dbus/dbus_client_types.h ('k') | chromeos/dbus/dbus_thread_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698