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

Side by Side Diff: net/server/http_server.cc

Issue 1506893004: [net] Make state table const to share between processes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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 | « no previous file | no next file » | 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/server/http_server.h" 5 #include "net/server/http_server.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/compiler_specific.h" 8 #include "base/compiler_specific.h"
9 #include "base/location.h" 9 #include "base/location.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after
339 ST_HEADER, // Starting a Request Header 339 ST_HEADER, // Starting a Request Header
340 ST_NAME, // Receiving a request header name 340 ST_NAME, // Receiving a request header name
341 ST_SEPARATOR, // Receiving the separator between header name and value 341 ST_SEPARATOR, // Receiving the separator between header name and value
342 ST_VALUE, // Receiving a request header value 342 ST_VALUE, // Receiving a request header value
343 ST_DONE, // Parsing is complete and successful 343 ST_DONE, // Parsing is complete and successful
344 ST_ERR, // Parsing encountered invalid syntax. 344 ST_ERR, // Parsing encountered invalid syntax.
345 MAX_STATES 345 MAX_STATES
346 }; 346 };
347 347
348 // State transition table 348 // State transition table
349 int parser_state[MAX_STATES][MAX_INPUTS] = { 349 const int parser_state[MAX_STATES][MAX_INPUTS] = {
350 /* METHOD */ { ST_URL, ST_ERR, ST_ERR, ST_ERR, ST_METHOD }, 350 /* METHOD */ {ST_URL, ST_ERR, ST_ERR, ST_ERR, ST_METHOD},
351 /* URL */ { ST_PROTO, ST_ERR, ST_ERR, ST_URL, ST_URL }, 351 /* URL */ {ST_PROTO, ST_ERR, ST_ERR, ST_URL, ST_URL},
352 /* PROTOCOL */ { ST_ERR, ST_HEADER, ST_NAME, ST_ERR, ST_PROTO }, 352 /* PROTOCOL */ {ST_ERR, ST_HEADER, ST_NAME, ST_ERR, ST_PROTO},
353 /* HEADER */ { ST_ERR, ST_ERR, ST_NAME, ST_ERR, ST_ERR }, 353 /* HEADER */ {ST_ERR, ST_ERR, ST_NAME, ST_ERR, ST_ERR},
354 /* NAME */ { ST_SEPARATOR, ST_DONE, ST_ERR, ST_VALUE, ST_NAME }, 354 /* NAME */ {ST_SEPARATOR, ST_DONE, ST_ERR, ST_VALUE, ST_NAME},
355 /* SEPARATOR */ { ST_SEPARATOR, ST_ERR, ST_ERR, ST_VALUE, ST_ERR }, 355 /* SEPARATOR */ {ST_SEPARATOR, ST_ERR, ST_ERR, ST_VALUE, ST_ERR},
356 /* VALUE */ { ST_VALUE, ST_HEADER, ST_NAME, ST_VALUE, ST_VALUE }, 356 /* VALUE */ {ST_VALUE, ST_HEADER, ST_NAME, ST_VALUE, ST_VALUE},
357 /* DONE */ { ST_DONE, ST_DONE, ST_DONE, ST_DONE, ST_DONE }, 357 /* DONE */ {ST_DONE, ST_DONE, ST_DONE, ST_DONE, ST_DONE},
358 /* ERR */ { ST_ERR, ST_ERR, ST_ERR, ST_ERR, ST_ERR } 358 /* ERR */ {ST_ERR, ST_ERR, ST_ERR, ST_ERR, ST_ERR}};
359 };
360 359
361 // Convert an input character to the parser's input token. 360 // Convert an input character to the parser's input token.
362 int charToInput(char ch) { 361 int charToInput(char ch) {
363 switch(ch) { 362 switch(ch) {
364 case ' ': 363 case ' ':
365 case '\t': 364 case '\t':
366 return INPUT_LWS; 365 return INPUT_LWS;
367 case '\r': 366 case '\r':
368 return INPUT_CR; 367 return INPUT_CR;
369 case '\n': 368 case '\n':
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
460 459
461 // This is called after any delegate callbacks are called to check if Close() 460 // This is called after any delegate callbacks are called to check if Close()
462 // has been called during callback processing. Using the pointer of connection, 461 // has been called during callback processing. Using the pointer of connection,
463 // |connection| is safe here because Close() deletes the connection in next run 462 // |connection| is safe here because Close() deletes the connection in next run
464 // loop. 463 // loop.
465 bool HttpServer::HasClosedConnection(HttpConnection* connection) { 464 bool HttpServer::HasClosedConnection(HttpConnection* connection) {
466 return FindConnection(connection->id()) != connection; 465 return FindConnection(connection->id()) != connection;
467 } 466 }
468 467
469 } // namespace net 468 } // namespace net
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698