Add a presentation URL availability listener
This class will be used by the Controller implementation in the
Presentation API. It works by tracking the set of urls being observed
on all known screens. It uses the watch part of the availability
protocol to keep the availability up-to-date as long as the observers
are registered.
Change-Id: Ib5b5069530f52e1cc6e40c504bdda4c6868fcaec
Reviewed-on: https://chromium-review.googlesource.com/c/1382649
Commit-Queue: Brandon Tolsch <btolsch@chromium.org>
Reviewed-by: Peter Thatcher <pthatcher@chromium.org>
diff --git a/platform/api/time.h b/platform/api/time.h
index bfbd90b..34c0628 100644
--- a/platform/api/time.h
+++ b/platform/api/time.h
@@ -12,6 +12,9 @@
class TimeDelta {
public:
+ constexpr static TimeDelta FromSeconds(int64_t sec) {
+ return TimeDelta(sec * 1000000);
+ }
constexpr static TimeDelta FromMilliseconds(int64_t msec) {
return TimeDelta(msec * 1000);
}
@@ -23,12 +26,25 @@
constexpr int64_t AsMilliseconds() const { return microseconds_ / 1000; }
constexpr int64_t AsMicroseconds() const { return microseconds_; }
+ constexpr TimeDelta& operator-=(TimeDelta t) {
+ microseconds_ -= t.microseconds_;
+ return *this;
+ }
+
+ constexpr TimeDelta& operator+=(TimeDelta t) {
+ microseconds_ += t.microseconds_;
+ return *this;
+ }
+
private:
constexpr explicit TimeDelta(int64_t usec) : microseconds_(usec) {}
friend constexpr TimeDelta operator-(TimeDelta t1, TimeDelta t2) {
return TimeDelta(t1.microseconds_ - t2.microseconds_);
}
+ friend constexpr TimeDelta operator+(TimeDelta t1, TimeDelta t2) {
+ return TimeDelta(t1.microseconds_ + t2.microseconds_);
+ }
friend constexpr bool operator<(TimeDelta t1, TimeDelta t2) {
return t1.microseconds_ < t2.microseconds_;
}