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

Side by Side Diff: base/time_mac.cc

Issue 11453012: Fix black background when locking with fullscreen window: (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Tune animation timings Created 8 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 <CoreFoundation/CFDate.h> 7 #include <CoreFoundation/CFDate.h>
8 #include <CoreFoundation/CFTimeZone.h> 8 #include <CoreFoundation/CFTimeZone.h>
9 #include <mach/mach_time.h> 9 #include <mach/mach_time.h>
10 #include <sys/time.h> 10 #include <sys/time.h>
(...skipping 29 matching lines...) Expand all
40 const int64 Time::kWindowsEpochDeltaMicroseconds = 40 const int64 Time::kWindowsEpochDeltaMicroseconds =
41 kWindowsEpochDeltaSeconds * Time::kMicrosecondsPerSecond; 41 kWindowsEpochDeltaSeconds * Time::kMicrosecondsPerSecond;
42 42
43 // Some functions in time.cc use time_t directly, so we provide an offset 43 // Some functions in time.cc use time_t directly, so we provide an offset
44 // to convert from time_t (Unix epoch) and internal (Windows epoch). 44 // to convert from time_t (Unix epoch) and internal (Windows epoch).
45 // static 45 // static
46 const int64 Time::kTimeTToMicrosecondsOffset = kWindowsEpochDeltaMicroseconds; 46 const int64 Time::kTimeTToMicrosecondsOffset = kWindowsEpochDeltaMicroseconds;
47 47
48 // static 48 // static
49 Time Time::Now() { 49 Time Time::Now() {
50 if (TimeFactory::instance())
51 return TimeFactory::instance()->TimeNow();
50 return FromCFAbsoluteTime(CFAbsoluteTimeGetCurrent()); 52 return FromCFAbsoluteTime(CFAbsoluteTimeGetCurrent());
51 } 53 }
52 54
53 // static 55 // static
54 Time Time::FromCFAbsoluteTime(CFAbsoluteTime t) { 56 Time Time::FromCFAbsoluteTime(CFAbsoluteTime t) {
55 if (t == 0) 57 if (t == 0)
56 return Time(); // Consider 0 as a null Time. 58 return Time(); // Consider 0 as a null Time.
57 if (t == std::numeric_limits<CFAbsoluteTime>::max()) 59 if (t == std::numeric_limits<CFAbsoluteTime>::max())
58 return Max(); 60 return Max();
59 return Time(static_cast<int64>( 61 return Time(static_cast<int64>(
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 exploded->millisecond = 126 exploded->millisecond =
125 (microsecond >= 0) ? microsecond / kMicrosecondsPerMillisecond : 127 (microsecond >= 0) ? microsecond / kMicrosecondsPerMillisecond :
126 (microsecond - kMicrosecondsPerMillisecond + 1) / 128 (microsecond - kMicrosecondsPerMillisecond + 1) /
127 kMicrosecondsPerMillisecond; 129 kMicrosecondsPerMillisecond;
128 } 130 }
129 131
130 // TimeTicks ------------------------------------------------------------------ 132 // TimeTicks ------------------------------------------------------------------
131 133
132 // static 134 // static
133 TimeTicks TimeTicks::Now() { 135 TimeTicks TimeTicks::Now() {
136 if (TimeFactory::instance())
137 return TimeFactory::instance()->TimeTicksNow();
138
134 uint64_t absolute_micro; 139 uint64_t absolute_micro;
135 140
136 static mach_timebase_info_data_t timebase_info; 141 static mach_timebase_info_data_t timebase_info;
137 if (timebase_info.denom == 0) { 142 if (timebase_info.denom == 0) {
138 // Zero-initialization of statics guarantees that denom will be 0 before 143 // Zero-initialization of statics guarantees that denom will be 0 before
139 // calling mach_timebase_info. mach_timebase_info will never set denom to 144 // calling mach_timebase_info. mach_timebase_info will never set denom to
140 // 0 as that would be invalid, so the zero-check can be used to determine 145 // 0 as that would be invalid, so the zero-check can be used to determine
141 // whether mach_timebase_info has already been called. This is 146 // whether mach_timebase_info has already been called. This is
142 // recommended by Apple's QA1398. 147 // recommended by Apple's QA1398.
143 kern_return_t kr = mach_timebase_info(&timebase_info); 148 kern_return_t kr = mach_timebase_info(&timebase_info);
(...skipping 11 matching lines...) Expand all
155 160
156 // Don't bother with the rollover handling that the Windows version does. 161 // Don't bother with the rollover handling that the Windows version does.
157 // With numer and denom = 1 (the expected case), the 64-bit absolute time 162 // With numer and denom = 1 (the expected case), the 64-bit absolute time
158 // reported in nanoseconds is enough to last nearly 585 years. 163 // reported in nanoseconds is enough to last nearly 585 years.
159 164
160 return TimeTicks(absolute_micro); 165 return TimeTicks(absolute_micro);
161 } 166 }
162 167
163 // static 168 // static
164 TimeTicks TimeTicks::HighResNow() { 169 TimeTicks TimeTicks::HighResNow() {
170 if (TimeFactory::instance())
171 return TimeFactory::instance()->TimeTicksHighResNow();
165 return Now(); 172 return Now();
166 } 173 }
167 174
168 // static 175 // static
169 TimeTicks TimeTicks::NowFromSystemTraceTime() { 176 TimeTicks TimeTicks::NowFromSystemTraceTime() {
170 return HighResNow(); 177 return HighResNow();
171 } 178 }
172 179
173 } // namespace base 180 } // namespace base
OLDNEW
« base/time.cc ('K') | « base/time.cc ('k') | base/time_posix.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698