Chromium Code Reviews| 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 #include "net/spdy/spdy_http_utils.h" | 5 #include "net/spdy/spdy_http_utils.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/string_number_conversions.h" | 9 #include "base/string_number_conversions.h" |
| 10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 121 (*headers)[":scheme"] = info.url.scheme(); | 121 (*headers)[":scheme"] = info.url.scheme(); |
| 122 (*headers)[":path"] = HttpUtil::PathForRequest(info.url); | 122 (*headers)[":path"] = HttpUtil::PathForRequest(info.url); |
| 123 headers->erase("host"); // this is kinda insane, spdy 3 spec. | 123 headers->erase("host"); // this is kinda insane, spdy 3 spec. |
| 124 } | 124 } |
| 125 | 125 |
| 126 } | 126 } |
| 127 | 127 |
| 128 SpdyPriority ConvertRequestPriorityToSpdyPriority( | 128 SpdyPriority ConvertRequestPriorityToSpdyPriority( |
| 129 const RequestPriority priority, | 129 const RequestPriority priority, |
| 130 int protocol_version) { | 130 int protocol_version) { |
| 131 DCHECK(HIGHEST <= priority && priority < NUM_PRIORITIES); | 131 DCHECK_GE(priority, MINIMUM_PRIORITY); |
|
Ryan Hamilton
2012/04/23 22:51:05
One minor problem. The CQ is about to land this C
szym
2012/04/24 00:19:31
Thanks for the heads up.
| |
| 132 DCHECK_LT(priority, NUM_PRIORITIES); | |
| 132 if (protocol_version == 2) { | 133 if (protocol_version == 2) { |
| 133 switch (priority) { | 134 switch (priority) { |
| 135 case HIGHEST: | |
| 136 return SPDY_PRIORITY_HIGHEST; | |
| 137 case MEDIUM: | |
| 138 return SPDY_PRIORITY_HIGHEST + 1; | |
| 139 case LOW: | |
| 140 return SPDY_PRIORITY_HIGHEST + 2; | |
| 134 case LOWEST: | 141 case LOWEST: |
| 135 return SPDY_PRIORITY_LOWEST - 1; | 142 return SPDY_PRIORITY_LOWEST - 1; |
| 136 case IDLE: | 143 case IDLE: |
| 137 return SPDY_PRIORITY_LOWEST; | 144 return SPDY_PRIORITY_LOWEST; |
| 138 default: | 145 default: |
| 139 return priority; | 146 NOTREACHED(); |
| 147 return SpdyPriority(); | |
| 140 } | 148 } |
| 141 } else { | 149 } else { |
| 142 return priority; | 150 switch (priority) { |
|
szym
2012/04/24 00:19:31
Do you think this switch would be better expressed
Ryan Hamilton
2012/04/24 00:42:11
Yup, that sounds great. The SPDY 2 case could be
| |
| 151 case HIGHEST: | |
| 152 return SPDY_PRIORITY_HIGHEST; | |
| 153 case MEDIUM: | |
| 154 return SPDY_PRIORITY_HIGHEST + 1; | |
| 155 case LOW: | |
| 156 return SPDY_PRIORITY_HIGHEST + 2; | |
| 157 case LOWEST: | |
| 158 return SPDY_PRIORITY_HIGHEST + 3; | |
| 159 case IDLE: | |
| 160 return SPDY_PRIORITY_HIGHEST + 4; | |
| 161 default: | |
| 162 NOTREACHED(); | |
| 163 return SpdyPriority(); | |
| 164 } | |
| 143 } | 165 } |
| 144 } | 166 } |
| 145 | 167 |
| 146 GURL GetUrlFromHeaderBlock(const SpdyHeaderBlock& headers, | 168 GURL GetUrlFromHeaderBlock(const SpdyHeaderBlock& headers, |
| 147 int protocol_version, | 169 int protocol_version, |
| 148 bool pushed) { | 170 bool pushed) { |
| 149 // SPDY 2 server push urls are specified in a single "url" header. | 171 // SPDY 2 server push urls are specified in a single "url" header. |
| 150 if (pushed && protocol_version == 2) { | 172 if (pushed && protocol_version == 2) { |
| 151 std::string url; | 173 std::string url; |
| 152 SpdyHeaderBlock::const_iterator it; | 174 SpdyHeaderBlock::const_iterator it; |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 173 it = headers.find(path_header); | 195 it = headers.find(path_header); |
| 174 if (it != headers.end()) | 196 if (it != headers.end()) |
| 175 path = it->second; | 197 path = it->second; |
| 176 | 198 |
| 177 std::string url = (scheme.empty() || host_port.empty() || path.empty()) | 199 std::string url = (scheme.empty() || host_port.empty() || path.empty()) |
| 178 ? "" : scheme + "://" + host_port + path; | 200 ? "" : scheme + "://" + host_port + path; |
| 179 return GURL(url); | 201 return GURL(url); |
| 180 } | 202 } |
| 181 | 203 |
| 182 } // namespace net | 204 } // namespace net |
| OLD | NEW |