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

Side by Side Diff: base/time.h

Issue 17802: Inline the TimeDelta::From* construction functions. (Closed)
Patch Set: Created 11 years, 11 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
« no previous file with comments | « no previous file | base/time.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 // 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 324 matching lines...) Expand 10 before | Expand all | Expand 10 after
335 static const int64 kTimeTToMicrosecondsOffset; 335 static const int64 kTimeTToMicrosecondsOffset;
336 336
337 // Time in microseconds in UTC. 337 // Time in microseconds in UTC.
338 int64 us_; 338 int64 us_;
339 }; 339 };
340 340
341 inline Time TimeDelta::operator+(Time t) const { 341 inline Time TimeDelta::operator+(Time t) const {
342 return Time(t.us_ + delta_); 342 return Time(t.us_ + delta_);
343 } 343 }
344 344
345 // Inline the TimeDelta factory methods, for fast TimeDelta construction.
346
347 // static
348 inline TimeDelta TimeDelta::FromDays(int64 days) {
349 return TimeDelta(days * Time::kMicrosecondsPerDay);
350 }
351
352 // static
353 inline TimeDelta TimeDelta::FromHours(int64 hours) {
354 return TimeDelta(hours * Time::kMicrosecondsPerHour);
355 }
356
357 // static
358 inline TimeDelta TimeDelta::FromMinutes(int64 minutes) {
359 return TimeDelta(minutes * Time::kMicrosecondsPerMinute);
360 }
361
362 // static
363 inline TimeDelta TimeDelta::FromSeconds(int64 secs) {
364 return TimeDelta(secs * Time::kMicrosecondsPerSecond);
365 }
366
367 // static
368 inline TimeDelta TimeDelta::FromMilliseconds(int64 ms) {
369 return TimeDelta(ms * Time::kMicrosecondsPerMillisecond);
370 }
371
372 // static
373 inline TimeDelta TimeDelta::FromMicroseconds(int64 us) {
374 return TimeDelta(us);
375 }
376
345 // TimeTicks ------------------------------------------------------------------ 377 // TimeTicks ------------------------------------------------------------------
346 378
347 class TimeTicks { 379 class TimeTicks {
348 public: 380 public:
349 TimeTicks() : ticks_(0) { 381 TimeTicks() : ticks_(0) {
350 } 382 }
351 383
352 // Platform-dependent tick count representing "right now." 384 // Platform-dependent tick count representing "right now."
353 // The resolution of this clock is ~1-15ms. Resolution varies depending 385 // The resolution of this clock is ~1-15ms. Resolution varies depending
354 // on hardware/operating system configuration. 386 // on hardware/operating system configuration.
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
436 #endif 468 #endif
437 }; 469 };
438 470
439 inline TimeTicks TimeDelta::operator+(TimeTicks t) const { 471 inline TimeTicks TimeDelta::operator+(TimeTicks t) const {
440 return TimeTicks(t.ticks_ + delta_); 472 return TimeTicks(t.ticks_ + delta_);
441 } 473 }
442 474
443 } // namespace base 475 } // namespace base
444 476
445 #endif // BASE_TIME_H_ 477 #endif // BASE_TIME_H_
OLDNEW
« no previous file with comments | « no previous file | base/time.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698