shill: add support for allowing remote dbus service to claim/release devices

Add method ClaimInterface and ReleaseInterface to DBus interface
org.chromium.flimflam.Manager to allow remote DBus service to claim
the ownership of network interfaces from shill.

To reduce complexity, this service will only support one DBus service at a
time, which means disallow a DBus service from claiming interface from shill
if another DBus service currently had ownership to one or more interfaces
from shill.

When an interface is claimed by a remote DBus service, shill will stop any
activities on that interface, deregister it from the manager if it is
registered, and put it in the blacklist to avoid any further usage. Once the
interface is released by the remote DBus service, it will be removed from the
blacklist and a new device will be created/registered when it is detected
through RTNL.

BUG=chromium:435704
TEST=unittests, manual test will be done using apmanager.

Change-Id: Ie01945f083910345d4cbe9e1d2e64711b5d60891
Reviewed-on: https://chromium-review.googlesource.com/231930
Reviewed-by: Peter Qiu <zqiu@chromium.org>
Commit-Queue: Peter Qiu <zqiu@chromium.org>
Tested-by: Peter Qiu <zqiu@chromium.org>
Reviewed-by: Paul Stewart <pstew@chromium.org>
diff --git a/mock_device_claimer.h b/mock_device_claimer.h
new file mode 100644
index 0000000..8c2a94b
--- /dev/null
+++ b/mock_device_claimer.h
@@ -0,0 +1,32 @@
+// Copyright 2014 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_DEVICE_CLAIMER_H_
+#define SHILL_MOCK_DEVICE_CLAIMER_H_
+
+#include "shill/device_claimer.h"
+
+#include <string>
+
+#include <base/macros.h>
+#include <gmock/gmock.h>
+
+namespace shill {
+
+class MockDeviceClaimer : public DeviceClaimer {
+ public:
+  explicit MockDeviceClaimer(const std::string &dbus_service_name);
+  ~MockDeviceClaimer() override;
+
+  MOCK_METHOD2(Claim, bool(const std::string &device_name, Error *error));
+  MOCK_METHOD2(Release, bool(const std::string &device_name, Error *error));
+  MOCK_METHOD0(DevicesClaimed, bool());
+
+ private:
+  DISALLOW_COPY_AND_ASSIGN(MockDeviceClaimer);
+};
+
+}  // namespace shill
+
+#endif  // SHILL_MOCK_DEVICE_CLAIMER_H_