[Android WebView] Fix webview perf bot switchover to use org.chromium.webview_shell...
[chromium-blink-merge.git] / net / quic / spdy_utils.cc
blob2db7eb0bf4fd579e0bf9b5060f0daa0940b9f8f0
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "net/quic/spdy_utils.h"
7 #include "base/memory/scoped_ptr.h"
8 #include "net/spdy/spdy_frame_builder.h"
9 #include "net/spdy/spdy_framer.h"
10 #include "net/spdy/spdy_protocol.h"
12 using std::string;
14 namespace net {
16 // static
17 SpdyMajorVersion SpdyUtils::GetSpdyVersionForQuicVersion(
18 QuicVersion quic_version) {
19 if (quic_version > QUIC_VERSION_24) {
20 return SPDY4;
22 return SPDY3;
25 // static
26 SpdyHeaderBlock SpdyUtils::ConvertSpdy3ResponseHeadersToSpdy4(
27 SpdyHeaderBlock response_headers) {
28 // SPDY/4 headers include neither the version field nor the response details.
29 response_headers.erase(":version");
30 size_t end_of_code = response_headers[":status"].find(' ');
31 if (end_of_code != string::npos) {
32 response_headers[":status"].erase(end_of_code);
34 return response_headers;
37 // static
38 string SpdyUtils::SerializeUncompressedHeaders(const SpdyHeaderBlock& headers,
39 QuicVersion quic_version) {
40 SpdyMajorVersion spdy_version = GetSpdyVersionForQuicVersion(quic_version);
42 size_t length = SpdyFramer::GetSerializedLength(spdy_version, &headers);
43 SpdyFrameBuilder builder(length, spdy_version);
44 SpdyFramer::WriteHeaderBlock(&builder, spdy_version, &headers);
45 scoped_ptr<SpdyFrame> block(builder.take());
46 return string(block->data(), length);
49 } // namespace net