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

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

Issue 2132623002: Landing Recent QUIC changes until 2016-07-02 02:45 UTC (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Removing comment about RPCs Created 4 years, 5 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
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_chromium_alarm_factory.h" 5 #include "net/quic/quic_chromium_alarm_factory.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/location.h" 8 #include "base/location.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/metrics/sparse_histogram.h" 10 #include "base/metrics/sparse_histogram.h"
(...skipping 23 matching lines...) Expand all
34 // Since tasks can not be un-posted, OnAlarm will be invoked which 34 // Since tasks can not be un-posted, OnAlarm will be invoked which
35 // will notice that deadline has not yet been reached, and will set 35 // will notice that deadline has not yet been reached, and will set
36 // the alarm for the new deadline. 36 // the alarm for the new deadline.
37 return; 37 return;
38 } 38 }
39 // The scheduled task is after new deadline. Invalidate the weak ptrs 39 // The scheduled task is after new deadline. Invalidate the weak ptrs
40 // so that task does not execute when we're not expecting it. 40 // so that task does not execute when we're not expecting it.
41 weak_factory_.InvalidateWeakPtrs(); 41 weak_factory_.InvalidateWeakPtrs();
42 } 42 }
43 43
44 int64_t delay_us = deadline().Subtract(clock_->Now()).ToMicroseconds(); 44 int64_t delay_us = (deadline() - (clock_->Now())).ToMicroseconds();
45 if (delay_us < 0) { 45 if (delay_us < 0) {
46 delay_us = 0; 46 delay_us = 0;
47 } 47 }
48 task_runner_->PostDelayedTask( 48 task_runner_->PostDelayedTask(
49 FROM_HERE, 49 FROM_HERE,
50 base::Bind(&QuicChromeAlarm::OnAlarm, weak_factory_.GetWeakPtr()), 50 base::Bind(&QuicChromeAlarm::OnAlarm, weak_factory_.GetWeakPtr()),
51 base::TimeDelta::FromMicroseconds(delay_us)); 51 base::TimeDelta::FromMicroseconds(delay_us));
52 task_deadline_ = deadline(); 52 task_deadline_ = deadline();
53 } 53 }
54 54
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 } 108 }
109 } 109 }
110 110
111 QuicAlarm* QuicChromiumAlarmFactory::CreateAlarm( 111 QuicAlarm* QuicChromiumAlarmFactory::CreateAlarm(
112 QuicAlarm::Delegate* delegate) { 112 QuicAlarm::Delegate* delegate) {
113 return new QuicChromeAlarm(clock_, task_runner_, 113 return new QuicChromeAlarm(clock_, task_runner_,
114 QuicArenaScopedPtr<QuicAlarm::Delegate>(delegate)); 114 QuicArenaScopedPtr<QuicAlarm::Delegate>(delegate));
115 } 115 }
116 116
117 } // namespace net 117 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/quic_buffered_packet_store_test.cc ('k') | net/quic/quic_chromium_alarm_factory_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698