shill: Setup .Task RPC service for incoming VPN communication.

This will be used by OpenVPN, for example, to communicate back to shill
connection information (IP, DNS, etc.).

The RPC class model mostly follows the existing RPC adaptor classes (Manager,
Service, etc.).

Task is a bit overloaded and confusing in the context of shill so calling the
RPC object RPCTask instead. Also, the current intent is for this object to just
handle RPC service calls. Once the initial VPN implementation is in we may
decide to rename and refactor these objects.

BUG=chromium-os:26993
TEST=unit test

Change-Id: Ie294524b954c4a589c07ad285c7703cbbf9157d6
Reviewed-on: https://gerrit.chromium.org/gerrit/17047
Reviewed-by: Darin Petkov <petkov@chromium.org>
Tested-by: Darin Petkov <petkov@chromium.org>
Reviewed-by: Sam Leffler <sleffler@chromium.org>
Commit-Ready: Darin Petkov <petkov@chromium.org>
diff --git a/rpc_task.cc b/rpc_task.cc
new file mode 100644
index 0000000..dd8b81b
--- /dev/null
+++ b/rpc_task.cc
@@ -0,0 +1,48 @@
+// 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.
+
+#include "shill/rpc_task.h"
+
+#include <base/string_number_conversions.h>
+
+#include "shill/adaptor_interfaces.h"
+#include "shill/control_interface.h"
+
+using std::map;
+using std::string;
+
+namespace shill {
+
+// static
+unsigned int RPCTask::serial_number_ = 0;
+
+RPCTask::RPCTask(ControlInterface *control_interface, RPCTaskDelegate *delegate)
+    : delegate_(delegate),
+      unique_name_(base::UintToString(serial_number_++)),
+      adaptor_(control_interface->CreateRPCTaskAdaptor(this)) {
+  CHECK(delegate);
+  VLOG(2) << "RPCTask " + unique_name_ + " created.";
+}
+
+RPCTask::~RPCTask() {
+  VLOG(2) << "RPCTask " + unique_name_ + " destroyed.";
+}
+
+void RPCTask::Notify(const string &reason, const map<string, string> &dict) {
+  delegate_->Notify(reason, dict);
+}
+
+string RPCTask::GetRpcIdentifier() const {
+  return adaptor_->GetRpcIdentifier();
+}
+
+string RPCTask::GetRpcInterfaceIdentifier() const {
+  return adaptor_->GetRpcInterfaceIdentifier();
+}
+
+string RPCTask::GetRpcConnectionIdentifier() const {
+  return adaptor_->GetRpcConnectionIdentifier();
+}
+
+}  // namespace shill