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

Side by Side Diff: base/time.h

Issue 10536061: Add Javascript time methods to base::Time. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 6 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 | « no previous file | base/time.cc » ('j') | base/time.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 // 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
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 time_t ToTimeT() const; 259 time_t ToTimeT() const;
260 260
261 // Converts time to/from a double which is the number of seconds since epoch 261 // Converts time to/from a double which is the number of seconds since epoch
262 // (Jan 1, 1970). Webkit uses this format to represent time. 262 // (Jan 1, 1970). Webkit uses this format to represent time.
263 // Because WebKit initializes double time value to 0 to indicate "not 263 // Because WebKit initializes double time value to 0 to indicate "not
264 // initialized", we map it to empty Time object that also means "not 264 // initialized", we map it to empty Time object that also means "not
265 // initialized". 265 // initialized".
266 static Time FromDoubleT(double dt); 266 static Time FromDoubleT(double dt);
267 double ToDoubleT() const; 267 double ToDoubleT() const;
268 268
269 // Converts to/from the Javascript convention for times, a number of
270 // milliseconds since the epoch:
271 // https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Date/g etTime.
272 static Time FromJsTime(double ms_since_epoch);
273 double ToJsTime() const;
274
269 #if defined(OS_POSIX) 275 #if defined(OS_POSIX)
270 struct timeval ToTimeVal() const; 276 struct timeval ToTimeVal() const;
271 #endif 277 #endif
272 278
273 #if defined(OS_WIN) 279 #if defined(OS_WIN)
274 static Time FromFileTime(FILETIME ft); 280 static Time FromFileTime(FILETIME ft);
275 FILETIME ToFileTime() const; 281 FILETIME ToFileTime() const;
276 282
277 // The minimum time of a low resolution timer. This is basically a windows 283 // The minimum time of a low resolution timer. This is basically a windows
278 // constant of ~15.6ms. While it does vary on some older OS versions, we'll 284 // constant of ~15.6ms. While it does vary on some older OS versions, we'll
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after
582 #endif 588 #endif
583 }; 589 };
584 590
585 inline TimeTicks TimeDelta::operator+(TimeTicks t) const { 591 inline TimeTicks TimeDelta::operator+(TimeTicks t) const {
586 return TimeTicks(t.ticks_ + delta_); 592 return TimeTicks(t.ticks_ + delta_);
587 } 593 }
588 594
589 } // namespace base 595 } // namespace base
590 596
591 #endif // BASE_TIME_H_ 597 #endif // BASE_TIME_H_
OLDNEW
« no previous file with comments | « no previous file | base/time.cc » ('j') | base/time.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698