OLD | NEW |
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_connection_helper.h" | 5 #include "net/quic/quic_connection_helper.h" |
6 | 6 |
7 #include "base/location.h" | 7 #include "base/location.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/metrics/sparse_histogram.h" | 9 #include "base/metrics/sparse_histogram.h" |
10 #include "base/task_runner.h" | 10 #include "base/task_runner.h" |
(...skipping 25 matching lines...) Expand all Loading... |
36 // Since tasks can not be un-posted, OnAlarm will be invoked which | 36 // Since tasks can not be un-posted, OnAlarm will be invoked which |
37 // will notice that deadline has not yet been reached, and will set | 37 // will notice that deadline has not yet been reached, and will set |
38 // the alarm for the new deadline. | 38 // the alarm for the new deadline. |
39 return; | 39 return; |
40 } | 40 } |
41 // The scheduled task is after new deadline. Invalidate the weak ptrs | 41 // The scheduled task is after new deadline. Invalidate the weak ptrs |
42 // so that task does not execute when we're not expecting it. | 42 // so that task does not execute when we're not expecting it. |
43 weak_factory_.InvalidateWeakPtrs(); | 43 weak_factory_.InvalidateWeakPtrs(); |
44 } | 44 } |
45 | 45 |
46 int64 delay_us = deadline().Subtract(clock_->Now()).ToMicroseconds(); | 46 int64_t delay_us = deadline().Subtract(clock_->Now()).ToMicroseconds(); |
47 if (delay_us < 0) { | 47 if (delay_us < 0) { |
48 delay_us = 0; | 48 delay_us = 0; |
49 } | 49 } |
50 task_runner_->PostDelayedTask( | 50 task_runner_->PostDelayedTask( |
51 FROM_HERE, | 51 FROM_HERE, |
52 base::Bind(&QuicChromeAlarm::OnAlarm, weak_factory_.GetWeakPtr()), | 52 base::Bind(&QuicChromeAlarm::OnAlarm, weak_factory_.GetWeakPtr()), |
53 base::TimeDelta::FromMicroseconds(delay_us)); | 53 base::TimeDelta::FromMicroseconds(delay_us)); |
54 task_deadline_ = deadline(); | 54 task_deadline_ = deadline(); |
55 } | 55 } |
56 | 56 |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 | 107 |
108 QuicRandom* QuicConnectionHelper::GetRandomGenerator() { | 108 QuicRandom* QuicConnectionHelper::GetRandomGenerator() { |
109 return random_generator_; | 109 return random_generator_; |
110 } | 110 } |
111 | 111 |
112 QuicAlarm* QuicConnectionHelper::CreateAlarm(QuicAlarm::Delegate* delegate) { | 112 QuicAlarm* QuicConnectionHelper::CreateAlarm(QuicAlarm::Delegate* delegate) { |
113 return new QuicChromeAlarm(clock_, task_runner_, delegate); | 113 return new QuicChromeAlarm(clock_, task_runner_, delegate); |
114 } | 114 } |
115 | 115 |
116 } // namespace net | 116 } // namespace net |
OLD | NEW |