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

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

Issue 862133002: Update from https://crrev.com/312398 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 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
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 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 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 SPDY4: 97 case SPDY4:
98 case SPDY5:
99 frame->data()[4] = flags; 98 frame->data()[4] = flags;
100 break; 99 break;
101 default: 100 default:
102 LOG(FATAL) << "Unsupported SPDY version."; 101 LOG(FATAL) << "Unsupported SPDY version.";
103 } 102 }
104 } 103 }
105 104
106 void SetFrameLength(SpdyFrame* frame, 105 void SetFrameLength(SpdyFrame* frame,
107 size_t length, 106 size_t length,
108 SpdyMajorVersion spdy_version) { 107 SpdyMajorVersion spdy_version) {
109 switch (spdy_version) { 108 switch (spdy_version) {
110 case SPDY2: 109 case SPDY2:
111 case SPDY3: 110 case SPDY3:
112 CHECK_EQ(0u, length & ~kLengthMask); 111 CHECK_EQ(0u, length & ~kLengthMask);
113 { 112 {
114 int32 wire_length = base::HostToNet32(length); 113 int32 wire_length = base::HostToNet32(length);
115 // 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
116 // offset 5. 115 // offset 5.
117 memcpy(frame->data() + 5, reinterpret_cast<char*>(&wire_length) + 1, 3); 116 memcpy(frame->data() + 5, reinterpret_cast<char*>(&wire_length) + 1, 3);
118 } 117 }
119 break; 118 break;
120 case SPDY4: 119 case SPDY4:
121 case SPDY5:
122 CHECK_GT(1u<<14, length); 120 CHECK_GT(1u<<14, length);
123 { 121 {
124 int32 wire_length = base::HostToNet32(length); 122 int32 wire_length = base::HostToNet32(length);
125 memcpy(frame->data(), 123 memcpy(frame->data(),
126 reinterpret_cast<char*>(&wire_length) + 1, 124 reinterpret_cast<char*>(&wire_length) + 1,
127 3); 125 3);
128 } 126 }
129 break; 127 break;
130 default: 128 default:
131 LOG(FATAL) << "Unsupported SPDY version."; 129 LOG(FATAL) << "Unsupported SPDY version.";
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 // Construct a fake SSLInfo that will pass AddHPKPHeader's checks. 164 // Construct a fake SSLInfo that will pass AddHPKPHeader's checks.
167 SSLInfo ssl_info; 165 SSLInfo ssl_info;
168 ssl_info.is_issued_by_known_root = true; 166 ssl_info.is_issued_by_known_root = true;
169 ssl_info.public_key_hashes.push_back(GetTestHashValue(primary_label)); 167 ssl_info.public_key_hashes.push_back(GetTestHashValue(primary_label));
170 EXPECT_TRUE(state->AddHPKPHeader(host, header, ssl_info)); 168 EXPECT_TRUE(state->AddHPKPHeader(host, header, ssl_info));
171 } 169 }
172 170
173 } // namespace test 171 } // namespace test
174 172
175 } // namespace net 173 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698