shill: Add Portal Detection object
Add a utility object that will perform a repeated test of an
HTTP URL and return the result to a callback.
BUG=chromium-os:23318
TEST=New unit tests
Change-Id: I0449dbe51fb1dcef2ecd3bb88de1bcaf2950f749
Reviewed-on: https://gerrit.chromium.org/gerrit/15472
Commit-Ready: Paul Stewart <pstew@chromium.org>
Reviewed-by: Paul Stewart <pstew@chromium.org>
Tested-by: Paul Stewart <pstew@chromium.org>
diff --git a/shill_time.cc b/shill_time.cc
index 7bae785..0c88e41 100644
--- a/shill_time.cc
+++ b/shill_time.cc
@@ -1,9 +1,11 @@
-// Copyright (c) 2011 The Chromium OS Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "shill/shill_time.h"
+#include <time.h>
+
namespace shill {
static base::LazyInstance<Time> g_time(base::LINKER_INITIALIZED);
@@ -16,6 +18,17 @@
return g_time.Pointer();
}
+int Time::GetTimeMonotonic(struct timeval *tv) {
+ struct timespec ts;
+ if (clock_gettime(CLOCK_MONOTONIC, &ts) != 0) {
+ return -1;
+ }
+
+ tv->tv_sec = ts.tv_sec;
+ tv->tv_usec = ts.tv_nsec / 1000;
+ return 0;
+}
+
int Time::GetTimeOfDay(struct timeval *tv, struct timezone *tz) {
return gettimeofday(tv, tz);
}