| Index: net/tools/balsa/balsa_headers.h
|
| diff --git a/net/tools/balsa/balsa_headers.h b/net/tools/balsa/balsa_headers.h
|
| index 47cf388b8aba85e2bc382dff4bf6d58a325826e8..8cc958f644944017bc9ac2cb89539a421a8693fc 100644
|
| --- a/net/tools/balsa/balsa_headers.h
|
| +++ b/net/tools/balsa/balsa_headers.h
|
| @@ -76,18 +76,14 @@ class BalsaBuffer {
|
| size_t buffer_size;
|
| size_t bytes_free;
|
|
|
| - size_t bytes_used() const {
|
| - return buffer_size - bytes_free;
|
| - }
|
| - char* start_of_unused_bytes() const {
|
| - return buffer + bytes_used();
|
| - }
|
| + size_t bytes_used() const { return buffer_size - bytes_free; }
|
| + char* start_of_unused_bytes() const { return buffer + bytes_used(); }
|
|
|
| BufferBlock() : buffer(NULL), buffer_size(0), bytes_free(0) {}
|
| ~BufferBlock() {}
|
|
|
| - BufferBlock(char* buf, size_t size, size_t free) :
|
| - buffer(buf), buffer_size(size), bytes_free(free) {}
|
| + BufferBlock(char* buf, size_t size, size_t free)
|
| + : buffer(buf), buffer_size(size), bytes_free(free) {}
|
| // Yes we want this to be copyable (it gets stuck into vectors).
|
| // For this reason, we don't use scoped ptrs, etc. here-- it
|
| // is more efficient to manage this memory externally to this
|
| @@ -102,14 +98,12 @@ class BalsaBuffer {
|
| size_t GetTotalBufferBlockSize() const;
|
|
|
| const char* GetPtr(Blocks::size_type block_idx) const {
|
| - DCHECK_LT(block_idx, blocks_.size())
|
| - << block_idx << ", " << blocks_.size();
|
| + DCHECK_LT(block_idx, blocks_.size()) << block_idx << ", " << blocks_.size();
|
| return blocks_[block_idx].buffer;
|
| }
|
|
|
| char* GetPtr(Blocks::size_type block_idx) {
|
| - DCHECK_LT(block_idx, blocks_.size())
|
| - << block_idx << ", " << blocks_.size();
|
| + DCHECK_LT(block_idx, blocks_.size()) << block_idx << ", " << blocks_.size();
|
| return blocks_[block_idx].buffer;
|
| }
|
|
|
| @@ -162,9 +156,7 @@ class BalsaBuffer {
|
|
|
| void CopyFrom(const BalsaBuffer& b);
|
|
|
| - const char* StartOfFirstBlock() const {
|
| - return blocks_[0].buffer;
|
| - }
|
| + const char* StartOfFirstBlock() const { return blocks_[0].buffer; }
|
|
|
| const char* EndOfFirstBlock() const {
|
| return blocks_[0].buffer + blocks_[0].bytes_used();
|
| @@ -247,21 +239,21 @@ class BalsaHeaders {
|
| size_t key_end_index,
|
| size_t value_begin_index,
|
| size_t last_character_index,
|
| - size_t buffer_base_index) :
|
| - first_char_idx(first_character_index),
|
| - key_end_idx(key_end_index),
|
| - value_begin_idx(value_begin_index),
|
| - last_char_idx(last_character_index),
|
| - buffer_base_idx(buffer_base_index),
|
| - skip(false) {}
|
| -
|
| - HeaderLineDescription() :
|
| - first_char_idx(0),
|
| - key_end_idx(0),
|
| - value_begin_idx(0),
|
| - last_char_idx(0),
|
| - buffer_base_idx(0),
|
| - skip(false) {}
|
| + size_t buffer_base_index)
|
| + : first_char_idx(first_character_index),
|
| + key_end_idx(key_end_index),
|
| + value_begin_idx(value_begin_index),
|
| + last_char_idx(last_character_index),
|
| + buffer_base_idx(buffer_base_index),
|
| + skip(false) {}
|
| +
|
| + HeaderLineDescription()
|
| + : first_char_idx(0),
|
| + key_end_idx(0),
|
| + value_begin_idx(0),
|
| + last_char_idx(0),
|
| + buffer_base_idx(0),
|
| + skip(false) {}
|
|
|
| size_t first_char_idx;
|
| size_t key_end_idx;
|
| @@ -312,37 +304,21 @@ class BalsaHeaders {
|
| // copy constructor.
|
| iterator_base(const iterator_base& it);
|
|
|
| - reference operator*() const {
|
| - return Lookup(idx_);
|
| - }
|
| + reference operator*() const { return Lookup(idx_); }
|
|
|
| - pointer operator->() const {
|
| - return &(this->operator*());
|
| - }
|
| + pointer operator->() const { return &(this->operator*()); }
|
|
|
| - bool operator==(const self& it) const {
|
| - return idx_ == it.idx_;
|
| - }
|
| + bool operator==(const self& it) const { return idx_ == it.idx_; }
|
|
|
| - bool operator<(const self& it) const {
|
| - return idx_ < it.idx_;
|
| - }
|
| + bool operator<(const self& it) const { return idx_ < it.idx_; }
|
|
|
| - bool operator<=(const self& it) const {
|
| - return idx_ <= it.idx_;
|
| - }
|
| + bool operator<=(const self& it) const { return idx_ <= it.idx_; }
|
|
|
| - bool operator!=(const self& it) const {
|
| - return !(*this == it);
|
| - }
|
| + bool operator!=(const self& it) const { return !(*this == it); }
|
|
|
| - bool operator>(const self& it) const {
|
| - return it < *this;
|
| - }
|
| + bool operator>(const self& it) const { return it < *this; }
|
|
|
| - bool operator>=(const self& it) const {
|
| - return it <= *this;
|
| - }
|
| + bool operator>=(const self& it) const { return it <= *this; }
|
|
|
| // This mainly exists so that we can have interesting output for
|
| // unittesting. The EXPECT_EQ, EXPECT_NE functions require that
|
| @@ -396,9 +372,9 @@ class BalsaHeaders {
|
| const char* stream_begin = headers_->GetPtr(line.buffer_base_idx);
|
| value_ = value_type(
|
| base::StringPiece(stream_begin + line.first_char_idx,
|
| - line.key_end_idx - line.first_char_idx),
|
| + line.key_end_idx - line.first_char_idx),
|
| base::StringPiece(stream_begin + line.value_begin_idx,
|
| - line.last_char_idx - line.value_begin_idx));
|
| + line.last_char_idx - line.value_begin_idx));
|
| DCHECK_GE(line.key_end_idx, line.first_char_idx);
|
| DCHECK_GE(line.last_char_idx, line.value_begin_idx);
|
| return value_;
|
| @@ -420,9 +396,9 @@ class BalsaHeaders {
|
| reverse_iterator_base() : iterator_base() {}
|
|
|
| // This constructor is no explicit purposely.
|
| - reverse_iterator_base(const iterator_base& it) : // NOLINT
|
| - iterator_base(it) {
|
| - }
|
| + reverse_iterator_base(const iterator_base& it)
|
| + : // NOLINT
|
| + iterator_base(it) {}
|
|
|
| self& operator=(const iterator_base& it) {
|
| idx_ = it.idx_;
|
| @@ -436,16 +412,12 @@ class BalsaHeaders {
|
| return *this;
|
| }
|
|
|
| - reference operator*() const {
|
| - return Lookup(idx_ - 1);
|
| - }
|
| + reference operator*() const { return Lookup(idx_ - 1); }
|
|
|
| - pointer operator->() const {
|
| - return &(this->operator*());
|
| - }
|
| + pointer operator->() const { return &(this->operator*()); }
|
|
|
| - reverse_iterator_base(const reverse_iterator_base& it) :
|
| - iterator_base(it) { }
|
| + reverse_iterator_base(const reverse_iterator_base& it)
|
| + : iterator_base(it) {}
|
|
|
| protected:
|
| void increment() {
|
| @@ -461,19 +433,20 @@ class BalsaHeaders {
|
| }
|
|
|
| reverse_iterator_base(const BalsaHeaders* headers,
|
| - HeaderLines::size_type index) :
|
| - iterator_base(headers, index) {}
|
| + HeaderLines::size_type index)
|
| + : iterator_base(headers, index) {}
|
| };
|
|
|
| public:
|
| class const_header_lines_iterator : public iterator_base {
|
| friend class BalsaHeaders;
|
| +
|
| public:
|
| typedef const_header_lines_iterator self;
|
| const_header_lines_iterator() : iterator_base() {}
|
|
|
| - const_header_lines_iterator(const const_header_lines_iterator& it) :
|
| - iterator_base(it.headers_, it.idx_) {}
|
| + const_header_lines_iterator(const const_header_lines_iterator& it)
|
| + : iterator_base(it.headers_, it.idx_) {}
|
|
|
| self& operator++() {
|
| iterator_base::increment();
|
| @@ -484,10 +457,11 @@ class BalsaHeaders {
|
| iterator_base::decrement();
|
| return *this;
|
| }
|
| +
|
| protected:
|
| const_header_lines_iterator(const BalsaHeaders* headers,
|
| - HeaderLines::size_type index) :
|
| - iterator_base(headers, index) {}
|
| + HeaderLines::size_type index)
|
| + : iterator_base(headers, index) {}
|
| };
|
|
|
| class const_reverse_header_lines_iterator : public reverse_iterator_base {
|
| @@ -495,13 +469,12 @@ class BalsaHeaders {
|
| typedef const_reverse_header_lines_iterator self;
|
| const_reverse_header_lines_iterator() : reverse_iterator_base() {}
|
|
|
| - const_reverse_header_lines_iterator(
|
| - const const_header_lines_iterator& it) :
|
| - reverse_iterator_base(it.headers_, it.idx_) {}
|
| + const_reverse_header_lines_iterator(const const_header_lines_iterator& it)
|
| + : reverse_iterator_base(it.headers_, it.idx_) {}
|
|
|
| const_reverse_header_lines_iterator(
|
| - const const_reverse_header_lines_iterator& it) :
|
| - reverse_iterator_base(it.headers_, it.idx_) {}
|
| + const const_reverse_header_lines_iterator& it)
|
| + : reverse_iterator_base(it.headers_, it.idx_) {}
|
|
|
| const_header_lines_iterator base() {
|
| return const_header_lines_iterator(headers_, idx_);
|
| @@ -516,10 +489,11 @@ class BalsaHeaders {
|
| reverse_iterator_base::decrement();
|
| return *this;
|
| }
|
| +
|
| protected:
|
| const_reverse_header_lines_iterator(const BalsaHeaders* headers,
|
| - HeaderLines::size_type index) :
|
| - reverse_iterator_base(headers, index) {}
|
| + HeaderLines::size_type index)
|
| + : reverse_iterator_base(headers, index) {}
|
|
|
| friend class BalsaHeaders;
|
| };
|
| @@ -531,6 +505,7 @@ class BalsaHeaders {
|
| // finished. header_lines_end() will also work.
|
| class const_header_lines_key_iterator : public iterator_base {
|
| friend class BalsaHeaders;
|
| +
|
| public:
|
| typedef const_header_lines_key_iterator self;
|
| const_header_lines_key_iterator(const const_header_lines_key_iterator&);
|
| @@ -543,9 +518,7 @@ class BalsaHeaders {
|
| return *this;
|
| }
|
|
|
| - void operator++(int ignore) {
|
| - ++(*this);
|
| - }
|
| + void operator++(int ignore) { ++(*this); }
|
|
|
| // Only forward-iteration makes sense, so no operator-- defined.
|
|
|
| @@ -558,9 +531,7 @@ class BalsaHeaders {
|
| const_header_lines_key_iterator(const BalsaHeaders* headers,
|
| HeaderLines::size_type index);
|
|
|
| - bool AtEnd() const {
|
| - return *this >= headers_->header_lines_end();
|
| - }
|
| + bool AtEnd() const { return *this >= headers_->header_lines_end(); }
|
|
|
| base::StringPiece key_;
|
| };
|
| @@ -790,9 +761,9 @@ class BalsaHeaders {
|
| WriteHeaderLineToBuffer(
|
| buffer,
|
| base::StringPiece(line_ptr + line.first_char_idx,
|
| - line.key_end_idx - line.first_char_idx),
|
| + line.key_end_idx - line.first_char_idx),
|
| base::StringPiece(line_ptr + line.value_begin_idx,
|
| - line.last_char_idx - line.value_begin_idx));
|
| + line.last_char_idx - line.value_begin_idx));
|
| }
|
| }
|
|
|
| @@ -828,7 +799,7 @@ class BalsaHeaders {
|
| const base::StringPiece first_line() const {
|
| DCHECK_GE(whitespace_4_idx_, non_whitespace_1_idx_);
|
| return base::StringPiece(BeginningOfFirstLine() + non_whitespace_1_idx_,
|
| - whitespace_4_idx_ - non_whitespace_1_idx_);
|
| + whitespace_4_idx_ - non_whitespace_1_idx_);
|
| }
|
|
|
| // Returns the parsed value of the response code if it has been parsed.
|
| @@ -842,7 +813,7 @@ class BalsaHeaders {
|
| const base::StringPiece request_method() const {
|
| DCHECK_GE(whitespace_2_idx_, non_whitespace_1_idx_);
|
| return base::StringPiece(BeginningOfFirstLine() + non_whitespace_1_idx_,
|
| - whitespace_2_idx_ - non_whitespace_1_idx_);
|
| + whitespace_2_idx_ - non_whitespace_1_idx_);
|
| }
|
|
|
| const base::StringPiece response_version() const {
|
| @@ -856,7 +827,7 @@ class BalsaHeaders {
|
| const base::StringPiece request_uri() const {
|
| DCHECK_GE(whitespace_3_idx_, non_whitespace_2_idx_);
|
| return base::StringPiece(BeginningOfFirstLine() + non_whitespace_2_idx_,
|
| - whitespace_3_idx_ - non_whitespace_2_idx_);
|
| + whitespace_3_idx_ - non_whitespace_2_idx_);
|
| }
|
|
|
| const base::StringPiece response_code() const {
|
| @@ -869,7 +840,7 @@ class BalsaHeaders {
|
| const base::StringPiece request_version() const {
|
| DCHECK_GE(whitespace_4_idx_, non_whitespace_3_idx_);
|
| return base::StringPiece(BeginningOfFirstLine() + non_whitespace_3_idx_,
|
| - whitespace_4_idx_ - non_whitespace_3_idx_);
|
| + whitespace_4_idx_ - non_whitespace_3_idx_);
|
| }
|
|
|
| const base::StringPiece response_reason_phrase() const {
|
| @@ -954,8 +925,8 @@ class BalsaHeaders {
|
| // parsed_response_code_ is 0 for requests, so ResponseCodeImpliesNoBody
|
| // will return false.
|
| return (content_length_status_ == BalsaHeadersEnums::NO_CONTENT_LENGTH) &&
|
| - !transfer_encoding_is_chunked_ &&
|
| - !ResponseCodeImpliesNoBody(parsed_response_code_);
|
| + !transfer_encoding_is_chunked_ &&
|
| + !ResponseCodeImpliesNoBody(parsed_response_code_);
|
| }
|
|
|
| size_t content_length() const { return content_length_; }
|
| @@ -1045,9 +1016,8 @@ class BalsaHeaders {
|
| const base::StringPiece& key,
|
| HeaderLines::iterator start);
|
|
|
| - HeaderLines::iterator GetHeaderLinesIterator(
|
| - const base::StringPiece& key,
|
| - HeaderLines::iterator start);
|
| + HeaderLines::iterator GetHeaderLinesIterator(const base::StringPiece& key,
|
| + HeaderLines::iterator start);
|
|
|
| template <typename IteratorType>
|
| const IteratorType HeaderLinesBeginHelper() const {
|
| @@ -1086,8 +1056,9 @@ class BalsaHeaders {
|
| // only acceptable for the purpose of debugging parse errors seen by the
|
| // BalsaFrame class.
|
| base::StringPiece OriginalHeadersForDebugging() const {
|
| - return base::StringPiece(OriginalHeaderStreamBegin(),
|
| - OriginalHeaderStreamEnd() - OriginalHeaderStreamBegin());
|
| + return base::StringPiece(
|
| + OriginalHeaderStreamBegin(),
|
| + OriginalHeaderStreamEnd() - OriginalHeaderStreamBegin());
|
| }
|
|
|
| BalsaBuffer balsa_buffer_;
|
|
|