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

Side by Side Diff: net/tools/balsa/balsa_frame.cc

Issue 312003002: Port net/tools/balsa to non-Linux platforms. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix Windows compiler warnings Created 6 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « net/tools/balsa/balsa_frame.h ('k') | net/tools/balsa/balsa_headers.h » ('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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/balsa/balsa_frame.h" 5 #include "net/tools/balsa/balsa_frame.h"
6 6
7 #include <assert.h> 7 #include <assert.h>
8 #if __SSE2__ 8 #if __SSE2__
9 #include <emmintrin.h> 9 #include <emmintrin.h>
10 #endif // __SSE2__ 10 #endif // __SSE2__
11 #include <strings.h>
12 11
13 #include <limits> 12 #include <limits>
14 #include <string> 13 #include <string>
15 #include <utility> 14 #include <utility>
16 #include <vector> 15 #include <vector>
17 16
18 #include "base/logging.h" 17 #include "base/logging.h"
19 #include "base/port.h" 18 #include "base/port.h"
20 #include "base/strings/string_piece.h" 19 #include "base/strings/string_piece.h"
21 #include "net/tools/balsa/balsa_enums.h" 20 #include "net/tools/balsa/balsa_enums.h"
22 #include "net/tools/balsa/balsa_headers.h" 21 #include "net/tools/balsa/balsa_headers.h"
23 #include "net/tools/balsa/balsa_visitor_interface.h" 22 #include "net/tools/balsa/balsa_visitor_interface.h"
24 #include "net/tools/balsa/buffer_interface.h" 23 #include "net/tools/balsa/buffer_interface.h"
25 #include "net/tools/balsa/simple_buffer.h" 24 #include "net/tools/balsa/simple_buffer.h"
26 #include "net/tools/balsa/split.h" 25 #include "net/tools/balsa/split.h"
27 #include "net/tools/balsa/string_piece_utils.h" 26 #include "net/tools/balsa/string_piece_utils.h"
28 27
28 #if defined(COMPILER_MSVC)
29 #include <string.h>
30 #define strncasecmp _strnicmp
31 #else
32 #include <strings.h>
33 #endif
34
29 namespace net { 35 namespace net {
30 36
31 // Constants holding some header names for headers which can affect the way the 37 // Constants holding some header names for headers which can affect the way the
32 // HTTP message is framed, and so must be processed specially: 38 // HTTP message is framed, and so must be processed specially:
33 static const char kContentLength[] = "content-length"; 39 static const char kContentLength[] = "content-length";
34 static const size_t kContentLengthSize = sizeof(kContentLength) - 1; 40 static const size_t kContentLengthSize = sizeof(kContentLength) - 1;
35 static const char kTransferEncoding[] = "transfer-encoding"; 41 static const char kTransferEncoding[] = "transfer-encoding";
36 static const size_t kTransferEncodingSize = sizeof(kTransferEncoding) - 1; 42 static const size_t kTransferEncodingSize = sizeof(kTransferEncoding) - 1;
37 43
38 BalsaFrame::BalsaFrame() 44 BalsaFrame::BalsaFrame()
(...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after
419 &last_error_)) { 425 &last_error_)) {
420 parse_state_ = BalsaFrameEnums::PARSE_ERROR; 426 parse_state_ = BalsaFrameEnums::PARSE_ERROR;
421 visitor_->HandleHeaderError(this); 427 visitor_->HandleHeaderError(this);
422 return; 428 return;
423 } 429 }
424 if (previous_error != last_error_) { 430 if (previous_error != last_error_) {
425 visitor_->HandleHeaderWarning(this); 431 visitor_->HandleHeaderWarning(this);
426 } 432 }
427 433
428 if (is_request_) { 434 if (is_request_) {
429 int version_length = 435 size_t version_length =
430 headers_->whitespace_4_idx_ - headers_->non_whitespace_3_idx_; 436 headers_->whitespace_4_idx_ - headers_->non_whitespace_3_idx_;
431 visitor_->ProcessRequestFirstLine( 437 visitor_->ProcessRequestFirstLine(
432 begin + headers_->non_whitespace_1_idx_, 438 begin + headers_->non_whitespace_1_idx_,
433 headers_->whitespace_4_idx_ - headers_->non_whitespace_1_idx_, 439 headers_->whitespace_4_idx_ - headers_->non_whitespace_1_idx_,
434 begin + headers_->non_whitespace_1_idx_, 440 begin + headers_->non_whitespace_1_idx_,
435 headers_->whitespace_2_idx_ - headers_->non_whitespace_1_idx_, 441 headers_->whitespace_2_idx_ - headers_->non_whitespace_1_idx_,
436 begin + headers_->non_whitespace_2_idx_, 442 begin + headers_->non_whitespace_2_idx_,
437 headers_->whitespace_3_idx_ - headers_->non_whitespace_2_idx_, 443 headers_->whitespace_3_idx_ - headers_->non_whitespace_2_idx_,
438 begin + headers_->non_whitespace_3_idx_, 444 begin + headers_->non_whitespace_3_idx_,
439 version_length); 445 version_length);
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
569 while (current < header_lines_end_m16) { 575 while (current < header_lines_end_m16) {
570 __m128i header_bytes = 576 __m128i header_bytes =
571 _mm_loadu_si128(reinterpret_cast<const __m128i *>(current)); 577 _mm_loadu_si128(reinterpret_cast<const __m128i *>(current));
572 __m128i colon_cmp = 578 __m128i colon_cmp =
573 _mm_cmpeq_epi8(header_bytes, reinterpret_cast<__m128i>(colons)); 579 _mm_cmpeq_epi8(header_bytes, reinterpret_cast<__m128i>(colons));
574 int colon_msk = _mm_movemask_epi8(colon_cmp); 580 int colon_msk = _mm_movemask_epi8(colon_cmp);
575 if (colon_msk == 0) { 581 if (colon_msk == 0) {
576 current += 16; 582 current += 16;
577 continue; 583 continue;
578 } 584 }
579 current += (ffs(colon_msk) - 1); 585 current += (ffs(colon_msk) - 1);
Nico 2014/07/04 00:27:31 I believe ffs() is only available if strings.h was
wtc 2014/07/07 16:50:16 Chromium uses the code in net/tools/balsa only in
580 if (current > line_end) { 586 if (current > line_end) {
581 break; 587 break;
582 } 588 }
583 goto found_colon; 589 goto found_colon;
584 } 590 }
585 #endif // __SSE2__ 591 #endif // __SSE2__
586 for (; current < line_end; ++current) { 592 for (; current < line_end; ++current) {
587 if (*current != ':') { 593 if (*current != ':') {
588 continue; 594 continue;
589 } 595 }
(...skipping 959 matching lines...) Expand 10 before | Expand all | Expand 10 after
1549 << BalsaFrameEnums::ParseStateToString(parse_state_) 1555 << BalsaFrameEnums::ParseStateToString(parse_state_)
1550 << "$$$$$$$$$$$$$$$" 1556 << "$$$$$$$$$$$$$$$"
1551 << " consumed: " << (current - input); 1557 << " consumed: " << (current - input);
1552 if (Error()) { 1558 if (Error()) {
1553 LOG(INFO) << BalsaFrameEnums::ErrorCodeToString(ErrorCode()); 1559 LOG(INFO) << BalsaFrameEnums::ErrorCodeToString(ErrorCode());
1554 } 1560 }
1555 #endif // DEBUGFRAMER 1561 #endif // DEBUGFRAMER
1556 return current - input; 1562 return current - input;
1557 } 1563 }
1558 1564
1559 const uint32 BalsaFrame::kValidTerm1;
1560 const uint32 BalsaFrame::kValidTerm1Mask;
1561 const uint32 BalsaFrame::kValidTerm2;
1562 const uint32 BalsaFrame::kValidTerm2Mask;
1563
1564 } // namespace net 1565 } // namespace net
OLDNEW
« no previous file with comments | « net/tools/balsa/balsa_frame.h ('k') | net/tools/balsa/balsa_headers.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698