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

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

Issue 2547583002: Landing Recent QUIC changes until Fri Nov 18 23:21:04 2016 +0000 (Closed)
Patch Set: Remove explicit HTTP/2 enum usage Created 4 years 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_bin.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"
11 #include "base/threading/thread_task_runner_handle.h" 11 #include "base/threading/thread_task_runner_handle.h"
12 #include "net/base/ip_endpoint.h" 12 #include "net/base/ip_endpoint.h"
13 #include "net/base/net_errors.h" 13 #include "net/base/net_errors.h"
14 #include "net/log/net_log_source.h" 14 #include "net/log/net_log_source.h"
15 #include "net/quic/core/crypto/crypto_handshake.h" 15 #include "net/quic/core/crypto/crypto_handshake.h"
16 #include "net/quic/core/crypto/quic_random.h" 16 #include "net/quic/core/crypto/quic_random.h"
17 #include "net/quic/core/quic_crypto_stream.h" 17 #include "net/quic/core/quic_crypto_stream.h"
18 #include "net/quic/core/quic_data_reader.h" 18 #include "net/quic/core/quic_data_reader.h"
19 #include "net/quic/core/quic_protocol.h" 19 #include "net/quic/core/quic_packets.h"
20 #include "net/socket/udp_server_socket.h" 20 #include "net/socket/udp_server_socket.h"
21 #include "net/tools/quic/quic_simple_dispatcher.h" 21 #include "net/tools/quic/quic_simple_dispatcher.h"
22 #include "net/tools/quic/quic_simple_per_connection_packet_writer.h" 22 #include "net/tools/quic/quic_simple_per_connection_packet_writer.h"
23 #include "net/tools/quic/quic_simple_server_packet_writer.h" 23 #include "net/tools/quic/quic_simple_server_packet_writer.h"
24 #include "net/tools/quic/quic_simple_server_session_helper.h" 24 #include "net/tools/quic/quic_simple_server_session_helper.h"
25 25
26 namespace net { 26 namespace net {
27 27
28 namespace { 28 namespace {
29 29
30 const char kSourceAddressTokenSecret[] = "secret"; 30 const char kSourceAddressTokenSecret[] = "secret";
31 const size_t kNumSessionsToCreatePerSocketEvent = 16; 31 const size_t kNumSessionsToCreatePerSocketEvent = 16;
32 32
33 // Allocate some extra space so we can send an error if the client goes over 33 // Allocate some extra space so we can send an error if the client goes over
34 // the limit. 34 // the limit.
35 const int kReadBufferSize = 2 * kMaxPacketSize; 35 const int kReadBufferSize = 2 * kMaxPacketSize;
36 36
37 } // namespace 37 } // namespace
38 38
39 QuicSimpleServer::QuicSimpleServer( 39 QuicSimpleServer::QuicSimpleServer(
40 std::unique_ptr<ProofSource> proof_source, 40 std::unique_ptr<ProofSource> proof_source,
41 const QuicConfig& config, 41 const QuicConfig& config,
42 const QuicCryptoServerConfig::ConfigOptions& crypto_config_options, 42 const QuicCryptoServerConfig::ConfigOptions& crypto_config_options,
43 const QuicVersionVector& supported_versions, 43 const QuicVersionVector& supported_versions,
44 QuicInMemoryCache* in_memory_cache) 44 QuicHttpResponseCache* response_cache)
45 : version_manager_(supported_versions), 45 : version_manager_(supported_versions),
46 helper_( 46 helper_(
47 new QuicChromiumConnectionHelper(&clock_, QuicRandom::GetInstance())), 47 new QuicChromiumConnectionHelper(&clock_, QuicRandom::GetInstance())),
48 alarm_factory_(new QuicChromiumAlarmFactory( 48 alarm_factory_(new QuicChromiumAlarmFactory(
49 base::ThreadTaskRunnerHandle::Get().get(), 49 base::ThreadTaskRunnerHandle::Get().get(),
50 &clock_)), 50 &clock_)),
51 config_(config), 51 config_(config),
52 crypto_config_options_(crypto_config_options), 52 crypto_config_options_(crypto_config_options),
53 crypto_config_(kSourceAddressTokenSecret, 53 crypto_config_(kSourceAddressTokenSecret,
54 QuicRandom::GetInstance(), 54 QuicRandom::GetInstance(),
55 std::move(proof_source)), 55 std::move(proof_source)),
56 read_pending_(false), 56 read_pending_(false),
57 synchronous_read_count_(0), 57 synchronous_read_count_(0),
58 read_buffer_(new IOBufferWithSize(kReadBufferSize)), 58 read_buffer_(new IOBufferWithSize(kReadBufferSize)),
59 in_memory_cache_(in_memory_cache), 59 response_cache_(response_cache),
60 weak_factory_(this) { 60 weak_factory_(this) {
61 Initialize(); 61 Initialize();
62 } 62 }
63 63
64 void QuicSimpleServer::Initialize() { 64 void QuicSimpleServer::Initialize() {
65 #if MMSG_MORE 65 #if MMSG_MORE
66 use_recvmmsg_ = true; 66 use_recvmmsg_ = true;
67 #endif 67 #endif
68 68
69 // If an initial flow control window has not explicitly been set, then use a 69 // If an initial flow control window has not explicitly been set, then use a
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 124
125 DVLOG(1) << "Listening on " << server_address_.ToString(); 125 DVLOG(1) << "Listening on " << server_address_.ToString();
126 126
127 socket_.swap(socket); 127 socket_.swap(socket);
128 128
129 dispatcher_.reset(new QuicSimpleDispatcher( 129 dispatcher_.reset(new QuicSimpleDispatcher(
130 config_, &crypto_config_, &version_manager_, 130 config_, &crypto_config_, &version_manager_,
131 std::unique_ptr<QuicConnectionHelperInterface>(helper_), 131 std::unique_ptr<QuicConnectionHelperInterface>(helper_),
132 std::unique_ptr<QuicCryptoServerStream::Helper>( 132 std::unique_ptr<QuicCryptoServerStream::Helper>(
133 new QuicSimpleServerSessionHelper(QuicRandom::GetInstance())), 133 new QuicSimpleServerSessionHelper(QuicRandom::GetInstance())),
134 std::unique_ptr<QuicAlarmFactory>(alarm_factory_), in_memory_cache_)); 134 std::unique_ptr<QuicAlarmFactory>(alarm_factory_), response_cache_));
135 QuicSimpleServerPacketWriter* writer = 135 QuicSimpleServerPacketWriter* writer =
136 new QuicSimpleServerPacketWriter(socket_.get(), dispatcher_.get()); 136 new QuicSimpleServerPacketWriter(socket_.get(), dispatcher_.get());
137 dispatcher_->InitializeWithWriter(writer); 137 dispatcher_->InitializeWithWriter(writer);
138 138
139 StartReading(); 139 StartReading();
140 140
141 return OK; 141 return OK;
142 } 142 }
143 143
144 void QuicSimpleServer::Shutdown() { 144 void QuicSimpleServer::Shutdown() {
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 QuicReceivedPacket packet(read_buffer_->data(), result, 202 QuicReceivedPacket packet(read_buffer_->data(), result,
203 helper_->GetClock()->Now(), false); 203 helper_->GetClock()->Now(), false);
204 dispatcher_->ProcessPacket( 204 dispatcher_->ProcessPacket(
205 QuicSocketAddress(QuicSocketAddressImpl(server_address_)), 205 QuicSocketAddress(QuicSocketAddressImpl(server_address_)),
206 QuicSocketAddress(QuicSocketAddressImpl(client_address_)), packet); 206 QuicSocketAddress(QuicSocketAddressImpl(client_address_)), packet);
207 207
208 StartReading(); 208 StartReading();
209 } 209 }
210 210
211 } // namespace net 211 } // namespace net
OLDNEW
« no previous file with comments | « net/tools/quic/quic_simple_server.h ('k') | net/tools/quic/quic_simple_server_bin.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698