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/quic/quic_protocol.h

Issue 11973021: Teach gtest how to print QuicConsumedData and QuicEncryptedPacket. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Sync with ToT Created 7 years, 11 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 | « no previous file | net/quic/quic_protocol.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) 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 #ifndef NET_QUIC_QUIC_PROTOCOL_H_ 5 #ifndef NET_QUIC_QUIC_PROTOCOL_H_
6 #define NET_QUIC_QUIC_PROTOCOL_H_ 6 #define NET_QUIC_QUIC_PROTOCOL_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <limits> 9 #include <limits>
10 #include <map> 10 #include <map>
(...skipping 461 matching lines...) Expand 10 before | Expand all | Expand 10 after
472 }; 472 };
473 473
474 class NET_EXPORT_PRIVATE QuicEncryptedPacket : public QuicData { 474 class NET_EXPORT_PRIVATE QuicEncryptedPacket : public QuicData {
475 public: 475 public:
476 QuicEncryptedPacket(const char* buffer, size_t length) 476 QuicEncryptedPacket(const char* buffer, size_t length)
477 : QuicData(buffer, length) { } 477 : QuicData(buffer, length) { }
478 478
479 QuicEncryptedPacket(char* buffer, size_t length, bool owns_buffer) 479 QuicEncryptedPacket(char* buffer, size_t length, bool owns_buffer)
480 : QuicData(buffer, length, owns_buffer) { } 480 : QuicData(buffer, length, owns_buffer) { }
481 481
482 // By default, gtest prints the raw bytes of an object. The bool data
483 // member (in the base class QuicData) causes this object to have padding
484 // bytes, which causes the default gtest object printer to read
485 // uninitialize memory. So we need to teach gtest how to print this object.
486 NET_EXPORT_PRIVATE friend std::ostream& operator<<(
487 std::ostream& os, const QuicEncryptedPacket& s);
488
482 base::StringPiece AssociatedData() const { 489 base::StringPiece AssociatedData() const {
483 return base::StringPiece(data() + kStartOfHashData, kStartOfEncryptedData); 490 return base::StringPiece(data() + kStartOfHashData, kStartOfEncryptedData);
484 } 491 }
485 492
486 private: 493 private:
487 DISALLOW_COPY_AND_ASSIGN(QuicEncryptedPacket); 494 DISALLOW_COPY_AND_ASSIGN(QuicEncryptedPacket);
488 }; 495 };
489 496
490 // A struct for functions which consume data payloads and fins. 497 // A struct for functions which consume data payloads and fins.
491 // The first member of the pair indicates bytes consumed. 498 // The first member of the pair indicates bytes consumed.
492 // The second member of the pair indicates if an incoming fin was consumed. 499 // The second member of the pair indicates if an incoming fin was consumed.
493 struct QuicConsumedData { 500 struct QuicConsumedData {
494 QuicConsumedData(size_t bytes_consumed, bool fin_consumed) 501 QuicConsumedData(size_t bytes_consumed, bool fin_consumed)
495 : bytes_consumed(bytes_consumed), 502 : bytes_consumed(bytes_consumed),
496 fin_consumed(fin_consumed) { 503 fin_consumed(fin_consumed) {
497 } 504 }
505
506 // By default, gtest prints the raw bytes of an object. The bool data
507 // member causes this object to have padding bytes, which causes the
508 // default gtest object printer to read uninitialize memory. So we need
509 // to teach gtest how to print this object.
510 NET_EXPORT_PRIVATE friend std::ostream& operator<<(
511 std::ostream& os, const QuicConsumedData& s);
512
498 size_t bytes_consumed; 513 size_t bytes_consumed;
499 bool fin_consumed; 514 bool fin_consumed;
500 }; 515 };
501 516
502 } // namespace net 517 } // namespace net
503 518
504 #endif // NET_QUIC_QUIC_PROTOCOL_H_ 519 #endif // NET_QUIC_QUIC_PROTOCOL_H_
OLDNEW
« no previous file with comments | « no previous file | net/quic/quic_protocol.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698