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

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

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
« no previous file with comments | « net/quic/quic_time.h ('k') | net/quic/quic_time_test.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) 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 #include "net/quic/quic_time.h" 5 #include "net/quic/quic_time.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 8
9 namespace net { 9 namespace net {
10 10
11 // Highest number of microseconds that DateTimeOffset can hold. 11 // Highest number of microseconds that DateTimeOffset can hold.
12 const int64 kQuicInfiniteTimeUs = GG_INT64_C(0x7fffffffffffffff) / 10; 12 const int64 kQuicInfiniteTimeUs = GG_INT64_C(0x7fffffffffffffff) / 10;
13 13
14 QuicTime::Delta::Delta() 14 QuicTime::Delta::Delta(base::TimeDelta delta_)
jar (doing other things) 2013/01/17 01:50:33 nit: use an arg name without the trailing undersco
Ryan Hamilton 2013/01/17 18:44:18 Done.
15 : delta_(base::TimeDelta::FromMicroseconds(0)) { 15 : delta_(delta_) {
16 } 16 }
17 17
18 QuicTime::Delta::Delta(base::TimeDelta delta) 18 QuicTime::Delta QuicTime::Delta::Zero() {
19 : delta_(delta) { 19 return QuicTime::Delta::FromMicroseconds(0);
20 } 20 }
21 21
22 QuicTime::Delta QuicTime::Delta::Infinite() { 22 QuicTime::Delta QuicTime::Delta::Infinite() {
23 return QuicTime::Delta::FromMicroseconds(kQuicInfiniteTimeUs); 23 return QuicTime::Delta::FromMicroseconds(kQuicInfiniteTimeUs);
24 } 24 }
25 25
26 bool QuicTime::Delta::IsZero() const { 26 bool QuicTime::Delta::IsZero() const {
27 return delta_.InMicroseconds() == 0; 27 return delta_.InMicroseconds() == 0;
28 } 28 }
29 29
(...skipping 24 matching lines...) Expand all
54 QuicTime::Delta QuicTime::Delta::Add(const Delta& delta) const { 54 QuicTime::Delta QuicTime::Delta::Add(const Delta& delta) const {
55 return QuicTime::Delta::FromMicroseconds(ToMicroseconds() + 55 return QuicTime::Delta::FromMicroseconds(ToMicroseconds() +
56 delta.ToMicroseconds()); 56 delta.ToMicroseconds());
57 } 57 }
58 58
59 QuicTime::Delta QuicTime::Delta::Subtract(const Delta& delta) const { 59 QuicTime::Delta QuicTime::Delta::Subtract(const Delta& delta) const {
60 return QuicTime::Delta::FromMicroseconds(ToMicroseconds() - 60 return QuicTime::Delta::FromMicroseconds(ToMicroseconds() -
61 delta.ToMicroseconds()); 61 delta.ToMicroseconds());
62 } 62 }
63 63
64 64 // static
65 QuicTime::QuicTime() { 65 QuicTime QuicTime::Zero() {
66 return QuicTime::FromMilliseconds(0);
66 } 67 }
67 68
68 QuicTime::QuicTime(base::TimeTicks ticks) 69 QuicTime::QuicTime(base::TimeTicks ticks)
69 : ticks_(ticks) { 70 : ticks_(ticks) {
70 } 71 }
71 72
72 QuicTime QuicTime::FromMilliseconds(int64 time_ms) { 73 QuicTime QuicTime::FromMilliseconds(int64 time_ms) {
73 // DateTime use 100 ns as resolution make sure we don't pass down too high 74 // DateTime use 100 ns as resolution make sure we don't pass down too high
74 // values. 75 // values.
75 DCHECK(time_ms < kQuicInfiniteTimeUs / 1000); 76 DCHECK(time_ms < kQuicInfiniteTimeUs / 1000);
(...skipping 27 matching lines...) Expand all
103 104
104 QuicTime QuicTime::Subtract(const Delta& delta) const { 105 QuicTime QuicTime::Subtract(const Delta& delta) const {
105 return QuicTime(ticks_ - delta.delta_); 106 return QuicTime(ticks_ - delta.delta_);
106 } 107 }
107 108
108 QuicTime::Delta QuicTime::Subtract(const QuicTime& other) const { 109 QuicTime::Delta QuicTime::Subtract(const QuicTime& other) const {
109 return QuicTime::Delta(ticks_ - other.ticks_); 110 return QuicTime::Delta(ticks_ - other.ticks_);
110 } 111 }
111 112
112 } // namespace gfe_quic 113 } // namespace gfe_quic
OLDNEW
« no previous file with comments | « net/quic/quic_time.h ('k') | net/quic/quic_time_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698