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

Side by Side Diff: net/spdy/spdy_test_utils.cc

Issue 1535363003: Switch to standard integer types in net/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: stddef Created 5 years 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/spdy/spdy_test_utils.h ('k') | net/spdy/spdy_write_queue.h » ('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 #include "net/spdy/spdy_test_utils.h" 5 #include "net/spdy/spdy_test_utils.h"
6 6
7 #include <cstring> 7 #include <cstring>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/base64.h" 10 #include "base/base64.h"
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 ADD_FAILURE() 82 ADD_FAILURE()
83 << "Description:\n" 83 << "Description:\n"
84 << description 84 << description
85 << "\n\nExpected:\n" 85 << "\n\nExpected:\n"
86 << HexDumpWithMarks(expected, expected_len, marks.get(), max_len) 86 << HexDumpWithMarks(expected, expected_len, marks.get(), max_len)
87 << "\nActual:\n" 87 << "\nActual:\n"
88 << HexDumpWithMarks(actual, actual_len, marks.get(), max_len); 88 << HexDumpWithMarks(actual, actual_len, marks.get(), max_len);
89 } 89 }
90 90
91 void SetFrameFlags(SpdyFrame* frame, 91 void SetFrameFlags(SpdyFrame* frame,
92 uint8 flags, 92 uint8_t flags,
93 SpdyMajorVersion spdy_version) { 93 SpdyMajorVersion spdy_version) {
94 switch (spdy_version) { 94 switch (spdy_version) {
95 case SPDY2: 95 case SPDY2:
96 case SPDY3: 96 case SPDY3:
97 case HTTP2: 97 case HTTP2:
98 frame->data()[4] = flags; 98 frame->data()[4] = flags;
99 break; 99 break;
100 default: 100 default:
101 LOG(FATAL) << "Unsupported SPDY version."; 101 LOG(FATAL) << "Unsupported SPDY version.";
102 } 102 }
103 } 103 }
104 104
105 void SetFrameLength(SpdyFrame* frame, 105 void SetFrameLength(SpdyFrame* frame,
106 size_t length, 106 size_t length,
107 SpdyMajorVersion spdy_version) { 107 SpdyMajorVersion spdy_version) {
108 switch (spdy_version) { 108 switch (spdy_version) {
109 case SPDY2: 109 case SPDY2:
110 case SPDY3: 110 case SPDY3:
111 CHECK_EQ(0u, length & ~kLengthMask); 111 CHECK_EQ(0u, length & ~kLengthMask);
112 { 112 {
113 int32 wire_length = base::HostToNet32(length); 113 int32_t wire_length = base::HostToNet32(length);
114 // The length field in SPDY 2 and 3 is a 24-bit (3B) integer starting at 114 // The length field in SPDY 2 and 3 is a 24-bit (3B) integer starting at
115 // offset 5. 115 // offset 5.
116 memcpy(frame->data() + 5, reinterpret_cast<char*>(&wire_length) + 1, 3); 116 memcpy(frame->data() + 5, reinterpret_cast<char*>(&wire_length) + 1, 3);
117 } 117 }
118 break; 118 break;
119 case HTTP2: 119 case HTTP2:
120 CHECK_GT(1u<<14, length); 120 CHECK_GT(1u<<14, length);
121 { 121 {
122 int32 wire_length = base::HostToNet32(length); 122 int32_t wire_length = base::HostToNet32(length);
123 memcpy(frame->data(), 123 memcpy(frame->data(),
124 reinterpret_cast<char*>(&wire_length) + 1, 124 reinterpret_cast<char*>(&wire_length) + 1,
125 3); 125 3);
126 } 126 }
127 break; 127 break;
128 default: 128 default:
129 LOG(FATAL) << "Unsupported SPDY version."; 129 LOG(FATAL) << "Unsupported SPDY version.";
130 } 130 }
131 } 131 }
132 132
133 std::string a2b_hex(const char* hex_data) { 133 std::string a2b_hex(const char* hex_data) {
134 std::vector<uint8> output; 134 std::vector<uint8_t> output;
135 std::string result; 135 std::string result;
136 if (base::HexStringToBytes(hex_data, &output)) 136 if (base::HexStringToBytes(hex_data, &output))
137 result.assign(reinterpret_cast<const char*>(&output[0]), output.size()); 137 result.assign(reinterpret_cast<const char*>(&output[0]), output.size());
138 return result; 138 return result;
139 } 139 }
140 140
141 HashValue GetTestHashValue(uint8_t label) { 141 HashValue GetTestHashValue(uint8_t label) {
142 HashValue hash_value(HASH_VALUE_SHA256); 142 HashValue hash_value(HASH_VALUE_SHA256);
143 memset(hash_value.data(), label, hash_value.size()); 143 memset(hash_value.data(), label, hash_value.size());
144 return hash_value; 144 return hash_value;
(...skipping 18 matching lines...) Expand all
163 163
164 // Construct a fake SSLInfo that will pass AddHPKPHeader's checks. 164 // Construct a fake SSLInfo that will pass AddHPKPHeader's checks.
165 SSLInfo ssl_info; 165 SSLInfo ssl_info;
166 ssl_info.is_issued_by_known_root = true; 166 ssl_info.is_issued_by_known_root = true;
167 ssl_info.public_key_hashes.push_back(GetTestHashValue(primary_label)); 167 ssl_info.public_key_hashes.push_back(GetTestHashValue(primary_label));
168 EXPECT_TRUE(state->AddHPKPHeader(host, header, ssl_info)); 168 EXPECT_TRUE(state->AddHPKPHeader(host, header, ssl_info));
169 } 169 }
170 170
171 } // namespace test 171 } // namespace test
172 } // namespace net 172 } // namespace net
OLDNEW
« no previous file with comments | « net/spdy/spdy_test_utils.h ('k') | net/spdy/spdy_write_queue.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698