Remove dependency on Selectors and refactor codebase.

Change-Id: Ic3024b76ba0eea61f790c91c36090b4aa68702a3
Refs: #4522
diff --git a/src/handles/write-handle.hpp b/src/handles/write-handle.hpp
index 686d68c..115801e 100644
--- a/src/handles/write-handle.hpp
+++ b/src/handles/write-handle.hpp
@@ -23,15 +23,12 @@
 #include "command-base-handle.hpp"
 
 #include <ndn-cxx/mgmt/dispatcher.hpp>
+#include <ndn-cxx/util/segment-fetcher.hpp>
 
 #include <queue>
 
 namespace repo {
 
-using std::map;
-using std::pair;
-using std::queue;
-
 /**
  * @brief WriteHandle provides basic credit based congestion control.
  *
@@ -80,12 +77,11 @@
   */
   struct ProcessInfo
   {
-    //ProcessId id;
     RepoCommandResponse response;
-    queue<SegmentNo> nextSegmentQueue;  ///< queue of waiting segment
+    std::queue<SegmentNo> nextSegmentQueue;  ///< queue of waiting segment
                                         ///  to be sent when having credits
     SegmentNo nextSegment;  ///< last segment put into the nextSegmentQueue
-    map<SegmentNo, int> retryCounts;  ///< to store retrying times of timeout segment
+    std::map<SegmentNo, int> retryCounts;  ///< to store retrying times of timeout segment
     int credit;  ///< congestion control credits of process
 
     /**
@@ -136,16 +132,13 @@
    * @brief fetch segmented data
    */
   void
-  onSegmentData(const Interest& interest, const Data& data, ProcessId processId);
-
-  void
-  onSegmentDataValidated(const Interest& interest, const Data& data, ProcessId processId);
+  onSegmentData(ndn::util::SegmentFetcher& fetcher, const Data& data, ProcessId processId);
 
   /**
-   * @brief Timeout when fetching segmented data. Data can be fetched RETRY_TIMEOUT times.
+   * @brief handle when fetching segmented data timeout
    */
   void
-  onSegmentTimeout(const Interest& interest, ProcessId processId);
+  onSegmentTimeout(ndn::util::SegmentFetcher& fetcher, ProcessId processId);
 
   /**
    * @brief initiate fetching segmented data
@@ -153,30 +146,12 @@
   void
   segInit(ProcessId processId, const RepoCommandParameter& parameter);
 
-  /**
-   * @brief control for sending interests in function onSegmentData()
-   */
-  void
-  onSegmentDataControl(ProcessId processId, const Interest& interest);
-
-  /**
-   * @brief control for sending interest in function onSegmentTimeout
-   */
-  void
-  onSegmentTimeoutControl(ProcessId processId, const Interest& interest);
-
   void
   processSegmentedInsertCommand(const Interest& interest, RepoCommandParameter& parameter,
                                 const ndn::mgmt::CommandContinuation& done);
 
 private:
   /**
-   * @brief failure of validation for both one or segmented data
-   */
-  void
-  onDataValidationFailed(const Data& data, const ValidationError& error);
-
-  /**
    * @brief extends noEndTime of process if not noEndTimeout, set StatusCode 405
    *
    * called by onCheckValidated() if there is no EndBlockId. If not noEndTimeout,
@@ -213,9 +188,12 @@
 
 private:
   Validator& m_validator;
-  map<ProcessId, ProcessInfo> m_processes;
-  int m_retryTime;
+
+  std::map<ProcessId, ProcessInfo> m_processes;
+
   int m_credit;
+  bool m_canBePrefix;
+  ndn::time::milliseconds m_maxTimeout;
   ndn::time::milliseconds m_noEndTimeout;
   ndn::time::milliseconds m_interestLifetime;
 };