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

Side by Side Diff: base/time_posix.cc

Issue 496007: Make ProcessWatcher use kqueues on Mac. (Closed)
Patch Set: No need for a thread Created 11 years 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
« no previous file with comments | « base/time.h ('k') | base/time_unittest.cc » ('j') | 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) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/time.h" 5 #include "base/time.h"
6 6
7 #include <sys/time.h> 7 #include <sys/time.h>
8 #include <time.h> 8 #include <time.h>
9 9
10 #include <limits> 10 #include <limits>
11 11
12 #include "base/basictypes.h" 12 #include "base/basictypes.h"
13 #include "base/logging.h" 13 #include "base/logging.h"
14 14
15 namespace base { 15 namespace base {
16 16
17 #if !defined(OS_MACOSX)
17 // The Time routines in this file use standard POSIX routines, or almost- 18 // The Time routines in this file use standard POSIX routines, or almost-
18 // standard routines in the case of timegm. We need to use a Mach-specific 19 // standard routines in the case of timegm. We need to use a Mach-specific
19 // function for TimeTicks::Now() on Mac OS X. 20 // function for TimeTicks::Now() on Mac OS X.
20 21
21 // Time ----------------------------------------------------------------------- 22 // Time -----------------------------------------------------------------------
22 23
23 // Windows uses a Gregorian epoch of 1601. We need to match this internally 24 // Windows uses a Gregorian epoch of 1601. We need to match this internally
24 // so that our time representations match across all platforms. See bug 14734. 25 // so that our time representations match across all platforms. See bug 14734.
25 // irb(main):010:0> Time.at(0).getutc() 26 // irb(main):010:0> Time.at(0).getutc()
26 // => Thu Jan 01 00:00:00 UTC 1970 27 // => Thu Jan 01 00:00:00 UTC 1970
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 168
168 #else // _POSIX_MONOTONIC_CLOCK 169 #else // _POSIX_MONOTONIC_CLOCK
169 #error No usable tick clock function on this platform. 170 #error No usable tick clock function on this platform.
170 #endif // _POSIX_MONOTONIC_CLOCK 171 #endif // _POSIX_MONOTONIC_CLOCK
171 172
172 // static 173 // static
173 TimeTicks TimeTicks::HighResNow() { 174 TimeTicks TimeTicks::HighResNow() {
174 return Now(); 175 return Now();
175 } 176 }
176 177
178 #endif // !OS_MACOSX
179
180 struct timespec TimeDelta::ToTimeSpec() const {
181 int64 microseconds = InMicroseconds();
182 time_t seconds = 0;
183 if (microseconds >= Time::kMicrosecondsPerSecond) {
184 seconds = InSeconds();
185 microseconds -= seconds * Time::kMicrosecondsPerSecond;
186 }
187 struct timespec result =
188 {seconds,
189 microseconds * Time::kNanosecondsPerMicrosecond};
190 return result;
191 }
192
177 } // namespace base 193 } // namespace base
OLDNEW
« no previous file with comments | « base/time.h ('k') | base/time_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698