Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(413)

Unified Diff: runtime/bin/utils_win.cc

Issue 12280004: Moved GetCurrentTime functions from bin/eventhandler to bin/utils. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/bin/utils_macos.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/utils_win.cc
===================================================================
--- runtime/bin/utils_win.cc (revision 18591)
+++ runtime/bin/utils_win.cc (working copy)
@@ -3,6 +3,7 @@
// BSD-style license that can be found in the LICENSE file.
#include <errno.h>
+#include <time.h>
#include "bin/utils.h"
#include "bin/log.h"
@@ -113,3 +114,26 @@
void ShellUtils::FreeUnicodeArgv(wchar_t** argv) {
LocalFree(argv);
}
+
+int64_t OS::GetCurrentTimeMillis() {
+ return GetCurrentTimeMicros() / 1000;
+}
+
+int64_t OS::GetCurrentTimeMicros() {
+ static const int64_t kTimeEpoc = 116444736000000000LL;
+ static const int64_t kTimeScaler = 10; // 100 ns to us.
+
+ // Although win32 uses 64-bit integers for representing timestamps,
+ // these are packed into a FILETIME structure. The FILETIME
+ // structure is just a struct representing a 64-bit integer. The
+ // TimeStamp union allows access to both a FILETIME and an integer
+ // representation of the timestamp. The Windows timestamp is in
+ // 100-nanosecond intervals since January 1, 1601.
+ union TimeStamp {
+ FILETIME ft_;
+ int64_t t_;
+ };
+ TimeStamp time;
+ GetSystemTimeAsFileTime(&time.ft_);
+ return (time.t_ - kTimeEpoc) / kTimeScaler;
+}
« no previous file with comments | « runtime/bin/utils_macos.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698