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

Side by Side Diff: net/tools/flip_server/http_interface.cc

Issue 1535363003: Switch to standard integer types in net/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: stddef Created 5 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/flip_server/http_interface.h ('k') | net/tools/flip_server/http_interface_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 (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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/flip_server/http_interface.h" 5 #include "net/tools/flip_server/http_interface.h"
6 6
7 #include "net/tools/balsa/balsa_frame.h" 7 #include "net/tools/balsa/balsa_frame.h"
8 #include "net/tools/flip_server/flip_config.h" 8 #include "net/tools/flip_server/flip_config.h"
9 #include "net/tools/flip_server/sm_connection.h" 9 #include "net/tools/flip_server/sm_connection.h"
10 #include "net/tools/flip_server/spdy_util.h" 10 #include "net/tools/flip_server/spdy_util.h"
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 void HttpSM::HandleBodyError(BalsaFrame* framer) { HandleError(); } 80 void HttpSM::HandleBodyError(BalsaFrame* framer) { HandleError(); }
81 81
82 void HttpSM::HandleError() { 82 void HttpSM::HandleError() {
83 VLOG(1) << ACCEPTOR_CLIENT_IDENT << "Error detected"; 83 VLOG(1) << ACCEPTOR_CLIENT_IDENT << "Error detected";
84 } 84 }
85 85
86 void HttpSM::AddToOutputOrder(const MemCacheIter& mci) { 86 void HttpSM::AddToOutputOrder(const MemCacheIter& mci) {
87 output_ordering_.AddToOutputOrder(mci); 87 output_ordering_.AddToOutputOrder(mci);
88 } 88 }
89 89
90 void HttpSM::InitSMInterface(SMInterface* sm_spdy_interface, int32 server_idx) { 90 void HttpSM::InitSMInterface(SMInterface* sm_spdy_interface,
91 int32_t server_idx) {
91 sm_spdy_interface_ = sm_spdy_interface; 92 sm_spdy_interface_ = sm_spdy_interface;
92 server_idx_ = server_idx; 93 server_idx_ = server_idx;
93 } 94 }
94 95
95 void HttpSM::InitSMConnection(SMConnectionPoolInterface* connection_pool, 96 void HttpSM::InitSMConnection(SMConnectionPoolInterface* connection_pool,
96 SMInterface* sm_interface, 97 SMInterface* sm_interface,
97 EpollServer* epoll_server, 98 EpollServer* epoll_server,
98 int fd, 99 int fd,
99 std::string server_ip, 100 std::string server_ip,
100 std::string server_port, 101 std::string server_port,
(...skipping 27 matching lines...) Expand all
128 data_frame->size = len; 129 data_frame->size = len;
129 data_frame->delete_when_done = true; 130 data_frame->delete_when_done = true;
130 connection_->EnqueueDataFrame(data_frame); 131 connection_->EnqueueDataFrame(data_frame);
131 return len; 132 return len;
132 } 133 }
133 134
134 bool HttpSM::MessageFullyRead() const { 135 bool HttpSM::MessageFullyRead() const {
135 return http_framer_->MessageFullyRead(); 136 return http_framer_->MessageFullyRead();
136 } 137 }
137 138
138 void HttpSM::SetStreamID(uint32 stream_id) { stream_id_ = stream_id; } 139 void HttpSM::SetStreamID(uint32_t stream_id) {
140 stream_id_ = stream_id;
141 }
139 142
140 bool HttpSM::Error() const { return http_framer_->Error(); } 143 bool HttpSM::Error() const { return http_framer_->Error(); }
141 144
142 const char* HttpSM::ErrorAsString() const { 145 const char* HttpSM::ErrorAsString() const {
143 return BalsaFrameEnums::ErrorCodeToString(http_framer_->ErrorCode()); 146 return BalsaFrameEnums::ErrorCodeToString(http_framer_->ErrorCode());
144 } 147 }
145 148
146 void HttpSM::Reset() { 149 void HttpSM::Reset() {
147 VLOG(1) << ACCEPTOR_CLIENT_IDENT << "HttpSM: Reset: stream " << stream_id_; 150 VLOG(1) << ACCEPTOR_CLIENT_IDENT << "HttpSM: Reset: stream " << stream_id_;
148 http_framer_->Reset(); 151 http_framer_->Reset();
(...skipping 21 matching lines...) Expand all
170 173
171 void HttpSM::Cleanup() { 174 void HttpSM::Cleanup() {
172 if (!(acceptor_->flip_handler_type_ == FLIP_HANDLER_HTTP_SERVER)) { 175 if (!(acceptor_->flip_handler_type_ == FLIP_HANDLER_HTTP_SERVER)) {
173 VLOG(2) << "HttpSM Request Fully Read; stream_id: " << stream_id_; 176 VLOG(2) << "HttpSM Request Fully Read; stream_id: " << stream_id_;
174 connection_->Cleanup("request complete"); 177 connection_->Cleanup("request complete");
175 } 178 }
176 } 179 }
177 180
178 int HttpSM::PostAcceptHook() { return 1; } 181 int HttpSM::PostAcceptHook() { return 1; }
179 182
180 void HttpSM::NewStream(uint32 stream_id, 183 void HttpSM::NewStream(uint32_t stream_id,
181 uint32 priority, 184 uint32_t priority,
182 const std::string& filename) { 185 const std::string& filename) {
183 MemCacheIter mci; 186 MemCacheIter mci;
184 mci.stream_id = stream_id; 187 mci.stream_id = stream_id;
185 mci.priority = priority; 188 mci.priority = priority;
186 if (!memory_cache_->AssignFileData(filename, &mci)) { 189 if (!memory_cache_->AssignFileData(filename, &mci)) {
187 // error creating new stream. 190 // error creating new stream.
188 VLOG(2) << ACCEPTOR_CLIENT_IDENT << "Sending ErrorNotFound"; 191 VLOG(2) << ACCEPTOR_CLIENT_IDENT << "Sending ErrorNotFound";
189 SendErrorNotFound(stream_id); 192 SendErrorNotFound(stream_id);
190 } else { 193 } else {
191 AddToOutputOrder(mci); 194 AddToOutputOrder(mci);
192 } 195 }
193 } 196 }
194 197
195 void HttpSM::SendEOF(uint32 stream_id) { 198 void HttpSM::SendEOF(uint32_t stream_id) {
196 SendEOFImpl(stream_id); 199 SendEOFImpl(stream_id);
197 if (acceptor_->flip_handler_type_ == FLIP_HANDLER_PROXY) { 200 if (acceptor_->flip_handler_type_ == FLIP_HANDLER_PROXY) {
198 sm_spdy_interface_->ResetForNewInterface(server_idx_); 201 sm_spdy_interface_->ResetForNewInterface(server_idx_);
199 } 202 }
200 } 203 }
201 204
202 void HttpSM::SendErrorNotFound(uint32 stream_id) { 205 void HttpSM::SendErrorNotFound(uint32_t stream_id) {
203 SendErrorNotFoundImpl(stream_id); 206 SendErrorNotFoundImpl(stream_id);
204 } 207 }
205 208
206 size_t HttpSM::SendSynStream(uint32 stream_id, const BalsaHeaders& headers) { 209 size_t HttpSM::SendSynStream(uint32_t stream_id, const BalsaHeaders& headers) {
207 return 0; 210 return 0;
208 } 211 }
209 212
210 size_t HttpSM::SendSynReply(uint32 stream_id, const BalsaHeaders& headers) { 213 size_t HttpSM::SendSynReply(uint32_t stream_id, const BalsaHeaders& headers) {
211 return SendSynReplyImpl(stream_id, headers); 214 return SendSynReplyImpl(stream_id, headers);
212 } 215 }
213 216
214 void HttpSM::SendDataFrame(uint32 stream_id, 217 void HttpSM::SendDataFrame(uint32_t stream_id,
215 const char* data, 218 const char* data,
216 int64 len, 219 int64_t len,
217 uint32 flags, 220 uint32_t flags,
218 bool compress) { 221 bool compress) {
219 SendDataFrameImpl(stream_id, data, len, flags, compress); 222 SendDataFrameImpl(stream_id, data, len, flags, compress);
220 } 223 }
221 224
222 void HttpSM::SendEOFImpl(uint32 stream_id) { 225 void HttpSM::SendEOFImpl(uint32_t stream_id) {
223 DataFrame* df = new DataFrame; 226 DataFrame* df = new DataFrame;
224 df->data = "0\r\n\r\n"; 227 df->data = "0\r\n\r\n";
225 df->size = 5; 228 df->size = 5;
226 df->delete_when_done = false; 229 df->delete_when_done = false;
227 EnqueueDataFrame(df); 230 EnqueueDataFrame(df);
228 if (acceptor_->flip_handler_type_ == FLIP_HANDLER_HTTP_SERVER) { 231 if (acceptor_->flip_handler_type_ == FLIP_HANDLER_HTTP_SERVER) {
229 Reset(); 232 Reset();
230 } 233 }
231 } 234 }
232 235
233 void HttpSM::SendErrorNotFoundImpl(uint32 stream_id) { 236 void HttpSM::SendErrorNotFoundImpl(uint32_t stream_id) {
234 BalsaHeaders my_headers; 237 BalsaHeaders my_headers;
235 my_headers.SetFirstlineFromStringPieces("HTTP/1.1", "404", "Not Found"); 238 my_headers.SetFirstlineFromStringPieces("HTTP/1.1", "404", "Not Found");
236 my_headers.RemoveAllOfHeader("content-length"); 239 my_headers.RemoveAllOfHeader("content-length");
237 my_headers.AppendHeader("transfer-encoding", "chunked"); 240 my_headers.AppendHeader("transfer-encoding", "chunked");
238 SendSynReplyImpl(stream_id, my_headers); 241 SendSynReplyImpl(stream_id, my_headers);
239 SendDataFrame(stream_id, "page not found", 14, 0, false); 242 SendDataFrame(stream_id, "page not found", 14, 0, false);
240 SendEOFImpl(stream_id); 243 SendEOFImpl(stream_id);
241 output_ordering_.RemoveStreamId(stream_id); 244 output_ordering_.RemoveStreamId(stream_id);
242 } 245 }
243 246
244 size_t HttpSM::SendSynReplyImpl(uint32 stream_id, const BalsaHeaders& headers) { 247 size_t HttpSM::SendSynReplyImpl(uint32_t stream_id,
248 const BalsaHeaders& headers) {
245 SimpleBuffer sb; 249 SimpleBuffer sb;
246 headers.WriteHeaderAndEndingToBuffer(&sb); 250 headers.WriteHeaderAndEndingToBuffer(&sb);
247 DataFrame* df = new DataFrame; 251 DataFrame* df = new DataFrame;
248 df->size = sb.ReadableBytes(); 252 df->size = sb.ReadableBytes();
249 char* buffer = new char[df->size]; 253 char* buffer = new char[df->size];
250 df->data = buffer; 254 df->data = buffer;
251 df->delete_when_done = true; 255 df->delete_when_done = true;
252 sb.Read(buffer, df->size); 256 sb.Read(buffer, df->size);
253 VLOG(2) << ACCEPTOR_CLIENT_IDENT << "Sending HTTP Reply header " 257 VLOG(2) << ACCEPTOR_CLIENT_IDENT << "Sending HTTP Reply header "
254 << stream_id_; 258 << stream_id_;
255 size_t df_size = df->size; 259 size_t df_size = df->size;
256 EnqueueDataFrame(df); 260 EnqueueDataFrame(df);
257 return df_size; 261 return df_size;
258 } 262 }
259 263
260 size_t HttpSM::SendSynStreamImpl(uint32 stream_id, 264 size_t HttpSM::SendSynStreamImpl(uint32_t stream_id,
261 const BalsaHeaders& headers) { 265 const BalsaHeaders& headers) {
262 SimpleBuffer sb; 266 SimpleBuffer sb;
263 headers.WriteHeaderAndEndingToBuffer(&sb); 267 headers.WriteHeaderAndEndingToBuffer(&sb);
264 DataFrame* df = new DataFrame; 268 DataFrame* df = new DataFrame;
265 df->size = sb.ReadableBytes(); 269 df->size = sb.ReadableBytes();
266 char* buffer = new char[df->size]; 270 char* buffer = new char[df->size];
267 df->data = buffer; 271 df->data = buffer;
268 df->delete_when_done = true; 272 df->delete_when_done = true;
269 sb.Read(buffer, df->size); 273 sb.Read(buffer, df->size);
270 VLOG(2) << ACCEPTOR_CLIENT_IDENT << "Sending HTTP Reply header " 274 VLOG(2) << ACCEPTOR_CLIENT_IDENT << "Sending HTTP Reply header "
271 << stream_id_; 275 << stream_id_;
272 size_t df_size = df->size; 276 size_t df_size = df->size;
273 EnqueueDataFrame(df); 277 EnqueueDataFrame(df);
274 return df_size; 278 return df_size;
275 } 279 }
276 280
277 void HttpSM::SendDataFrameImpl(uint32 stream_id, 281 void HttpSM::SendDataFrameImpl(uint32_t stream_id,
278 const char* data, 282 const char* data,
279 int64 len, 283 int64_t len,
280 uint32 flags, 284 uint32_t flags,
281 bool compress) { 285 bool compress) {
282 char chunk_buf[128]; 286 char chunk_buf[128];
283 snprintf(chunk_buf, sizeof(chunk_buf), "%x\r\n", (unsigned int)len); 287 snprintf(chunk_buf, sizeof(chunk_buf), "%x\r\n", (unsigned int)len);
284 std::string chunk_description(chunk_buf); 288 std::string chunk_description(chunk_buf);
285 DataFrame* df = new DataFrame; 289 DataFrame* df = new DataFrame;
286 df->size = chunk_description.size() + len + 2; 290 df->size = chunk_description.size() + len + 2;
287 char* buffer = new char[df->size]; 291 char* buffer = new char[df->size];
288 df->data = buffer; 292 df->data = buffer;
289 df->delete_when_done = true; 293 df->delete_when_done = true;
290 memcpy(buffer, chunk_description.data(), chunk_description.size()); 294 memcpy(buffer, chunk_description.data(), chunk_description.size());
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
331 num_to_write, 335 num_to_write,
332 0, 336 0,
333 true); 337 true);
334 VLOG(2) << ACCEPTOR_CLIENT_IDENT << "HttpSM: GetOutput SendDataFrame[" 338 VLOG(2) << ACCEPTOR_CLIENT_IDENT << "HttpSM: GetOutput SendDataFrame["
335 << mci->stream_id << "]: " << num_to_write; 339 << mci->stream_id << "]: " << num_to_write;
336 mci->body_bytes_consumed += num_to_write; 340 mci->body_bytes_consumed += num_to_write;
337 mci->bytes_sent += num_to_write; 341 mci->bytes_sent += num_to_write;
338 } 342 }
339 343
340 } // namespace net 344 } // namespace net
OLDNEW
« no previous file with comments | « net/tools/flip_server/http_interface.h ('k') | net/tools/flip_server/http_interface_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698