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

Side by Side Diff: base/time.h

Issue 7461141: Rename BASE_API to BASE_EXPORT. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 4 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 | « base/threading/worker_pool_posix.h ('k') | base/timer.h » ('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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 // Time represents an absolute point in time, internally represented as 5 // Time represents an absolute point in time, internally represented as
6 // microseconds (s/1,000,000) since a platform-dependent epoch. Each 6 // microseconds (s/1,000,000) since a platform-dependent epoch. Each
7 // platform's epoch, along with other system-dependent clock interface 7 // platform's epoch, along with other system-dependent clock interface
8 // routines, is defined in time_PLATFORM.cc. 8 // routines, is defined in time_PLATFORM.cc.
9 // 9 //
10 // TimeDelta represents a duration of time, internally represented in 10 // TimeDelta represents a duration of time, internally represented in
11 // microseconds. 11 // microseconds.
12 // 12 //
13 // TimeTicks represents an abstract time that is always incrementing for use 13 // TimeTicks represents an abstract time that is always incrementing for use
14 // in measuring time durations. It is internally represented in microseconds. 14 // in measuring time durations. It is internally represented in microseconds.
15 // It can not be converted to a human-readable time, but is guaranteed not to 15 // It can not be converted to a human-readable time, but is guaranteed not to
16 // decrease (if the user changes the computer clock, Time::Now() may actually 16 // decrease (if the user changes the computer clock, Time::Now() may actually
17 // decrease or jump). 17 // decrease or jump).
18 // 18 //
19 // These classes are represented as only a 64-bit value, so they can be 19 // These classes are represented as only a 64-bit value, so they can be
20 // efficiently passed by value. 20 // efficiently passed by value.
21 21
22 #ifndef BASE_TIME_H_ 22 #ifndef BASE_TIME_H_
23 #define BASE_TIME_H_ 23 #define BASE_TIME_H_
24 #pragma once 24 #pragma once
25 25
26 #include <time.h> 26 #include <time.h>
27 27
28 #include "base/atomicops.h" 28 #include "base/atomicops.h"
29 #include "base/base_api.h" 29 #include "base/base_export.h"
30 #include "base/basictypes.h" 30 #include "base/basictypes.h"
31 31
32 #if defined(OS_POSIX) 32 #if defined(OS_POSIX)
33 // For struct timeval. 33 // For struct timeval.
34 #include <sys/time.h> 34 #include <sys/time.h>
35 #endif 35 #endif
36 36
37 #if defined(OS_WIN) 37 #if defined(OS_WIN)
38 // For FILETIME in FromFileTime, until it moves to a new converter class. 38 // For FILETIME in FromFileTime, until it moves to a new converter class.
39 // See TODO(iyengar) below. 39 // See TODO(iyengar) below.
40 #include <windows.h> 40 #include <windows.h>
41 #endif 41 #endif
42 42
43 namespace base { 43 namespace base {
44 44
45 class Time; 45 class Time;
46 class TimeTicks; 46 class TimeTicks;
47 47
48 // TimeDelta ------------------------------------------------------------------ 48 // TimeDelta ------------------------------------------------------------------
49 49
50 class BASE_API TimeDelta { 50 class BASE_EXPORT TimeDelta {
51 public: 51 public:
52 TimeDelta() : delta_(0) { 52 TimeDelta() : delta_(0) {
53 } 53 }
54 54
55 // Converts units of time to TimeDeltas. 55 // Converts units of time to TimeDeltas.
56 static TimeDelta FromDays(int64 days); 56 static TimeDelta FromDays(int64 days);
57 static TimeDelta FromHours(int64 hours); 57 static TimeDelta FromHours(int64 hours);
58 static TimeDelta FromMinutes(int64 minutes); 58 static TimeDelta FromMinutes(int64 minutes);
59 static TimeDelta FromSeconds(int64 secs); 59 static TimeDelta FromSeconds(int64 secs);
60 static TimeDelta FromMilliseconds(int64 ms); 60 static TimeDelta FromMilliseconds(int64 ms);
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 int64 delta_; 170 int64 delta_;
171 }; 171 };
172 172
173 inline TimeDelta operator*(int64 a, TimeDelta td) { 173 inline TimeDelta operator*(int64 a, TimeDelta td) {
174 return TimeDelta(a * td.delta_); 174 return TimeDelta(a * td.delta_);
175 } 175 }
176 176
177 // Time ----------------------------------------------------------------------- 177 // Time -----------------------------------------------------------------------
178 178
179 // Represents a wall clock time. 179 // Represents a wall clock time.
180 class BASE_API Time { 180 class BASE_EXPORT Time {
181 public: 181 public:
182 static const int64 kMillisecondsPerSecond = 1000; 182 static const int64 kMillisecondsPerSecond = 1000;
183 static const int64 kMicrosecondsPerMillisecond = 1000; 183 static const int64 kMicrosecondsPerMillisecond = 1000;
184 static const int64 kMicrosecondsPerSecond = kMicrosecondsPerMillisecond * 184 static const int64 kMicrosecondsPerSecond = kMicrosecondsPerMillisecond *
185 kMillisecondsPerSecond; 185 kMillisecondsPerSecond;
186 static const int64 kMicrosecondsPerMinute = kMicrosecondsPerSecond * 60; 186 static const int64 kMicrosecondsPerMinute = kMicrosecondsPerSecond * 60;
187 static const int64 kMicrosecondsPerHour = kMicrosecondsPerMinute * 60; 187 static const int64 kMicrosecondsPerHour = kMicrosecondsPerMinute * 60;
188 static const int64 kMicrosecondsPerDay = kMicrosecondsPerHour * 24; 188 static const int64 kMicrosecondsPerDay = kMicrosecondsPerHour * 24;
189 static const int64 kMicrosecondsPerWeek = kMicrosecondsPerDay * 7; 189 static const int64 kMicrosecondsPerWeek = kMicrosecondsPerDay * 7;
190 static const int64 kNanosecondsPerMicrosecond = 1000; 190 static const int64 kNanosecondsPerMicrosecond = 1000;
191 static const int64 kNanosecondsPerSecond = kNanosecondsPerMicrosecond * 191 static const int64 kNanosecondsPerSecond = kNanosecondsPerMicrosecond *
192 kMicrosecondsPerSecond; 192 kMicrosecondsPerSecond;
193 193
194 #if !defined(OS_WIN) 194 #if !defined(OS_WIN)
195 // On Mac & Linux, this value is the delta from the Windows epoch of 1601 to 195 // On Mac & Linux, this value is the delta from the Windows epoch of 1601 to
196 // the Posix delta of 1970. This is used for migrating between the old 196 // the Posix delta of 1970. This is used for migrating between the old
197 // 1970-based epochs to the new 1601-based ones. It should be removed from 197 // 1970-based epochs to the new 1601-based ones. It should be removed from
198 // this global header and put in the platform-specific ones when we remove the 198 // this global header and put in the platform-specific ones when we remove the
199 // migration code. 199 // migration code.
200 static const int64 kWindowsEpochDeltaMicroseconds; 200 static const int64 kWindowsEpochDeltaMicroseconds;
201 #endif 201 #endif
202 202
203 // Represents an exploded time that can be formatted nicely. This is kind of 203 // Represents an exploded time that can be formatted nicely. This is kind of
204 // like the Win32 SYSTEMTIME structure or the Unix "struct tm" with a few 204 // like the Win32 SYSTEMTIME structure or the Unix "struct tm" with a few
205 // additions and changes to prevent errors. 205 // additions and changes to prevent errors.
206 struct BASE_API Exploded { 206 struct BASE_EXPORT Exploded {
207 int year; // Four digit year "2007" 207 int year; // Four digit year "2007"
208 int month; // 1-based month (values 1 = January, etc.) 208 int month; // 1-based month (values 1 = January, etc.)
209 int day_of_week; // 0-based day of week (0 = Sunday, etc.) 209 int day_of_week; // 0-based day of week (0 = Sunday, etc.)
210 int day_of_month; // 1-based day of month (1-31) 210 int day_of_month; // 1-based day of month (1-31)
211 int hour; // Hour within the current day (0-23) 211 int hour; // Hour within the current day (0-23)
212 int minute; // Minute within the current hour (0-59) 212 int minute; // Minute within the current hour (0-59)
213 int second; // Second within the current minute (0-59 plus leap 213 int second; // Second within the current minute (0-59 plus leap
214 // seconds which may take it up to 60). 214 // seconds which may take it up to 60).
215 int millisecond; // Milliseconds within the current second (0-999) 215 int millisecond; // Milliseconds within the current second (0-999)
216 216
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
450 inline TimeDelta TimeDelta::FromMicroseconds(int64 us) { 450 inline TimeDelta TimeDelta::FromMicroseconds(int64 us) {
451 return TimeDelta(us); 451 return TimeDelta(us);
452 } 452 }
453 453
454 inline Time TimeDelta::operator+(Time t) const { 454 inline Time TimeDelta::operator+(Time t) const {
455 return Time(t.us_ + delta_); 455 return Time(t.us_ + delta_);
456 } 456 }
457 457
458 // TimeTicks ------------------------------------------------------------------ 458 // TimeTicks ------------------------------------------------------------------
459 459
460 class BASE_API TimeTicks { 460 class BASE_EXPORT TimeTicks {
461 public: 461 public:
462 TimeTicks() : ticks_(0) { 462 TimeTicks() : ticks_(0) {
463 } 463 }
464 464
465 // Platform-dependent tick count representing "right now." 465 // Platform-dependent tick count representing "right now."
466 // The resolution of this clock is ~1-15ms. Resolution varies depending 466 // The resolution of this clock is ~1-15ms. Resolution varies depending
467 // on hardware/operating system configuration. 467 // on hardware/operating system configuration.
468 static TimeTicks Now(); 468 static TimeTicks Now();
469 469
470 // Returns a platform-dependent high-resolution tick count. Implementation 470 // Returns a platform-dependent high-resolution tick count. Implementation
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
557 #endif 557 #endif
558 }; 558 };
559 559
560 inline TimeTicks TimeDelta::operator+(TimeTicks t) const { 560 inline TimeTicks TimeDelta::operator+(TimeTicks t) const {
561 return TimeTicks(t.ticks_ + delta_); 561 return TimeTicks(t.ticks_ + delta_);
562 } 562 }
563 563
564 } // namespace base 564 } // namespace base
565 565
566 #endif // BASE_TIME_H_ 566 #endif // BASE_TIME_H_
OLDNEW
« no previous file with comments | « base/threading/worker_pool_posix.h ('k') | base/timer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698