face: deduplicate callback typedefs between Channel and ProtocolFactory

This should have been part of commit 1d7e7afd381b91b6194d516826294b7f41f78745

Change-Id: I61623152180d4df288fc7dd3c225518e438d2bda
Refs: #3258
diff --git a/daemon/face/channel.hpp b/daemon/face/channel.hpp
index ea4b751..cb5ed27 100644
--- a/daemon/face/channel.hpp
+++ b/daemon/face/channel.hpp
@@ -1,11 +1,12 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /**
- * Copyright (c) 2014  Regents of the University of California,
- *                     Arizona Board of Regents,
- *                     Colorado State University,
- *                     University Pierre & Marie Curie, Sorbonne University,
- *                     Washington University in St. Louis,
- *                     Beijing Institute of Technology
+ * Copyright (c) 2014-2015,  Regents of the University of California,
+ *                           Arizona Board of Regents,
+ *                           Colorado State University,
+ *                           University Pierre & Marie Curie, Sorbonne University,
+ *                           Washington University in St. Louis,
+ *                           Beijing Institute of Technology,
+ *                           The University of Memphis.
  *
  * This file is part of NFD (Named Data Networking Forwarding Daemon).
  * See AUTHORS.md for complete list of NFD authors and contributors.
@@ -20,7 +21,7 @@
  *
  * You should have received a copy of the GNU General Public License along with
  * NFD, e.g., in COPYING.md file.  If not, see <http://www.gnu.org/licenses/>.
- **/
+ */
 
 #ifndef NFD_DAEMON_FACE_CHANNEL_HPP
 #define NFD_DAEMON_FACE_CHANNEL_HPP
@@ -31,20 +32,23 @@
 
 class Face;
 
+/**
+ * \brief Prototype for the callback that is invoked when the face
+ *        is created (as a response to incoming connection or after
+ *        connection is established)
+ */
+typedef function<void(const shared_ptr<Face>& newFace)> FaceCreatedCallback;
+
+/**
+ * \brief Prototype for the callback that is invoked when the face
+ *        fails to be created
+ */
+typedef function<void(const std::string& reason)> FaceCreationFailedCallback;
+
+
 class Channel : noncopyable
 {
 public:
-  /** \brief Prototype for the callback called when face is created
-   *         (as a response to incoming connection or after connection
-   *         is established)
-   */
-  typedef function<void(const shared_ptr<Face>& newFace)> FaceCreatedCallback;
-
-  /** \brief Prototype for the callback that is called when face is failed to
-   *         get created
-   */
-  typedef function<void(const std::string& reason)> ConnectFailedCallback;
-
   virtual
   ~Channel();
 
diff --git a/daemon/face/protocol-factory.hpp b/daemon/face/protocol-factory.hpp
index e2491ef..31efe8b 100644
--- a/daemon/face/protocol-factory.hpp
+++ b/daemon/face/protocol-factory.hpp
@@ -26,27 +26,10 @@
 #ifndef NFD_DAEMON_FACE_PROTOCOL_FACTORY_HPP
 #define NFD_DAEMON_FACE_PROTOCOL_FACTORY_HPP
 
-#include "common.hpp"
+#include "channel.hpp"
 
 namespace nfd {
 
-class Channel;
-class Face;
-
-/**
- * \brief Prototype for the callback that is invoked when the face
- *        is created (as a response to incoming connection or after
- *        connection is established)
- */
-typedef function<void(const shared_ptr<Face>& newFace)> FaceCreatedCallback;
-
-/**
- * \brief Prototype for the callback that is invoked when the face
- *        fails to be created
- */
-typedef function<void(const std::string& reason)> FaceCreationFailedCallback;
-
-
 /**
  * \brief Abstract base class for all protocol factories
  */
diff --git a/daemon/face/tcp-channel.cpp b/daemon/face/tcp-channel.cpp
index 2549c66..f9873c2 100644
--- a/daemon/face/tcp-channel.cpp
+++ b/daemon/face/tcp-channel.cpp
@@ -44,7 +44,7 @@
 
 void
 TcpChannel::listen(const FaceCreatedCallback& onFaceCreated,
-                   const ConnectFailedCallback& onAcceptFailed,
+                   const FaceCreationFailedCallback& onAcceptFailed,
                    int backlog/* = tcp::acceptor::max_connections*/)
 {
   if (isListening()) {
@@ -66,8 +66,8 @@
 
 void
 TcpChannel::connect(const tcp::Endpoint& remoteEndpoint,
-                    const TcpChannel::FaceCreatedCallback& onFaceCreated,
-                    const TcpChannel::ConnectFailedCallback& onConnectFailed,
+                    const FaceCreatedCallback& onFaceCreated,
+                    const FaceCreationFailedCallback& onConnectFailed,
                     const time::seconds& timeout/* = time::seconds(4)*/)
 {
   auto it = m_channelFaces.find(remoteEndpoint);
@@ -133,7 +133,7 @@
 
 void
 TcpChannel::accept(const FaceCreatedCallback& onFaceCreated,
-                   const ConnectFailedCallback& onAcceptFailed)
+                   const FaceCreationFailedCallback& onAcceptFailed)
 {
   m_acceptor.async_accept(m_acceptSocket, bind(&TcpChannel::handleAccept, this,
                                                boost::asio::placeholders::error,
@@ -143,7 +143,7 @@
 void
 TcpChannel::handleAccept(const boost::system::error_code& error,
                          const FaceCreatedCallback& onFaceCreated,
-                         const ConnectFailedCallback& onAcceptFailed)
+                         const FaceCreationFailedCallback& onAcceptFailed)
 {
   if (error) {
     if (error == boost::asio::error::operation_aborted) // when the socket is closed by someone
@@ -168,7 +168,7 @@
                           const shared_ptr<ip::tcp::socket>& socket,
                           const scheduler::EventId& connectTimeoutEvent,
                           const FaceCreatedCallback& onFaceCreated,
-                          const ConnectFailedCallback& onConnectFailed)
+                          const FaceCreationFailedCallback& onConnectFailed)
 {
   scheduler::cancel(connectTimeoutEvent);
 
@@ -200,7 +200,7 @@
 
 void
 TcpChannel::handleConnectTimeout(const shared_ptr<ip::tcp::socket>& socket,
-                                 const ConnectFailedCallback& onConnectFailed)
+                                 const FaceCreationFailedCallback& onConnectFailed)
 {
   NFD_LOG_DEBUG("Connect to remote endpoint timed out");
 
diff --git a/daemon/face/tcp-channel.hpp b/daemon/face/tcp-channel.hpp
index 7d9994a..799fbf1 100644
--- a/daemon/face/tcp-channel.hpp
+++ b/daemon/face/tcp-channel.hpp
@@ -66,7 +66,7 @@
    */
   void
   listen(const FaceCreatedCallback& onFaceCreated,
-         const ConnectFailedCallback& onAcceptFailed,
+         const FaceCreationFailedCallback& onAcceptFailed,
          int backlog = boost::asio::ip::tcp::acceptor::max_connections);
 
   /**
@@ -75,7 +75,7 @@
   void
   connect(const tcp::Endpoint& remoteEndpoint,
           const FaceCreatedCallback& onFaceCreated,
-          const ConnectFailedCallback& onConnectFailed,
+          const FaceCreationFailedCallback& onConnectFailed,
           const time::seconds& timeout = time::seconds(4));
 
   /**
@@ -95,23 +95,23 @@
 
   void
   accept(const FaceCreatedCallback& onFaceCreated,
-         const ConnectFailedCallback& onConnectFailed);
+         const FaceCreationFailedCallback& onAcceptFailed);
 
   void
   handleAccept(const boost::system::error_code& error,
                const FaceCreatedCallback& onFaceCreated,
-               const ConnectFailedCallback& onConnectFailed);
+               const FaceCreationFailedCallback& onAcceptFailed);
 
   void
   handleConnect(const boost::system::error_code& error,
                 const shared_ptr<boost::asio::ip::tcp::socket>& socket,
                 const scheduler::EventId& connectTimeoutEvent,
                 const FaceCreatedCallback& onFaceCreated,
-                const ConnectFailedCallback& onConnectFailed);
+                const FaceCreationFailedCallback& onConnectFailed);
 
   void
   handleConnectTimeout(const shared_ptr<boost::asio::ip::tcp::socket>& socket,
-                       const ConnectFailedCallback& onConnectFailed);
+                       const FaceCreationFailedCallback& onConnectFailed);
 
 private:
   std::map<tcp::Endpoint, shared_ptr<face::LpFaceWrapper>> m_channelFaces;
diff --git a/daemon/face/udp-channel.cpp b/daemon/face/udp-channel.cpp
index a1ff92c..d3791e4 100644
--- a/daemon/face/udp-channel.cpp
+++ b/daemon/face/udp-channel.cpp
@@ -45,7 +45,7 @@
 
 void
 UdpChannel::listen(const FaceCreatedCallback& onFaceCreated,
-                   const ConnectFailedCallback& onReceiveFailed)
+                   const FaceCreationFailedCallback& onReceiveFailed)
 {
   if (isListening()) {
     NFD_LOG_WARN("[" << m_localEndpoint << "] Already listening");
@@ -70,7 +70,7 @@
 UdpChannel::connect(const udp::Endpoint& remoteEndpoint,
                     ndn::nfd::FacePersistency persistency,
                     const FaceCreatedCallback& onFaceCreated,
-                    const ConnectFailedCallback& onConnectFailed)
+                    const FaceCreationFailedCallback& onConnectFailed)
 {
   shared_ptr<face::LpFaceWrapper> face;
   try {
@@ -136,7 +136,7 @@
 UdpChannel::handleNewPeer(const boost::system::error_code& error,
                           size_t nBytesReceived,
                           const FaceCreatedCallback& onFaceCreated,
-                          const ConnectFailedCallback& onReceiveFailed)
+                          const FaceCreationFailedCallback& onReceiveFailed)
 {
   if (error) {
     if (error == boost::asio::error::operation_aborted) // when the socket is closed by someone
diff --git a/daemon/face/udp-channel.hpp b/daemon/face/udp-channel.hpp
index aea854c..7a7c5eb 100644
--- a/daemon/face/udp-channel.hpp
+++ b/daemon/face/udp-channel.hpp
@@ -68,7 +68,7 @@
    */
   void
   listen(const FaceCreatedCallback& onFaceCreated,
-         const ConnectFailedCallback& onReceiveFailed);
+         const FaceCreationFailedCallback& onReceiveFailed);
 
   /**
    * \brief Create a face by establishing connection to remote endpoint
@@ -79,7 +79,7 @@
   connect(const udp::Endpoint& remoteEndpoint,
           ndn::nfd::FacePersistency persistency,
           const FaceCreatedCallback& onFaceCreated,
-          const ConnectFailedCallback& onConnectFailed);
+          const FaceCreationFailedCallback& onConnectFailed);
 
   /**
    * \brief Get number of faces in the channel
@@ -102,7 +102,7 @@
   handleNewPeer(const boost::system::error_code& error,
                 size_t nBytesReceived,
                 const FaceCreatedCallback& onFaceCreated,
-                const ConnectFailedCallback& onReceiveFailed);
+                const FaceCreationFailedCallback& onReceiveFailed);
 
 private:
   std::map<udp::Endpoint, shared_ptr<face::LpFaceWrapper>> m_channelFaces;
diff --git a/daemon/face/unix-stream-channel.cpp b/daemon/face/unix-stream-channel.cpp
index 3de9850..c34ad7b 100644
--- a/daemon/face/unix-stream-channel.cpp
+++ b/daemon/face/unix-stream-channel.cpp
@@ -58,7 +58,7 @@
 
 void
 UnixStreamChannel::listen(const FaceCreatedCallback& onFaceCreated,
-                          const ConnectFailedCallback& onAcceptFailed,
+                          const FaceCreationFailedCallback& onAcceptFailed,
                           int backlog/* = acceptor::max_connections*/)
 {
   if (isListening()) {
@@ -109,7 +109,7 @@
 
 void
 UnixStreamChannel::accept(const FaceCreatedCallback& onFaceCreated,
-                          const ConnectFailedCallback& onAcceptFailed)
+                          const FaceCreationFailedCallback& onAcceptFailed)
 {
   m_acceptor.async_accept(m_socket, bind(&UnixStreamChannel::handleAccept, this,
                                          boost::asio::placeholders::error,
@@ -119,7 +119,7 @@
 void
 UnixStreamChannel::handleAccept(const boost::system::error_code& error,
                                 const FaceCreatedCallback& onFaceCreated,
-                                const ConnectFailedCallback& onAcceptFailed)
+                                const FaceCreationFailedCallback& onAcceptFailed)
 {
   if (error) {
     if (error == boost::asio::error::operation_aborted) // when the socket is closed by someone
diff --git a/daemon/face/unix-stream-channel.hpp b/daemon/face/unix-stream-channel.hpp
index 06be812..fbddbe2 100644
--- a/daemon/face/unix-stream-channel.hpp
+++ b/daemon/face/unix-stream-channel.hpp
@@ -72,7 +72,7 @@
    */
   void
   listen(const FaceCreatedCallback& onFaceCreated,
-         const ConnectFailedCallback& onAcceptFailed,
+         const FaceCreationFailedCallback& onAcceptFailed,
          int backlog = boost::asio::local::stream_protocol::acceptor::max_connections);
 
   bool
@@ -81,12 +81,12 @@
 private:
   void
   accept(const FaceCreatedCallback& onFaceCreated,
-         const ConnectFailedCallback& onAcceptFailed);
+         const FaceCreationFailedCallback& onAcceptFailed);
 
   void
   handleAccept(const boost::system::error_code& error,
                const FaceCreatedCallback& onFaceCreated,
-               const ConnectFailedCallback& onAcceptFailed);
+               const FaceCreationFailedCallback& onAcceptFailed);
 
 private:
   unix_stream::Endpoint m_endpoint;