debugd: Prevent multiple instances of debugd from running.

DBus::Connection::request_name() does not indicate whether it
successfully acquires the requested DBus name or not. This CL changes
debugd to use newly introduced DBus::Connection::acquire_name()
(CL:195002) to ensure that debugd can successfully acquire its DBus
name.

BUG=chromium:364585
TEST=Tested the following:
1. `FEATURES=test emerge-$BOARD platform2`
2. Manually run the following commands in a root shell on the DUT:
   - `stop debugd` and then `start debugd` works
   - `restart debugd` works
   - `debugd` fails to acquire the DBus name when another instance of
     debugd is already running.

Change-Id: Ibe27a0ab2c49047b86411a4e62639c0f45a5b5cf
Reviewed-on: https://chromium-review.googlesource.com/195484
Reviewed-by: Jorge Lucangeli Obes <jorgelo@chromium.org>
Reviewed-by: mukesh agrawal <quiche@chromium.org>
Tested-by: Ben Chan <benchan@chromium.org>
Commit-Queue: Ben Chan <benchan@chromium.org>
diff --git a/src/debug_daemon.cc b/src/debug_daemon.cc
index 7c72745..549cdfc 100644
--- a/src/debug_daemon.cc
+++ b/src/debug_daemon.cc
@@ -37,11 +37,8 @@
   storage_tool_ = new StorageTool();
   memory_tool_ = new MemtesterTool();
   wimax_status_tool_ = new WiMaxStatusTool();
-  try {
-    // TODO(ellyjones): Remove this when crosbug.com/23964 is fixed
-    dbus_->request_name(kDebugDaemonService);
-  }
-  catch (DBus::Error e) { // NOLINT
+  if (!dbus_->acquire_name(kDebugDaemonService)) {
+    LOG(ERROR) << "Failed to acquire D-Bus name " << kDebugDaemonService;
     return false;
   }
   return true;