shill: wifi: Monitor the presence of WPA supplicant.

Connect to WPA supplicant only if it's present and suspend the device when WPA
supplicant disappears. This ensures that the WiFi device/service state remains
consistent across crashes of WPA supplicant, for example.

Also, drop the device connection when stopping the WiFi device. This avoids a
DCHECK for connections not being present in Manager::DeregisterService.

Remove a device restart on scan failure -- this should be covered now by the
explicit wpa_supplicant monitor.

BUG=chromium-os:31712,chromium-os:25657
TEST=tested on device, kill -SEGV wpa_supplicant; unit tests

Change-Id: I11efb1d841d4c7abd40da725b1d074170baee726
Reviewed-on: https://gerrit.chromium.org/gerrit/26017
Commit-Ready: Darin Petkov <petkov@chromium.org>
Reviewed-by: Darin Petkov <petkov@chromium.org>
Tested-by: Darin Petkov <petkov@chromium.org>
diff --git a/mock_dbus_manager.h b/mock_dbus_manager.h
new file mode 100644
index 0000000..6a6a837
--- /dev/null
+++ b/mock_dbus_manager.h
@@ -0,0 +1,29 @@
+// Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef SHILL_MOCK_DBUS_MANAGER_H_
+#define SHILL_MOCK_DBUS_MANAGER_H_
+
+#include <gmock/gmock.h>
+
+#include "shill/dbus_manager.h"
+
+namespace shill {
+
+class MockDBusManager : public DBusManager {
+ public:
+  MockDBusManager();
+  virtual ~MockDBusManager();
+
+  MOCK_METHOD3(WatchName, void(const std::string &name,
+                               const AppearedCallback &on_appear,
+                               const VanishedCallback &on_vanish));
+
+ private:
+  DISALLOW_COPY_AND_ASSIGN(MockDBusManager);
+};
+
+}  // namespace shill
+
+#endif  // SHILL_MOCK_DBUS_MANAGER_H_