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

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

Issue 1572353002: QuicAlarms are now allocated out of an arena in QuicConnection (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Merge recent changes. Created 4 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
« no previous file with comments | « net/quic/quic_chromium_connection_helper.h ('k') | net/quic/quic_connection.h » ('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_chromium_connection_helper.h" 5 #include "net/quic/quic_chromium_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"
11 #include "base/time/time.h" 11 #include "base/time/time.h"
12 #include "net/base/io_buffer.h" 12 #include "net/base/io_buffer.h"
13 #include "net/base/net_errors.h" 13 #include "net/base/net_errors.h"
14 #include "net/quic/quic_utils.h" 14 #include "net/quic/quic_utils.h"
15 15
16 namespace net { 16 namespace net {
17 17
18 namespace { 18 namespace {
19 19
20 class QuicChromeAlarm : public QuicAlarm { 20 class QuicChromeAlarm : public QuicAlarm {
21 public: 21 public:
22 QuicChromeAlarm(const QuicClock* clock, 22 QuicChromeAlarm(const QuicClock* clock,
23 base::TaskRunner* task_runner, 23 base::TaskRunner* task_runner,
24 QuicAlarm::Delegate* delegate) 24 QuicArenaScopedPtr<QuicAlarm::Delegate> delegate)
25 : QuicAlarm(delegate), 25 : QuicAlarm(std::move(delegate)),
26 clock_(clock), 26 clock_(clock),
27 task_runner_(task_runner), 27 task_runner_(task_runner),
28 task_deadline_(QuicTime::Zero()), 28 task_deadline_(QuicTime::Zero()),
29 weak_factory_(this) {} 29 weak_factory_(this) {}
30 30
31 protected: 31 protected:
32 void SetImpl() override { 32 void SetImpl() override {
33 DCHECK(deadline().IsInitialized()); 33 DCHECK(deadline().IsInitialized());
34 if (task_deadline_.IsInitialized()) { 34 if (task_deadline_.IsInitialized()) {
35 if (task_deadline_ <= deadline()) { 35 if (task_deadline_ <= deadline()) {
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 QuicChromiumConnectionHelper::~QuicChromiumConnectionHelper() {} 103 QuicChromiumConnectionHelper::~QuicChromiumConnectionHelper() {}
104 104
105 const QuicClock* QuicChromiumConnectionHelper::GetClock() const { 105 const QuicClock* QuicChromiumConnectionHelper::GetClock() const {
106 return clock_; 106 return clock_;
107 } 107 }
108 108
109 QuicRandom* QuicChromiumConnectionHelper::GetRandomGenerator() { 109 QuicRandom* QuicChromiumConnectionHelper::GetRandomGenerator() {
110 return random_generator_; 110 return random_generator_;
111 } 111 }
112 112
113 QuicArenaScopedPtr<QuicAlarm> QuicChromiumConnectionHelper::CreateAlarm(
114 QuicArenaScopedPtr<QuicAlarm::Delegate> delegate,
115 QuicConnectionArena* arena) {
116 if (arena != nullptr) {
117 return arena->New<QuicChromeAlarm>(clock_, task_runner_,
118 std::move(delegate));
119 } else {
120 return QuicArenaScopedPtr<QuicAlarm>(
121 new QuicChromeAlarm(clock_, task_runner_, std::move(delegate)));
122 }
123 }
124
113 QuicAlarm* QuicChromiumConnectionHelper::CreateAlarm( 125 QuicAlarm* QuicChromiumConnectionHelper::CreateAlarm(
114 QuicAlarm::Delegate* delegate) { 126 QuicAlarm::Delegate* delegate) {
115 return new QuicChromeAlarm(clock_, task_runner_, delegate); 127 return new QuicChromeAlarm(clock_, task_runner_,
128 QuicArenaScopedPtr<QuicAlarm::Delegate>(delegate));
116 } 129 }
117 130
118 QuicBufferAllocator* QuicChromiumConnectionHelper::GetBufferAllocator() { 131 QuicBufferAllocator* QuicChromiumConnectionHelper::GetBufferAllocator() {
119 return &buffer_allocator_; 132 return &buffer_allocator_;
120 } 133 }
121 134
122 } // namespace net 135 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/quic_chromium_connection_helper.h ('k') | net/quic/quic_connection.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698