OLD | NEW |
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 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 Initialize(); | 82 Initialize(); |
83 } | 83 } |
84 | 84 |
85 void QuicSimpleServer::Initialize() { | 85 void QuicSimpleServer::Initialize() { |
86 #if MMSG_MORE | 86 #if MMSG_MORE |
87 use_recvmmsg_ = true; | 87 use_recvmmsg_ = true; |
88 #endif | 88 #endif |
89 | 89 |
90 // If an initial flow control window has not explicitly been set, then use a | 90 // If an initial flow control window has not explicitly been set, then use a |
91 // sensible value for a server: 1 MB for session, 64 KB for each stream. | 91 // sensible value for a server: 1 MB for session, 64 KB for each stream. |
92 const uint32 kInitialSessionFlowControlWindow = 1 * 1024 * 1024; // 1 MB | 92 const uint32_t kInitialSessionFlowControlWindow = 1 * 1024 * 1024; // 1 MB |
93 const uint32 kInitialStreamFlowControlWindow = 64 * 1024; // 64 KB | 93 const uint32_t kInitialStreamFlowControlWindow = 64 * 1024; // 64 KB |
94 if (config_.GetInitialStreamFlowControlWindowToSend() == | 94 if (config_.GetInitialStreamFlowControlWindowToSend() == |
95 kMinimumFlowControlSendWindow) { | 95 kMinimumFlowControlSendWindow) { |
96 config_.SetInitialStreamFlowControlWindowToSend( | 96 config_.SetInitialStreamFlowControlWindowToSend( |
97 kInitialStreamFlowControlWindow); | 97 kInitialStreamFlowControlWindow); |
98 } | 98 } |
99 if (config_.GetInitialSessionFlowControlWindowToSend() == | 99 if (config_.GetInitialSessionFlowControlWindowToSend() == |
100 kMinimumFlowControlSendWindow) { | 100 kMinimumFlowControlSendWindow) { |
101 config_.SetInitialSessionFlowControlWindowToSend( | 101 config_.SetInitialSessionFlowControlWindowToSend( |
102 kInitialSessionFlowControlWindow); | 102 kInitialSessionFlowControlWindow); |
103 } | 103 } |
(...skipping 14 matching lines...) Expand all Loading... |
118 int rc = socket->Listen(address); | 118 int rc = socket->Listen(address); |
119 if (rc < 0) { | 119 if (rc < 0) { |
120 LOG(ERROR) << "Listen() failed: " << ErrorToString(rc); | 120 LOG(ERROR) << "Listen() failed: " << ErrorToString(rc); |
121 return rc; | 121 return rc; |
122 } | 122 } |
123 | 123 |
124 // These send and receive buffer sizes are sized for a single connection, | 124 // These send and receive buffer sizes are sized for a single connection, |
125 // because the default usage of QuicSimpleServer is as a test server with | 125 // because the default usage of QuicSimpleServer is as a test server with |
126 // one or two clients. Adjust higher for use with many clients. | 126 // one or two clients. Adjust higher for use with many clients. |
127 rc = socket->SetReceiveBufferSize( | 127 rc = socket->SetReceiveBufferSize( |
128 static_cast<int32>(kDefaultSocketReceiveBuffer)); | 128 static_cast<int32_t>(kDefaultSocketReceiveBuffer)); |
129 if (rc < 0) { | 129 if (rc < 0) { |
130 LOG(ERROR) << "SetReceiveBufferSize() failed: " << ErrorToString(rc); | 130 LOG(ERROR) << "SetReceiveBufferSize() failed: " << ErrorToString(rc); |
131 return rc; | 131 return rc; |
132 } | 132 } |
133 | 133 |
134 rc = socket->SetSendBufferSize(20 * kMaxPacketSize); | 134 rc = socket->SetSendBufferSize(20 * kMaxPacketSize); |
135 if (rc < 0) { | 135 if (rc < 0) { |
136 LOG(ERROR) << "SetSendBufferSize() failed: " << ErrorToString(rc); | 136 LOG(ERROR) << "SetSendBufferSize() failed: " << ErrorToString(rc); |
137 return rc; | 137 return rc; |
138 } | 138 } |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
208 } | 208 } |
209 | 209 |
210 QuicEncryptedPacket packet(read_buffer_->data(), result, false); | 210 QuicEncryptedPacket packet(read_buffer_->data(), result, false); |
211 dispatcher_->ProcessPacket(server_address_, client_address_, packet); | 211 dispatcher_->ProcessPacket(server_address_, client_address_, packet); |
212 | 212 |
213 StartReading(); | 213 StartReading(); |
214 } | 214 } |
215 | 215 |
216 } // namespace tools | 216 } // namespace tools |
217 } // namespace net | 217 } // namespace net |
OLD | NEW |