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

Side by Side Diff: net/quic/quic_time.h

Issue 11961022: Remove default constructors for QuicTime and QuicTime::Delta and used static Zero() methods instead… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 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 | Annotate | Revision Log
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 // QuicTime represents one point in time, stored in microsecond resolution. 5 // QuicTime represents one point in time, stored in microsecond resolution.
6 // QuicTime is monotonically increasing, even across system clock adjustments. 6 // QuicTime is monotonically increasing, even across system clock adjustments.
7 // The epoch (time 0) of QuicTime is unspecified. 7 // The epoch (time 0) of QuicTime is unspecified.
8 // 8 //
9 // This implementation wraps the classes base::TimeTicks and base::TimeDelta. 9 // This implementation wraps the classes base::TimeTicks and base::TimeDelta.
10 10
11 #ifndef NET_QUIC_QUIC_TIME_H_ 11 #ifndef NET_QUIC_QUIC_TIME_H_
12 #define NET_QUIC_QUIC_TIME_H_ 12 #define NET_QUIC_QUIC_TIME_H_
13 13
14 #include "base/basictypes.h" 14 #include "base/basictypes.h"
15 #include "base/time.h" 15 #include "base/time.h"
16 #include "net/base/net_export.h" 16 #include "net/base/net_export.h"
17 17
18 namespace net { 18 namespace net {
19 19
20 class NET_EXPORT_PRIVATE QuicTime { 20 class NET_EXPORT_PRIVATE QuicTime {
21 public: 21 public:
22 // A QuicTime::Delta represents the signed difference between two points in 22 // A QuicTime::Delta represents the signed difference between two points in
23 // time, stored in microsecond resolution. 23 // time, stored in microsecond resolution.
24 class NET_EXPORT_PRIVATE Delta { 24 class NET_EXPORT_PRIVATE Delta {
25 public: 25 public:
26 // Default constructor initializes to 0.
27 Delta();
28
29 explicit Delta(base::TimeDelta delta); 26 explicit Delta(base::TimeDelta delta);
30 27
31 // Create a object with infinite offset time. 28 // Create a object with infinite offset time.
32 static Delta Infinite(); 29 static Delta Infinite();
33 30
31 // Create a object with infinite offset time.
32 static Delta Zero();
33
34 // Converts a number of milliseconds to a time offset. 34 // Converts a number of milliseconds to a time offset.
35 static Delta FromMilliseconds(int64 ms); 35 static Delta FromMilliseconds(int64 ms);
36 36
37 // Converts a number of microseconds to a time offset. 37 // Converts a number of microseconds to a time offset.
38 static Delta FromMicroseconds(int64 us); 38 static Delta FromMicroseconds(int64 us);
39 39
40 // Converts the time offset to a rounded number of seconds. 40 // Converts the time offset to a rounded number of seconds.
41 int64 ToSeconds() const; 41 int64 ToSeconds() const;
42 42
43 // Converts the time offset to a rounded number of milliseconds. 43 // Converts the time offset to a rounded number of milliseconds.
44 int64 ToMilliseconds() const; 44 int64 ToMilliseconds() const;
45 45
46 // Converts the time offset to a rounded number of microseconds. 46 // Converts the time offset to a rounded number of microseconds.
47 int64 ToMicroseconds() const; 47 int64 ToMicroseconds() const;
48 48
49 Delta Add(const Delta& delta) const; 49 Delta Add(const Delta& delta) const;
50 50
51 Delta Subtract(const Delta& delta) const; 51 Delta Subtract(const Delta& delta) const;
52 52
53 bool IsZero() const; 53 bool IsZero() const;
54 54
55 bool IsInfinite() const; 55 bool IsInfinite() const;
56 56
57 private: 57 private:
58 base::TimeDelta delta_; 58 base::TimeDelta delta_;
59 59
60 friend class QuicTime; 60 friend class QuicTime;
61 }; 61 };
62 62
63 // Default constructor initializes to time 0. 63 explicit QuicTime(base::TimeTicks ticks);
64 QuicTime();
65 64
66 explicit QuicTime(base::TimeTicks ticks); 65 // Creates a new QuicTime with an internal value of 0. IsInitialized()
66 // will return true for these times.
67 static QuicTime Zero();
67 68
68 // Create a new QuicTime holding the time_ms. 69 // Create a new QuicTime holding the time_ms.
69 static QuicTime FromMilliseconds(int64 time_ms); 70 static QuicTime FromMilliseconds(int64 time_ms);
70 71
71 // Create a new QuicTime holding the time_us. 72 // Create a new QuicTime holding the time_us.
72 static QuicTime FromMicroseconds(int64 time_us); 73 static QuicTime FromMicroseconds(int64 time_us);
73 74
74 int64 ToMilliseconds() const; 75 int64 ToMilliseconds() const;
75 76
76 int64 ToMicroseconds() const; 77 int64 ToMicroseconds() const;
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 inline bool operator<=(QuicTime lhs, QuicTime rhs) { 126 inline bool operator<=(QuicTime lhs, QuicTime rhs) {
126 return !(rhs < lhs); 127 return !(rhs < lhs);
127 } 128 }
128 inline bool operator>=(QuicTime lhs, QuicTime rhs) { 129 inline bool operator>=(QuicTime lhs, QuicTime rhs) {
129 return !(lhs < rhs); 130 return !(lhs < rhs);
130 } 131 }
131 132
132 } // namespace net 133 } // namespace net
133 134
134 #endif // NET_QUIC_QUIC_TIME_H_ 135 #endif // NET_QUIC_QUIC_TIME_H_
OLDNEW
« no previous file with comments | « net/quic/quic_http_stream_test.cc ('k') | net/quic/quic_time.cc » ('j') | net/quic/quic_time.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698