[public] Move clock interfaces into //src/public/lib

Change-Id: I5948d2f80b6c683df0dda6fc6e58794c792cd440
Reviewed-on: https://fuchsia-review.googlesource.com/c/cobalt/+/495219
Commit-Queue: Zach Bush <zmbush@google.com>
Reviewed-by: Cameron Dale <camrdale@google.com>
diff --git a/src/lib/util/BUILD.gn b/src/lib/util/BUILD.gn
index 2ce7327..bc6969d 100644
--- a/src/lib/util/BUILD.gn
+++ b/src/lib/util/BUILD.gn
@@ -9,6 +9,8 @@
 
 source_set("clock") {
   sources = [ "clock.h" ]
+  public_deps = [ "$cobalt_root/src/public/lib:clock_interfaces" ]
+  public_configs = [ "$cobalt_root:cobalt_config" ]
 
   visibility += [
     "//src/cobalt/bin/utils:clock",
diff --git a/src/lib/util/clock.h b/src/lib/util/clock.h
index 018cc37..7b41237 100644
--- a/src/lib/util/clock.h
+++ b/src/lib/util/clock.h
@@ -12,16 +12,9 @@
 #include <sstream>
 #include <string>
 
-namespace cobalt {
-namespace util {
+#include "src/public/lib/clock_interfaces.h"
 
-// Allows us to mock out a clock for tests.
-class SystemClockInterface {
- public:
-  virtual ~SystemClockInterface() = default;
-
-  virtual std::chrono::system_clock::time_point now() = 0;
-};
+namespace cobalt::util {
 
 // A wrapper around another SystemClockInterface.
 //
@@ -45,13 +38,6 @@
 };
 
 // Allows us to mock out a clock for tests.
-class SteadyClockInterface {
- public:
-  virtual ~SteadyClockInterface() = default;
-
-  virtual std::chrono::steady_clock::time_point now() = 0;
-};
-
 // A clock that returns the real system time.
 class SteadyClock : public SteadyClockInterface {
  public:
@@ -111,16 +97,6 @@
   std::function<void(std::chrono::system_clock::time_point)> callback_;
 };
 
-// An abstract interface to a clock that refuses to provide the time if a quality condition is not
-// satisfied; for example, if the clock has not been initialized from a trustworthy source.
-class ValidatedClockInterface {
- public:
-  virtual ~ValidatedClockInterface() = default;
-
-  // Returns the current time if an accurate clock is avaliable or nullopt otherwise.
-  virtual std::optional<std::chrono::system_clock::time_point> now() = 0;
-};
-
 // A clock that returns an incrementing sequence of tics each time it is called.
 // Optionally a callback may be set that will be invoked each time the
 // clock ticks.
@@ -225,7 +201,6 @@
   std::deque<bool> accurate_sequence_{false};
 };
 
-}  // namespace util
-}  // namespace cobalt
+}  // namespace cobalt::util
 
 #endif  // COBALT_SRC_LIB_UTIL_CLOCK_H_
diff --git a/src/public/lib/BUILD.gn b/src/public/lib/BUILD.gn
index b9fe0da..56cf459 100644
--- a/src/public/lib/BUILD.gn
+++ b/src/public/lib/BUILD.gn
@@ -5,3 +5,7 @@
     "$cobalt_root/src/lib/util:status",
   ]
 }
+
+source_set("clock_interfaces") {
+  sources = [ "clock_interfaces.h" ]
+}
diff --git a/src/public/lib/clock_interfaces.h b/src/public/lib/clock_interfaces.h
new file mode 100644
index 0000000..e957320
--- /dev/null
+++ b/src/public/lib/clock_interfaces.h
@@ -0,0 +1,45 @@
+// Copyright 2017 The Fuchsia Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef COBALT_SRC_PUBLIC_LIB_CLOCK_INTERFACES_H_
+#define COBALT_SRC_PUBLIC_LIB_CLOCK_INTERFACES_H_
+
+#include <chrono>
+#include <iomanip>
+#include <optional>
+#include <queue>
+#include <sstream>
+#include <string>
+
+namespace cobalt::util {
+
+// Allows us to mock out a clock for tests.
+class SystemClockInterface {
+ public:
+  virtual ~SystemClockInterface() = default;
+
+  virtual std::chrono::system_clock::time_point now() = 0;
+};
+
+// Allows us to mock out a clock for tests.
+class SteadyClockInterface {
+ public:
+  virtual ~SteadyClockInterface() = default;
+
+  virtual std::chrono::steady_clock::time_point now() = 0;
+};
+
+// An abstract interface to a clock that refuses to provide the time if a quality condition is not
+// satisfied; for example, if the clock has not been initialized from a trustworthy source.
+class ValidatedClockInterface {
+ public:
+  virtual ~ValidatedClockInterface() = default;
+
+  // Returns the current time if an accurate clock is avaliable or nullopt otherwise.
+  virtual std::optional<std::chrono::system_clock::time_point> now() = 0;
+};
+
+}  // namespace cobalt::util
+
+#endif  // COBALT_SRC_PUBLIC_LIB_CLOCK_INTERFACES_H_