| OLD | NEW |
| 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 // Some helpers for quic. | 5 // Some helpers for quic. |
| 6 | 6 |
| 7 #ifndef NET_QUIC_QUIC_UTILS_H_ | 7 #ifndef NET_QUIC_QUIC_UTILS_H_ |
| 8 #define NET_QUIC_QUIC_UTILS_H_ | 8 #define NET_QUIC_QUIC_UTILS_H_ |
| 9 | 9 |
| 10 #include <string> |
| 11 |
| 10 #include "net/base/int128.h" | 12 #include "net/base/int128.h" |
| 11 #include "net/base/net_export.h" | 13 #include "net/base/net_export.h" |
| 12 #include "net/quic/quic_protocol.h" | 14 #include "net/quic/quic_protocol.h" |
| 13 | 15 |
| 14 namespace net { | 16 namespace net { |
| 15 | 17 |
| 16 class NET_EXPORT_PRIVATE QuicUtils { | 18 class NET_EXPORT_PRIVATE QuicUtils { |
| 17 public: | 19 public: |
| 18 enum Priority { | 20 enum Priority { |
| 19 LOCAL_PRIORITY, | 21 LOCAL_PRIORITY, |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 | 63 |
| 62 // Returns TransmissionType as a char* | 64 // Returns TransmissionType as a char* |
| 63 static const char* TransmissionTypeToString(TransmissionType type); | 65 static const char* TransmissionTypeToString(TransmissionType type); |
| 64 | 66 |
| 65 // TagToString is a utility function for pretty-printing handshake messages | 67 // TagToString is a utility function for pretty-printing handshake messages |
| 66 // that converts a tag to a string. It will try to maintain the human friendly | 68 // that converts a tag to a string. It will try to maintain the human friendly |
| 67 // name if possible (i.e. kABCD -> "ABCD"), or will just treat it as a number | 69 // name if possible (i.e. kABCD -> "ABCD"), or will just treat it as a number |
| 68 // if not. | 70 // if not. |
| 69 static std::string TagToString(QuicTag tag); | 71 static std::string TagToString(QuicTag tag); |
| 70 | 72 |
| 73 // Returns the list of QUIC tags represented by the comma separated |
| 74 // string in |connection_options|. |
| 75 static QuicTagVector ParseQuicConnectionOptions( |
| 76 const std::string& connection_options); |
| 77 |
| 71 // Given a binary buffer, return a hex+ASCII dump in the style of | 78 // Given a binary buffer, return a hex+ASCII dump in the style of |
| 72 // tcpdump's -X and -XX options: | 79 // tcpdump's -X and -XX options: |
| 73 // "0x0000: 0090 69bd 5400 000d 610f 0189 0800 4500 ..i.T...a.....E.\n" | 80 // "0x0000: 0090 69bd 5400 000d 610f 0189 0800 4500 ..i.T...a.....E.\n" |
| 74 // "0x0010: 001c fb98 4000 4001 7e18 d8ef 2301 455d ....@.@.~...#.E]\n" | 81 // "0x0010: 001c fb98 4000 4001 7e18 d8ef 2301 455d ....@.@.~...#.E]\n" |
| 75 // "0x0020: 7fe2 0800 6bcb 0bc6 806e ....k....n\n" | 82 // "0x0020: 7fe2 0800 6bcb 0bc6 806e ....k....n\n" |
| 76 static std::string StringToHexASCIIDump(base::StringPiece in_buffer); | 83 static std::string StringToHexASCIIDump(base::StringPiece in_buffer); |
| 77 | 84 |
| 78 static char* AsChars(unsigned char* data) { | 85 static char* AsChars(unsigned char* data) { |
| 79 return reinterpret_cast<char*>(data); | 86 return reinterpret_cast<char*>(data); |
| 80 } | 87 } |
| 81 | 88 |
| 82 static QuicPriority LowestPriority(); | 89 static QuicPriority LowestPriority(); |
| 83 | 90 |
| 84 static QuicPriority HighestPriority(); | 91 static QuicPriority HighestPriority(); |
| 85 | 92 |
| 86 private: | 93 private: |
| 87 DISALLOW_COPY_AND_ASSIGN(QuicUtils); | 94 DISALLOW_COPY_AND_ASSIGN(QuicUtils); |
| 88 }; | 95 }; |
| 89 | 96 |
| 90 // Utility function that returns an IOVector object wrapped around |str|. | 97 // Utility function that returns an IOVector object wrapped around |str|. |
| 91 inline IOVector MakeIOVector(base::StringPiece str) { | 98 inline IOVector MakeIOVector(base::StringPiece str) { |
| 92 IOVector iov; | 99 IOVector iov; |
| 93 iov.Append(const_cast<char*>(str.data()), str.size()); | 100 iov.Append(const_cast<char*>(str.data()), str.size()); |
| 94 return iov; | 101 return iov; |
| 95 } | 102 } |
| 96 | 103 |
| 97 } // namespace net | 104 } // namespace net |
| 98 | 105 |
| 99 #endif // NET_QUIC_QUIC_UTILS_H_ | 106 #endif // NET_QUIC_QUIC_UTILS_H_ |
| OLD | NEW |