/*
 *  Copyright (c) 2015, Facebook, Inc.
 *  All rights reserved.
 *
 *  This source code is licensed under the BSD-style license found in the
 *  LICENSE file in the root directory of this source tree. An additional grant
 *  of patent rights can be found in the PATENTS file in the same directory.
 *
 */
#pragma once

#include <glog/logging.h>
#include <proxygen/lib/utils/Time.h>

namespace proxygen {

template <typename ClockType = std::chrono::steady_clock>
class MockTimeUtilGeneric : public TimeUtilGeneric<ClockType> {
 public:

  void advance(std::chrono::milliseconds ms) {
    t_ += ms;
  }

  void setCurrentTime(std::chrono::time_point<ClockType> t) {
    CHECK(t.time_since_epoch() > t_.time_since_epoch())
      << "Time can not move backwards";
    t_ = t;
  }

  void verifyAndClear() {
  }

  std::chrono::time_point<ClockType> now() const override {
    return t_;
  }

 private:
  std::chrono::time_point<ClockType> t_;
};

using MockTimeUtil = MockTimeUtilGeneric<>;

}

/*
 *  Copyright (c) 2015, Facebook, Inc.
 *  All rights reserved.
 *
 *  This source code is licensed under the BSD-style license found in the
 *  LICENSE file in the root directory of this source tree. An additional grant
 *  of patent rights can be found in the PATENTS file in the same directory.
 *
 */
#pragma once

#include <glog/logging.h>
#include <proxygen/lib/utils/Time.h>

namespace proxygen {

class MockTimeUtil : public TimeUtil {
 public:

  void advance(std::chrono::milliseconds ms) {
    t_ += ms;
  }

  void setCurrentTime(TimePoint t) {
    CHECK(t.time_since_epoch() > t_.time_since_epoch())
      << "Time can not move backwards";
    t_ = t;
  }

  void verifyAndClear() {
  }

  TimePoint now() const override {
    return t_;
  }

 private:
  TimePoint t_;
};

}

--- 
+++ 
@@ -14,14 +14,15 @@
 
 namespace proxygen {
 
-class MockTimeUtil : public TimeUtil {
+template <typename ClockType = std::chrono::steady_clock>
+class MockTimeUtilGeneric : public TimeUtilGeneric<ClockType> {
  public:
 
   void advance(std::chrono::milliseconds ms) {
     t_ += ms;
   }
 
-  void setCurrentTime(TimePoint t) {
+  void setCurrentTime(std::chrono::time_point<ClockType> t) {
     CHECK(t.time_since_epoch() > t_.time_since_epoch())
       << "Time can not move backwards";
     t_ = t;
@@ -30,12 +31,14 @@
   void verifyAndClear() {
   }
 
-  TimePoint now() const override {
+  std::chrono::time_point<ClockType> now() const override {
     return t_;
   }
 
  private:
-  TimePoint t_;
+  std::chrono::time_point<ClockType> t_;
 };
 
+using MockTimeUtil = MockTimeUtilGeneric<>;
+
 }
Expire cached TLS session tickets using tlsext_tick_lifetime_hint

Summary:
Our current TLS cache in liger does not respect timeout hints. We should
start doing that because it will limit certain kinds of attacks if an
attacker gets access to a master key.

Test Plan: Added new test in SSLSessionPersistentCacheTest to test expiration

Reviewed By: subodh@fb.com

Subscribers: bmatheny, seanc, yfeldblum, devonharris

FB internal diff: D2299744

Tasks: 7633098

Signature: t1:2299744:1439331830:9d0770149e49b6094ca61bac4e1e4ef16938c4dc
