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

Side by Side Diff: net/quic/spdy_utils.cc

Issue 1776373003: Consolidate SpdyFramer::WriteHeaderBlock() and SerializeHeaderBlockWithoutCompression(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 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 | « no previous file | net/spdy/spdy_framer.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) 2013 The Chromium Authors. All rights reserved. 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 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/quic/spdy_utils.h" 5 #include "net/quic/spdy_utils.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/stl_util.h" 10 #include "base/stl_util.h"
11 #include "base/strings/string_number_conversions.h" 11 #include "base/strings/string_number_conversions.h"
12 #include "base/strings/string_split.h" 12 #include "base/strings/string_split.h"
13 #include "net/spdy/spdy_frame_builder.h" 13 #include "net/spdy/spdy_frame_builder.h"
14 #include "net/spdy/spdy_framer.h" 14 #include "net/spdy/spdy_framer.h"
15 #include "net/spdy/spdy_protocol.h" 15 #include "net/spdy/spdy_protocol.h"
16 #include "url/gurl.h" 16 #include "url/gurl.h"
17 17
18 using std::string; 18 using std::string;
19 using std::vector; 19 using std::vector;
20 20
21 namespace net { 21 namespace net {
22 22
23 // static 23 // static
24 string SpdyUtils::SerializeUncompressedHeaders(const SpdyHeaderBlock& headers) { 24 string SpdyUtils::SerializeUncompressedHeaders(const SpdyHeaderBlock& headers) {
25 SpdyMajorVersion spdy_version = HTTP2; 25 SpdyMajorVersion spdy_version = HTTP2;
26 26
27 size_t length = SpdyFramer::GetSerializedLength(spdy_version, &headers); 27 size_t length = SpdyFramer::GetSerializedLength(spdy_version, &headers);
28 SpdyFrameBuilder builder(length, spdy_version); 28 SpdyFrameBuilder builder(length, spdy_version);
29 SpdyFramer::WriteHeaderBlock(&builder, spdy_version, &headers); 29 SpdyFramer framer(spdy_version);
30 framer.SerializeHeaderBlockWithoutCompression(&builder, headers);
30 scoped_ptr<SpdyFrame> block(builder.take()); 31 scoped_ptr<SpdyFrame> block(builder.take());
31 return string(block->data(), length); 32 return string(block->data(), length);
32 } 33 }
33 34
34 // static 35 // static
35 bool SpdyUtils::ParseHeaders(const char* data, 36 bool SpdyUtils::ParseHeaders(const char* data,
36 uint32_t data_len, 37 uint32_t data_len,
37 int* content_length, 38 int* content_length,
38 SpdyHeaderBlock* headers) { 39 SpdyHeaderBlock* headers) {
39 SpdyFramer framer(HTTP2); 40 SpdyFramer framer(HTTP2);
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 return GURL(GetUrlFromHeaderBlock(headers)).host(); 133 return GURL(GetUrlFromHeaderBlock(headers)).host();
133 } 134 }
134 135
135 // static 136 // static
136 bool SpdyUtils::UrlIsValid(const SpdyHeaderBlock& headers) { 137 bool SpdyUtils::UrlIsValid(const SpdyHeaderBlock& headers) {
137 string url(GetUrlFromHeaderBlock(headers)); 138 string url(GetUrlFromHeaderBlock(headers));
138 return url != "" && GURL(url).is_valid(); 139 return url != "" && GURL(url).is_valid();
139 } 140 }
140 141
141 } // namespace net 142 } // namespace net
OLDNEW
« no previous file with comments | « no previous file | net/spdy/spdy_framer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698