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

Side by Side Diff: net/tools/quic/quic_simple_server.cc

Issue 1908103002: Landing Recent QUIC changes until 4/15/2016 17:20 UTC (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix Created 4 years, 8 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/tools/quic/quic_simple_server.h ('k') | net/tools/quic/quic_simple_server_session_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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/tools/quic/quic_simple_server.h" 5 #include "net/tools/quic/quic_simple_server.h"
6 6
7 #include <string.h> 7 #include <string.h>
8 8
9 #include "base/location.h" 9 #include "base/location.h"
10 #include "base/single_thread_task_runner.h" 10 #include "base/single_thread_task_runner.h"
(...skipping 18 matching lines...) Expand all
29 29
30 // Allocate some extra space so we can send an error if the client goes over 30 // Allocate some extra space so we can send an error if the client goes over
31 // the limit. 31 // the limit.
32 const int kReadBufferSize = 2 * kMaxPacketSize; 32 const int kReadBufferSize = 2 * kMaxPacketSize;
33 33
34 class SimpleQuicDispatcher : public QuicDispatcher { 34 class SimpleQuicDispatcher : public QuicDispatcher {
35 public: 35 public:
36 SimpleQuicDispatcher(const QuicConfig& config, 36 SimpleQuicDispatcher(const QuicConfig& config,
37 const QuicCryptoServerConfig* crypto_config, 37 const QuicCryptoServerConfig* crypto_config,
38 const QuicVersionVector& supported_versions, 38 const QuicVersionVector& supported_versions,
39 QuicConnectionHelperInterface* helper) 39 QuicConnectionHelperInterface* helper,
40 : QuicDispatcher(config, crypto_config, supported_versions, helper) {} 40 QuicAlarmFactory* alarm_factory)
41 : QuicDispatcher(config,
42 crypto_config,
43 supported_versions,
44 std::unique_ptr<QuicConnectionHelperInterface>(helper),
45 std::unique_ptr<QuicAlarmFactory>(alarm_factory)) {}
41 46
42 protected: 47 protected:
43 QuicServerSessionBase* CreateQuicSession( 48 QuicServerSessionBase* CreateQuicSession(
44 QuicConnectionId connection_id, 49 QuicConnectionId connection_id,
45 const IPEndPoint& client_address) override { 50 const IPEndPoint& client_address) override {
46 QuicServerSessionBase* session = 51 QuicServerSessionBase* session =
47 QuicDispatcher::CreateQuicSession(connection_id, client_address); 52 QuicDispatcher::CreateQuicSession(connection_id, client_address);
48 static_cast<QuicSimplePerConnectionPacketWriter*>( 53 static_cast<QuicSimplePerConnectionPacketWriter*>(
49 session->connection()->writer()) 54 session->connection()->writer())
50 ->set_connection(session->connection()); 55 ->set_connection(session->connection());
51 return session; 56 return session;
52 } 57 }
53 58
54 QuicPacketWriter* CreatePerConnectionWriter() override { 59 QuicPacketWriter* CreatePerConnectionWriter() override {
55 return new QuicSimplePerConnectionPacketWriter( 60 return new QuicSimplePerConnectionPacketWriter(
56 static_cast<QuicSimpleServerPacketWriter*>(writer())); 61 static_cast<QuicSimpleServerPacketWriter*>(writer()));
57 } 62 }
58 }; 63 };
59 64
60 } // namespace 65 } // namespace
61 66
62 QuicSimpleServer::QuicSimpleServer(ProofSource* proof_source, 67 QuicSimpleServer::QuicSimpleServer(ProofSource* proof_source,
63 const QuicConfig& config, 68 const QuicConfig& config,
64 const QuicVersionVector& supported_versions) 69 const QuicVersionVector& supported_versions)
65 : helper_( 70 : helper_(
66 new QuicChromiumConnectionHelper(base::ThreadTaskRunnerHandle::Get() 71 new QuicChromiumConnectionHelper(&clock_, QuicRandom::GetInstance())),
67 .get(), 72 alarm_factory_(new QuicChromiumAlarmFactory(
68 &clock_, 73 base::ThreadTaskRunnerHandle::Get().get(),
69 QuicRandom::GetInstance())), 74 &clock_)),
70 config_(config), 75 config_(config),
71 crypto_config_(kSourceAddressTokenSecret, 76 crypto_config_(kSourceAddressTokenSecret,
72 QuicRandom::GetInstance(), 77 QuicRandom::GetInstance(),
73 proof_source), 78 proof_source),
74 supported_versions_(supported_versions), 79 supported_versions_(supported_versions),
75 read_pending_(false), 80 read_pending_(false),
76 synchronous_read_count_(0), 81 synchronous_read_count_(0),
77 read_buffer_(new IOBufferWithSize(kReadBufferSize)), 82 read_buffer_(new IOBufferWithSize(kReadBufferSize)),
78 weak_factory_(this) { 83 weak_factory_(this) {
79 Initialize(); 84 Initialize();
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 rc = socket->GetLocalAddress(&server_address_); 142 rc = socket->GetLocalAddress(&server_address_);
138 if (rc < 0) { 143 if (rc < 0) {
139 LOG(ERROR) << "GetLocalAddress() failed: " << ErrorToString(rc); 144 LOG(ERROR) << "GetLocalAddress() failed: " << ErrorToString(rc);
140 return rc; 145 return rc;
141 } 146 }
142 147
143 DVLOG(1) << "Listening on " << server_address_.ToString(); 148 DVLOG(1) << "Listening on " << server_address_.ToString();
144 149
145 socket_.swap(socket); 150 socket_.swap(socket);
146 151
147 dispatcher_.reset(new SimpleQuicDispatcher(config_, &crypto_config_, 152 dispatcher_.reset(new SimpleQuicDispatcher(
148 supported_versions_, helper_)); 153 config_, &crypto_config_, supported_versions_, helper_, alarm_factory_));
149 QuicSimpleServerPacketWriter* writer = 154 QuicSimpleServerPacketWriter* writer =
150 new QuicSimpleServerPacketWriter(socket_.get(), dispatcher_.get()); 155 new QuicSimpleServerPacketWriter(socket_.get(), dispatcher_.get());
151 dispatcher_->InitializeWithWriter(writer); 156 dispatcher_->InitializeWithWriter(writer);
152 157
153 StartReading(); 158 StartReading();
154 159
155 return OK; 160 return OK;
156 } 161 }
157 162
158 void QuicSimpleServer::Shutdown() { 163 void QuicSimpleServer::Shutdown() {
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 } 208 }
204 209
205 QuicReceivedPacket packet(read_buffer_->data(), result, 210 QuicReceivedPacket packet(read_buffer_->data(), result,
206 helper_->GetClock()->Now(), false); 211 helper_->GetClock()->Now(), false);
207 dispatcher_->ProcessPacket(server_address_, client_address_, packet); 212 dispatcher_->ProcessPacket(server_address_, client_address_, packet);
208 213
209 StartReading(); 214 StartReading();
210 } 215 }
211 216
212 } // namespace net 217 } // namespace net
OLDNEW
« no previous file with comments | « net/tools/quic/quic_simple_server.h ('k') | net/tools/quic/quic_simple_server_session_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698