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

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

Issue 485833002: HTTP2 draft 14 support (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add ignore_result(). Created 6 years, 4 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/spdy/spdy_test_util_common.cc ('k') | net/tools/flip_server/spdy_interface.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/logging.h" 10 #include "base/logging.h"
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 << "\nActual:\n" 84 << "\nActual:\n"
85 << HexDumpWithMarks(actual, actual_len, marks.get(), max_len); 85 << HexDumpWithMarks(actual, actual_len, marks.get(), max_len);
86 } 86 }
87 87
88 void SetFrameFlags(SpdyFrame* frame, 88 void SetFrameFlags(SpdyFrame* frame,
89 uint8 flags, 89 uint8 flags,
90 SpdyMajorVersion spdy_version) { 90 SpdyMajorVersion spdy_version) {
91 switch (spdy_version) { 91 switch (spdy_version) {
92 case SPDY2: 92 case SPDY2:
93 case SPDY3: 93 case SPDY3:
94 frame->data()[4] = flags;
95 break;
96 case SPDY4: 94 case SPDY4:
97 case SPDY5: 95 case SPDY5:
98 frame->data()[3] = flags; 96 frame->data()[4] = flags;
99 break; 97 break;
100 default: 98 default:
101 LOG(FATAL) << "Unsupported SPDY version."; 99 LOG(FATAL) << "Unsupported SPDY version.";
102 } 100 }
103 } 101 }
104 102
105 void SetFrameLength(SpdyFrame* frame, 103 void SetFrameLength(SpdyFrame* frame,
106 size_t length, 104 size_t length,
107 SpdyMajorVersion spdy_version) { 105 SpdyMajorVersion spdy_version) {
108 switch (spdy_version) { 106 switch (spdy_version) {
109 case SPDY2: 107 case SPDY2:
110 case SPDY3: 108 case SPDY3:
111 CHECK_EQ(0u, length & ~kLengthMask); 109 CHECK_EQ(0u, length & ~kLengthMask);
112 { 110 {
113 int32 wire_length = base::HostToNet32(length); 111 int32 wire_length = base::HostToNet32(length);
114 // The length field in SPDY 2 and 3 is a 24-bit (3B) integer starting at 112 // The length field in SPDY 2 and 3 is a 24-bit (3B) integer starting at
115 // offset 5. 113 // offset 5.
116 memcpy(frame->data() + 5, reinterpret_cast<char*>(&wire_length) + 1, 3); 114 memcpy(frame->data() + 5, reinterpret_cast<char*>(&wire_length) + 1, 3);
117 } 115 }
118 break; 116 break;
119 case SPDY4: 117 case SPDY4:
120 case SPDY5: 118 case SPDY5:
121 CHECK_GT(1u<<14, length); 119 CHECK_GT(1u<<14, length);
122 { 120 {
123 int32 wire_length = base::HostToNet16(static_cast<uint16>(length)); 121 int32 wire_length = base::HostToNet32(length);
124 memcpy(frame->data(), 122 memcpy(frame->data(),
125 reinterpret_cast<char*>(&wire_length), 123 reinterpret_cast<char*>(&wire_length) + 1,
126 sizeof(uint16)); 124 3);
127 } 125 }
128 break; 126 break;
129 default: 127 default:
130 LOG(FATAL) << "Unsupported SPDY version."; 128 LOG(FATAL) << "Unsupported SPDY version.";
131 } 129 }
132 } 130 }
133 131
134 std::string a2b_hex(const char* hex_data) { 132 std::string a2b_hex(const char* hex_data) {
135 std::vector<uint8> output; 133 std::vector<uint8> output;
136 std::string result; 134 std::string result;
137 if (base::HexStringToBytes(hex_data, &output)) 135 if (base::HexStringToBytes(hex_data, &output))
138 result.assign(reinterpret_cast<const char*>(&output[0]), output.size()); 136 result.assign(reinterpret_cast<const char*>(&output[0]), output.size());
139 return result; 137 return result;
140 } 138 }
141 139
142 } // namespace test 140 } // namespace test
143 141
144 } // namespace net 142 } // namespace net
OLDNEW
« no previous file with comments | « net/spdy/spdy_test_util_common.cc ('k') | net/tools/flip_server/spdy_interface.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698