core: set FreshnessPeriod on segment publisher Data

refs #2438

Change-Id: Ibf46dad33b0483f0716bbfef6697d73cc00a117b
diff --git a/core/segment-publisher.hpp b/core/segment-publisher.hpp
index ccb3426..d79586d 100644
--- a/core/segment-publisher.hpp
+++ b/core/segment-publisher.hpp
@@ -1,12 +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,
- *                      The University of Memphis
+ * 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.
@@ -40,10 +40,14 @@
 class SegmentPublisher : noncopyable
 {
 public:
-  SegmentPublisher(FaceBase& face, const Name& prefix, ndn::KeyChain& keyChain)
+  SegmentPublisher(FaceBase& face,
+                   const Name& prefix,
+                   ndn::KeyChain& keyChain,
+                   const time::milliseconds& freshnessPeriod = getDefaultFreshness())
     : m_face(face)
     , m_prefix(prefix)
     , m_keyChain(keyChain)
+    , m_freshnessPeriod(freshnessPeriod)
   {
   }
 
@@ -59,6 +63,12 @@
     return MAX_SEGMENT_SIZE;
   }
 
+  static constexpr time::milliseconds
+  getDefaultFreshness()
+  {
+    return time::milliseconds(1000);
+  }
+
   void
   publish()
   {
@@ -84,6 +94,7 @@
 
       shared_ptr<Data> data = make_shared<Data>(segmentName);
       data->setContent(segmentBegin, segmentEnd - segmentBegin);
+      data->setFreshnessPeriod(m_freshnessPeriod);
 
       segmentBegin = segmentEnd;
       if (segmentBegin >= end) {
@@ -113,6 +124,7 @@
   FaceBase& m_face;
   const Name m_prefix;
   ndn::KeyChain& m_keyChain;
+  const time::milliseconds m_freshnessPeriod;
 };
 
 } // namespace nfd