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

Side by Side Diff: net/tools/flip_server/balsa_headers.h

Issue 10854063: Clean-up inline members of nested classes (net/) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: add a NET_EXPOR_PRIVATE Created 8 years, 4 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/spdy/spdy_session.cc ('k') | net/tools/flip_server/balsa_headers.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 #ifndef NET_TOOLS_FLIP_SERVER_BALSA_HEADERS_H_ 5 #ifndef NET_TOOLS_FLIP_SERVER_BALSA_HEADERS_H_
6 #define NET_TOOLS_FLIP_SERVER_BALSA_HEADERS_H_ 6 #define NET_TOOLS_FLIP_SERVER_BALSA_HEADERS_H_
7 7
8 #include <algorithm> 8 #include <algorithm>
9 #include <iosfwd> 9 #include <iosfwd>
10 #include <iterator> 10 #include <iterator>
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after
299 typedef StringPiecePair value_type; 299 typedef StringPiecePair value_type;
300 typedef value_type& reference; 300 typedef value_type& reference;
301 typedef value_type* pointer; 301 typedef value_type* pointer;
302 302
303 typedef std::forward_iterator_tag iterator_category; 303 typedef std::forward_iterator_tag iterator_category;
304 typedef ptrdiff_t difference_type; 304 typedef ptrdiff_t difference_type;
305 305
306 typedef iterator_base self; 306 typedef iterator_base self;
307 307
308 // default constructor. 308 // default constructor.
309 iterator_base() : headers_(NULL), idx_(0) { } 309 iterator_base();
310 310
311 // copy constructor. 311 // copy constructor.
312 iterator_base(const iterator_base& it) 312 iterator_base(const iterator_base& it);
313 : headers_(it.headers_),
314 idx_(it.idx_) {}
315 313
316 reference operator*() const { 314 reference operator*() const {
317 return Lookup(idx_); 315 return Lookup(idx_);
318 } 316 }
319 317
320 pointer operator->() const { 318 pointer operator->() const {
321 return &(this->operator*()); 319 return &(this->operator*());
322 } 320 }
323 321
324 bool operator==(const self& it) const { 322 bool operator==(const self& it) const {
(...skipping 21 matching lines...) Expand all
346 } 344 }
347 345
348 // This mainly exists so that we can have interesting output for 346 // This mainly exists so that we can have interesting output for
349 // unittesting. The EXPECT_EQ, EXPECT_NE functions require that 347 // unittesting. The EXPECT_EQ, EXPECT_NE functions require that
350 // operator<< work for the classes it sees. It would be better if there 348 // operator<< work for the classes it sees. It would be better if there
351 // was an additional traits-like system for the gUnit output... but oh 349 // was an additional traits-like system for the gUnit output... but oh
352 // well. 350 // well.
353 std::ostream& operator<<(std::ostream& os) const; 351 std::ostream& operator<<(std::ostream& os) const;
354 352
355 protected: 353 protected:
356 iterator_base(const BalsaHeaders* headers, HeaderLines::size_type index) : 354 iterator_base(const BalsaHeaders* headers, HeaderLines::size_type index);
357 headers_(headers),
358 idx_(index) {}
359 355
360 void increment() { 356 void increment() {
361 const HeaderLines& header_lines = headers_->header_lines_; 357 const HeaderLines& header_lines = headers_->header_lines_;
362 const HeaderLines::size_type header_lines_size = header_lines.size(); 358 const HeaderLines::size_type header_lines_size = header_lines.size();
363 const HeaderLines::size_type original_idx = idx_; 359 const HeaderLines::size_type original_idx = idx_;
364 do { 360 do {
365 ++idx_; 361 ++idx_;
366 } while (idx_ < header_lines_size && header_lines[idx_].skip == true); 362 } while (idx_ < header_lines_size && header_lines[idx_].skip == true);
367 // The condition below exists so that ++(end() - 1) == end(), even 363 // The condition below exists so that ++(end() - 1) == end(), even
368 // if there are only 'skip == true' elements between the end() iterator 364 // if there are only 'skip == true' elements between the end() iterator
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
529 525
530 // An iterator that only stops at lines with a particular key. 526 // An iterator that only stops at lines with a particular key.
531 // See also GetIteratorForKey. 527 // See also GetIteratorForKey.
532 // 528 //
533 // Check against header_lines_key_end() to determine when iteration is 529 // Check against header_lines_key_end() to determine when iteration is
534 // finished. header_lines_end() will also work. 530 // finished. header_lines_end() will also work.
535 class const_header_lines_key_iterator : public iterator_base { 531 class const_header_lines_key_iterator : public iterator_base {
536 friend class BalsaHeaders; 532 friend class BalsaHeaders;
537 public: 533 public:
538 typedef const_header_lines_key_iterator self; 534 typedef const_header_lines_key_iterator self;
535 const_header_lines_key_iterator(const const_header_lines_key_iterator&);
539 536
540 self& operator++() { 537 self& operator++() {
541 do { 538 do {
542 iterator_base::increment(); 539 iterator_base::increment();
543 } while (!AtEnd() && 540 } while (!AtEnd() &&
544 !StringPieceUtils::EqualIgnoreCase(key_, (**this).first)); 541 !StringPieceUtils::EqualIgnoreCase(key_, (**this).first));
545 return *this; 542 return *this;
546 } 543 }
547 544
548 void operator++(int ignore) { 545 void operator++(int ignore) {
549 ++(*this); 546 ++(*this);
550 } 547 }
551 548
552 // Only forward-iteration makes sense, so no operator-- defined. 549 // Only forward-iteration makes sense, so no operator-- defined.
553 550
554 private: 551 private:
555 const_header_lines_key_iterator(const BalsaHeaders* headers, 552 const_header_lines_key_iterator(const BalsaHeaders* headers,
556 HeaderLines::size_type index, 553 HeaderLines::size_type index,
557 const base::StringPiece& key) 554 const base::StringPiece& key);
558 : iterator_base(headers, index),
559 key_(key) {
560 }
561 555
562 // Should only be used for creating an end iterator. 556 // Should only be used for creating an end iterator.
563 const_header_lines_key_iterator(const BalsaHeaders* headers, 557 const_header_lines_key_iterator(const BalsaHeaders* headers,
564 HeaderLines::size_type index) 558 HeaderLines::size_type index);
565 : iterator_base(headers, index) {
566 }
567 559
568 bool AtEnd() const { 560 bool AtEnd() const {
569 return *this >= headers_->header_lines_end(); 561 return *this >= headers_->header_lines_end();
570 } 562 }
571 563
572 base::StringPiece key_; 564 base::StringPiece key_;
573 }; 565 };
574 566
575 // TODO(fenix): Revisit the amount of bytes initially allocated to the second 567 // TODO(fenix): Revisit the amount of bytes initially allocated to the second
576 // block of the balsa_buffer_. It may make sense to pre-allocate some amount 568 // block of the balsa_buffer_. It may make sense to pre-allocate some amount
(...skipping 559 matching lines...) Expand 10 before | Expand all | Expand 10 after
1136 size_t end_of_firstline_idx_; 1128 size_t end_of_firstline_idx_;
1137 1129
1138 bool transfer_encoding_is_chunked_; 1130 bool transfer_encoding_is_chunked_;
1139 1131
1140 HeaderLines header_lines_; 1132 HeaderLines header_lines_;
1141 }; 1133 };
1142 1134
1143 } // namespace net 1135 } // namespace net
1144 1136
1145 #endif // NET_TOOLS_FLIP_SERVER_BALSA_HEADERS_H_ 1137 #endif // NET_TOOLS_FLIP_SERVER_BALSA_HEADERS_H_
OLDNEW
« no previous file with comments | « net/spdy/spdy_session.cc ('k') | net/tools/flip_server/balsa_headers.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698