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

Side by Side Diff: net/quic/core/quic_utils.h

Issue 2740453006: Add QuicStringPiece which is actually StringPiece. (Closed)
Patch Set: fix compile error and rebase Created 3 years, 9 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
« no previous file with comments | « net/quic/core/quic_stream_test.cc ('k') | net/quic/core/quic_utils.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_CORE_QUIC_UTILS_H_ 5 #ifndef NET_QUIC_CORE_QUIC_UTILS_H_
6 #define NET_QUIC_CORE_QUIC_UTILS_H_ 6 #define NET_QUIC_CORE_QUIC_UTILS_H_
7 7
8 #include <cstddef> 8 #include <cstddef>
9 #include <cstdint> 9 #include <cstdint>
10 #include <string> 10 #include <string>
11 11
12 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "base/strings/string_piece.h"
14 #include "net/base/int128.h" 13 #include "net/base/int128.h"
15 #include "net/quic/core/quic_error_codes.h" 14 #include "net/quic/core/quic_error_codes.h"
16 #include "net/quic/core/quic_types.h" 15 #include "net/quic/core/quic_types.h"
17 #include "net/quic/platform/api/quic_export.h" 16 #include "net/quic/platform/api/quic_export.h"
18 #include "net/quic/platform/api/quic_socket_address.h" 17 #include "net/quic/platform/api/quic_socket_address.h"
18 #include "net/quic/platform/api/quic_string_piece.h"
19 19
20 namespace net { 20 namespace net {
21 21
22 class QUIC_EXPORT_PRIVATE QuicUtils { 22 class QUIC_EXPORT_PRIVATE QuicUtils {
23 public: 23 public:
24 // Returns the 64 bit FNV1a hash of the data. See 24 // Returns the 64 bit FNV1a hash of the data. See
25 // http://www.isthe.com/chongo/tech/comp/fnv/index.html#FNV-param 25 // http://www.isthe.com/chongo/tech/comp/fnv/index.html#FNV-param
26 static uint64_t FNV1a_64_Hash(base::StringPiece data); 26 static uint64_t FNV1a_64_Hash(QuicStringPiece data);
27 27
28 // Returns the 128 bit FNV1a hash of the data. See 28 // Returns the 128 bit FNV1a hash of the data. See
29 // http://www.isthe.com/chongo/tech/comp/fnv/index.html#FNV-param 29 // http://www.isthe.com/chongo/tech/comp/fnv/index.html#FNV-param
30 static uint128 FNV1a_128_Hash(base::StringPiece data); 30 static uint128 FNV1a_128_Hash(QuicStringPiece data);
31 31
32 // Returns the 128 bit FNV1a hash of the two sequences of data. See 32 // Returns the 128 bit FNV1a hash of the two sequences of data. See
33 // http://www.isthe.com/chongo/tech/comp/fnv/index.html#FNV-param 33 // http://www.isthe.com/chongo/tech/comp/fnv/index.html#FNV-param
34 static uint128 FNV1a_128_Hash_Two(base::StringPiece data1, 34 static uint128 FNV1a_128_Hash_Two(QuicStringPiece data1,
35 base::StringPiece data2); 35 QuicStringPiece data2);
36 36
37 // Returns the 128 bit FNV1a hash of the three sequences of data. See 37 // Returns the 128 bit FNV1a hash of the three sequences of data. See
38 // http://www.isthe.com/chongo/tech/comp/fnv/index.html#FNV-param 38 // http://www.isthe.com/chongo/tech/comp/fnv/index.html#FNV-param
39 static uint128 FNV1a_128_Hash_Three(base::StringPiece data1, 39 static uint128 FNV1a_128_Hash_Three(QuicStringPiece data1,
40 base::StringPiece data2, 40 QuicStringPiece data2,
41 base::StringPiece data3); 41 QuicStringPiece data3);
42 42
43 // SerializeUint128 writes the first 96 bits of |v| in little-endian form 43 // SerializeUint128 writes the first 96 bits of |v| in little-endian form
44 // to |out|. 44 // to |out|.
45 static void SerializeUint128Short(uint128 v, uint8_t* out); 45 static void SerializeUint128Short(uint128 v, uint8_t* out);
46 46
47 // Returns the level of encryption as a char* 47 // Returns the level of encryption as a char*
48 static const char* EncryptionLevelToString(EncryptionLevel level); 48 static const char* EncryptionLevelToString(EncryptionLevel level);
49 49
50 // Returns TransmissionType as a char* 50 // Returns TransmissionType as a char*
51 static const char* TransmissionTypeToString(TransmissionType type); 51 static const char* TransmissionTypeToString(TransmissionType type);
52 52
53 // Returns PeerAddressChangeType as a std::string. 53 // Returns PeerAddressChangeType as a std::string.
54 static std::string PeerAddressChangeTypeToString(PeerAddressChangeType type); 54 static std::string PeerAddressChangeTypeToString(PeerAddressChangeType type);
55 55
56 // Determines and returns change type of address change from |old_address| to 56 // Determines and returns change type of address change from |old_address| to
57 // |new_address|. 57 // |new_address|.
58 static PeerAddressChangeType DetermineAddressChangeType( 58 static PeerAddressChangeType DetermineAddressChangeType(
59 const QuicSocketAddress& old_address, 59 const QuicSocketAddress& old_address,
60 const QuicSocketAddress& new_address); 60 const QuicSocketAddress& new_address);
61 61
62 private: 62 private:
63 DISALLOW_COPY_AND_ASSIGN(QuicUtils); 63 DISALLOW_COPY_AND_ASSIGN(QuicUtils);
64 }; 64 };
65 65
66 } // namespace net 66 } // namespace net
67 67
68 #endif // NET_QUIC_CORE_QUIC_UTILS_H_ 68 #endif // NET_QUIC_CORE_QUIC_UTILS_H_
OLDNEW
« no previous file with comments | « net/quic/core/quic_stream_test.cc ('k') | net/quic/core/quic_utils.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698