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

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

Issue 2801603003: Add SpdyString alias for std::string in net/spdy. (Closed)
Patch Set: Created 3 years, 8 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/fuzzing/hpack_fuzz_util_test.cc ('k') | net/spdy/header_coalescer_test.cc » ('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) 2016 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2016 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/header_coalescer.h" 5 #include "net/spdy/header_coalescer.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/strings/string_util.h" 9 #include "base/strings/string_util.h"
10 #include "net/http/http_util.h" 10 #include "net/http/http_util.h"
11 #include "net/spdy/platform/api/spdy_estimate_memory_usage.h" 11 #include "net/spdy/platform/api/spdy_estimate_memory_usage.h"
12 #include "net/spdy/platform/api/spdy_string.h"
12 13
13 namespace net { 14 namespace net {
14 15
15 const size_t kMaxHeaderListSize = 256 * 1024; 16 const size_t kMaxHeaderListSize = 256 * 1024;
16 17
17 void HeaderCoalescer::OnHeader(SpdyStringPiece key, SpdyStringPiece value) { 18 void HeaderCoalescer::OnHeader(SpdyStringPiece key, SpdyStringPiece value) {
18 if (error_seen_) { 19 if (error_seen_) {
19 return; 20 return;
20 } 21 }
21 22
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 error_seen_ = true; 55 error_seen_ = true;
55 return; 56 return;
56 } 57 }
57 58
58 auto iter = headers_.find(key); 59 auto iter = headers_.find(key);
59 if (iter == headers_.end()) { 60 if (iter == headers_.end()) {
60 headers_[key] = value; 61 headers_[key] = value;
61 } else { 62 } else {
62 // This header had multiple values, so it must be reconstructed. 63 // This header had multiple values, so it must be reconstructed.
63 SpdyStringPiece v = iter->second; 64 SpdyStringPiece v = iter->second;
64 std::string s(v.data(), v.length()); 65 SpdyString s(v.data(), v.length());
65 if (key == "cookie") { 66 if (key == "cookie") {
66 // Obeys section 8.1.2.5 in RFC 7540 for cookie reconstruction. 67 // Obeys section 8.1.2.5 in RFC 7540 for cookie reconstruction.
67 s.append("; "); 68 s.append("; ");
68 } else { 69 } else {
69 SpdyStringPiece("\0", 1).AppendToString(&s); 70 SpdyStringPiece("\0", 1).AppendToString(&s);
70 } 71 }
71 value.AppendToString(&s); 72 value.AppendToString(&s);
72 headers_[key] = s; 73 headers_[key] = s;
73 } 74 }
74 } 75 }
75 76
76 SpdyHeaderBlock HeaderCoalescer::release_headers() { 77 SpdyHeaderBlock HeaderCoalescer::release_headers() {
77 DCHECK(headers_valid_); 78 DCHECK(headers_valid_);
78 headers_valid_ = false; 79 headers_valid_ = false;
79 return std::move(headers_); 80 return std::move(headers_);
80 } 81 }
81 82
82 size_t HeaderCoalescer::EstimateMemoryUsage() const { 83 size_t HeaderCoalescer::EstimateMemoryUsage() const {
83 return SpdyEstimateMemoryUsage(headers_); 84 return SpdyEstimateMemoryUsage(headers_);
84 } 85 }
85 86
86 } // namespace net 87 } // namespace net
OLDNEW
« no previous file with comments | « net/spdy/fuzzing/hpack_fuzz_util_test.cc ('k') | net/spdy/header_coalescer_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698