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

Side by Side Diff: base/time.cc

Issue 42527: - Added support for keeping track of load times.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 8 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/time.h ('k') | chrome/browser/renderer_host/render_view_host.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 #include "base/string_util.h" 6 #include "base/string_util.h"
7 #include "base/sys_string_conversions.h" 7 #include "base/sys_string_conversions.h"
8 #include "base/third_party/nspr/prtime.h" 8 #include "base/third_party/nspr/prtime.h"
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 return Time(); // Preserve 0 so we can tell it doesn't exist. 53 return Time(); // Preserve 0 so we can tell it doesn't exist.
54 return (tt * kMicrosecondsPerSecond) + kTimeTToMicrosecondsOffset; 54 return (tt * kMicrosecondsPerSecond) + kTimeTToMicrosecondsOffset;
55 } 55 }
56 56
57 time_t Time::ToTimeT() const { 57 time_t Time::ToTimeT() const {
58 if (us_ == 0) 58 if (us_ == 0)
59 return 0; // Preserve 0 so we can tell it doesn't exist. 59 return 0; // Preserve 0 so we can tell it doesn't exist.
60 return (us_ - kTimeTToMicrosecondsOffset) / kMicrosecondsPerSecond; 60 return (us_ - kTimeTToMicrosecondsOffset) / kMicrosecondsPerSecond;
61 } 61 }
62 62
63 // static
64 Time Time::FromDoubleT(double dt) {
65 return (dt * static_cast<double>(kMicrosecondsPerSecond)) +
66 kTimeTToMicrosecondsOffset;
67 }
68
63 double Time::ToDoubleT() const { 69 double Time::ToDoubleT() const {
64 if (us_ == 0) 70 if (us_ == 0)
65 return 0; // Preserve 0 so we can tell it doesn't exist. 71 return 0; // Preserve 0 so we can tell it doesn't exist.
66 return (static_cast<double>(us_ - kTimeTToMicrosecondsOffset) / 72 return (static_cast<double>(us_ - kTimeTToMicrosecondsOffset) /
67 static_cast<double>(kMicrosecondsPerSecond)); 73 static_cast<double>(kMicrosecondsPerSecond));
68 } 74 }
69 75
70 Time Time::LocalMidnight() const { 76 Time Time::LocalMidnight() const {
71 Exploded exploded; 77 Exploded exploded;
72 LocalExplode(&exploded); 78 LocalExplode(&exploded);
(...skipping 14 matching lines...) Expand all
87 PRStatus result = PR_ParseTimeString(ascii_time_string.c_str(), PR_FALSE, 93 PRStatus result = PR_ParseTimeString(ascii_time_string.c_str(), PR_FALSE,
88 &result_time); 94 &result_time);
89 if (PR_SUCCESS != result) 95 if (PR_SUCCESS != result)
90 return false; 96 return false;
91 result_time += kTimeTToMicrosecondsOffset; 97 result_time += kTimeTToMicrosecondsOffset;
92 *parsed_time = Time(result_time); 98 *parsed_time = Time(result_time);
93 return true; 99 return true;
94 } 100 }
95 101
96 } // namespace base 102 } // namespace base
OLDNEW
« no previous file with comments | « base/time.h ('k') | chrome/browser/renderer_host/render_view_host.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698