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

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: 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
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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
418 typedef iterator_base::reference reference; 414 typedef iterator_base::reference reference;
419 typedef iterator_base::pointer pointer; 415 typedef iterator_base::pointer pointer;
420 using iterator_base::headers_; 416 using iterator_base::headers_;
421 using iterator_base::idx_; 417 using iterator_base::idx_;
422 418
423 reverse_iterator_base() : iterator_base() {} 419 reverse_iterator_base() : iterator_base() {}
424 420
425 // This constructor is no explicit purposely. 421 // This constructor is no explicit purposely.
426 reverse_iterator_base(const iterator_base& it) : // NOLINT 422 reverse_iterator_base(const iterator_base& it) : // NOLINT
427 iterator_base(it) { 423 iterator_base(it) {
428 } 424 }
mmenke 2012/08/09 15:13:35 Should these constructors be de-inlined?
hans 2012/08/09 15:35:42 The plugin doesn't think it's complex enough.
429 425
430 self& operator=(const iterator_base& it) { 426 self& operator=(const iterator_base& it) {
431 idx_ = it.idx_; 427 idx_ = it.idx_;
432 headers_ = it.headers_; 428 headers_ = it.headers_;
433 return *this; 429 return *this;
434 } 430 }
435 431
436 self& operator=(const reverse_iterator_base& it) { 432 self& operator=(const reverse_iterator_base& it) {
437 idx_ = it.idx_; 433 idx_ = it.idx_;
438 headers_ = it.headers_; 434 headers_ = it.headers_;
439 return *this; 435 return *this;
440 } 436 }
441 437
442 reference operator*() const { 438 reference operator*() const {
443 return Lookup(idx_ - 1); 439 return Lookup(idx_ - 1);
444 } 440 }
445 441
446 pointer operator->() const { 442 pointer operator->() const {
447 return &(this->operator*()); 443 return &(this->operator*());
448 } 444 }
449 445
450 reverse_iterator_base(const reverse_iterator_base& it) : 446 reverse_iterator_base(const reverse_iterator_base& it) :
451 iterator_base(it) { } 447 iterator_base(it) { }
mmenke 2012/08/09 15:13:35 Another inline constructor.
hans 2012/08/09 15:35:42 Ditto.
452 448
453 protected: 449 protected:
454 void increment() { 450 void increment() {
455 --idx_; 451 --idx_;
456 iterator_base::decrement(); 452 iterator_base::decrement();
457 ++idx_; 453 ++idx_;
458 } 454 }
459 455
460 void decrement() { 456 void decrement() {
461 ++idx_; 457 ++idx_;
462 iterator_base::increment(); 458 iterator_base::increment();
463 --idx_; 459 --idx_;
464 } 460 }
465 461
466 reverse_iterator_base(const BalsaHeaders* headers, 462 reverse_iterator_base(const BalsaHeaders* headers,
467 HeaderLines::size_type index) : 463 HeaderLines::size_type index) :
468 iterator_base(headers, index) {} 464 iterator_base(headers, index) {}
mmenke 2012/08/09 15:13:35 Another inline constructor.
hans 2012/08/09 15:35:42 Ditto.
469 }; 465 };
470 466
471 public: 467 public:
472 class const_header_lines_iterator : public iterator_base { 468 class const_header_lines_iterator : public iterator_base {
473 friend class BalsaHeaders; 469 friend class BalsaHeaders;
474 public: 470 public:
475 typedef const_header_lines_iterator self; 471 typedef const_header_lines_iterator self;
476 const_header_lines_iterator() : iterator_base() {} 472 const_header_lines_iterator() : iterator_base() {}
477 473
478 const_header_lines_iterator(const const_header_lines_iterator& it) : 474 const_header_lines_iterator(const const_header_lines_iterator& it) :
479 iterator_base(it.headers_, it.idx_) {} 475 iterator_base(it.headers_, it.idx_) {}
mmenke 2012/08/09 15:13:35 Two more inline constructors.
hans 2012/08/09 15:35:42 Ditto.
480 476
481 self& operator++() { 477 self& operator++() {
482 iterator_base::increment(); 478 iterator_base::increment();
483 return *this; 479 return *this;
484 } 480 }
485 481
486 self& operator--() { 482 self& operator--() {
487 iterator_base::decrement(); 483 iterator_base::decrement();
488 return *this; 484 return *this;
489 } 485 }
490 protected: 486 protected:
491 const_header_lines_iterator(const BalsaHeaders* headers, 487 const_header_lines_iterator(const BalsaHeaders* headers,
492 HeaderLines::size_type index) : 488 HeaderLines::size_type index) :
493 iterator_base(headers, index) {} 489 iterator_base(headers, index) {}
mmenke 2012/08/09 15:13:35 Another inline constructor.
hans 2012/08/09 15:35:42 Ditto.
494 }; 490 };
495 491
496 class const_reverse_header_lines_iterator : public reverse_iterator_base { 492 class const_reverse_header_lines_iterator : public reverse_iterator_base {
497 public: 493 public:
498 typedef const_reverse_header_lines_iterator self; 494 typedef const_reverse_header_lines_iterator self;
499 const_reverse_header_lines_iterator() : reverse_iterator_base() {} 495 const_reverse_header_lines_iterator() : reverse_iterator_base() {}
500 496
501 const_reverse_header_lines_iterator( 497 const_reverse_header_lines_iterator(
502 const const_header_lines_iterator& it) : 498 const const_header_lines_iterator& it) :
503 reverse_iterator_base(it.headers_, it.idx_) {} 499 reverse_iterator_base(it.headers_, it.idx_) {}
504 500
505 const_reverse_header_lines_iterator( 501 const_reverse_header_lines_iterator(
506 const const_reverse_header_lines_iterator& it) : 502 const const_reverse_header_lines_iterator& it) :
507 reverse_iterator_base(it.headers_, it.idx_) {} 503 reverse_iterator_base(it.headers_, it.idx_) {}
508 504
509 const_header_lines_iterator base() { 505 const_header_lines_iterator base() {
510 return const_header_lines_iterator(headers_, idx_); 506 return const_header_lines_iterator(headers_, idx_);
511 } 507 }
mmenke 2012/08/09 15:13:35 Four more inline constructors. Not going to bothe
hans 2012/08/09 15:35:42 Ditto.
512 508
513 self& operator++() { 509 self& operator++() {
514 reverse_iterator_base::increment(); 510 reverse_iterator_base::increment();
515 return *this; 511 return *this;
516 } 512 }
517 513
518 self& operator--() { 514 self& operator--() {
519 reverse_iterator_base::decrement(); 515 reverse_iterator_base::decrement();
520 return *this; 516 return *this;
521 } 517 }
522 protected: 518 protected:
523 const_reverse_header_lines_iterator(const BalsaHeaders* headers, 519 const_reverse_header_lines_iterator(const BalsaHeaders* headers,
524 HeaderLines::size_type index) : 520 HeaderLines::size_type index) :
525 reverse_iterator_base(headers, index) {} 521 reverse_iterator_base(headers, index) {}
526 522
527 friend class BalsaHeaders; 523 friend class BalsaHeaders;
528 }; 524 };
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

Powered by Google App Engine
This is Rietveld 408576698