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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/bin/utils_macos.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include <errno.h> 5 #include <errno.h>
6 #include <time.h>
6 7
7 #include "bin/utils.h" 8 #include "bin/utils.h"
8 #include "bin/log.h" 9 #include "bin/log.h"
9 10
10 static void FormatMessageIntoBuffer(DWORD code, 11 static void FormatMessageIntoBuffer(DWORD code,
11 wchar_t* buffer, 12 wchar_t* buffer,
12 int buffer_length) { 13 int buffer_length) {
13 DWORD message_size = 14 DWORD message_size =
14 FormatMessageW(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, 15 FormatMessageW(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
15 NULL, 16 NULL,
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 } 107 }
107 108
108 wchar_t** ShellUtils::GetUnicodeArgv(int* argc) { 109 wchar_t** ShellUtils::GetUnicodeArgv(int* argc) {
109 wchar_t* command_line = GetCommandLineW(); 110 wchar_t* command_line = GetCommandLineW();
110 return CommandLineToArgvW(command_line, argc); 111 return CommandLineToArgvW(command_line, argc);
111 } 112 }
112 113
113 void ShellUtils::FreeUnicodeArgv(wchar_t** argv) { 114 void ShellUtils::FreeUnicodeArgv(wchar_t** argv) {
114 LocalFree(argv); 115 LocalFree(argv);
115 } 116 }
117
118 int64_t OS::GetCurrentTimeMillis() {
119 return GetCurrentTimeMicros() / 1000;
120 }
121
122 int64_t OS::GetCurrentTimeMicros() {
123 static const int64_t kTimeEpoc = 116444736000000000LL;
124 static const int64_t kTimeScaler = 10; // 100 ns to us.
125
126 // Although win32 uses 64-bit integers for representing timestamps,
127 // these are packed into a FILETIME structure. The FILETIME
128 // structure is just a struct representing a 64-bit integer. The
129 // TimeStamp union allows access to both a FILETIME and an integer
130 // representation of the timestamp. The Windows timestamp is in
131 // 100-nanosecond intervals since January 1, 1601.
132 union TimeStamp {
133 FILETIME ft_;
134 int64_t t_;
135 };
136 TimeStamp time;
137 GetSystemTimeAsFileTime(&time.ft_);
138 return (time.t_ - kTimeEpoc) / kTimeScaler;
139 }
OLDNEW
« 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