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

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

Issue 754433003: Update from https://crrev.com/305340 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years 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/buffered_spdy_framer_unittest.cc ('k') | net/spdy/spdy_framer.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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 #include "net/spdy/hpack_huffman_aggregator.h" 4 #include "net/spdy/hpack_huffman_aggregator.h"
5 5
6 #include "base/metrics/bucket_ranges.h" 6 #include "base/metrics/bucket_ranges.h"
7 #include "base/metrics/field_trial.h" 7 #include "base/metrics/field_trial.h"
8 #include "base/metrics/histogram.h" 8 #include "base/metrics/histogram.h"
9 #include "base/metrics/sample_vector.h" 9 #include "base/metrics/sample_vector.h"
10 #include "base/stl_util.h" 10 #include "base/stl_util.h"
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 } 42 }
43 43
44 void HpackHuffmanAggregator::AggregateTransactionCharacterCounts( 44 void HpackHuffmanAggregator::AggregateTransactionCharacterCounts(
45 const HttpRequestInfo& request, 45 const HttpRequestInfo& request,
46 const HttpRequestHeaders& request_headers, 46 const HttpRequestHeaders& request_headers,
47 const ProxyServer& proxy, 47 const ProxyServer& proxy,
48 const HttpResponseHeaders& response_headers) { 48 const HttpResponseHeaders& response_headers) {
49 if (IsCrossOrigin(request)) { 49 if (IsCrossOrigin(request)) {
50 return; 50 return;
51 } 51 }
52 HostPortPair endpoint = HostPortPair(request.url.HostNoBrackets(), 52 HpackEncoder* encoder = ObtainEncoder(SpdySessionKey(
53 request.url.EffectiveIntPort()); 53 HostPortPair::FromURL(request.url), proxy, request.privacy_mode));
54 HpackEncoder* encoder = ObtainEncoder(
55 SpdySessionKey(endpoint, proxy, request.privacy_mode));
56 54
57 // Convert and encode the request and response header sets. 55 // Convert and encode the request and response header sets.
58 { 56 {
59 SpdyHeaderBlock headers; 57 SpdyHeaderBlock headers;
60 CreateSpdyHeadersFromHttpRequest( 58 CreateSpdyHeadersFromHttpRequest(
61 request, request_headers, SPDY4, false, &headers); 59 request, request_headers, SPDY4, false, &headers);
62 60
63 std::string tmp_out; 61 std::string tmp_out;
64 encoder->EncodeHeaderSet(headers, &tmp_out); 62 encoder->EncodeHeaderSet(headers, &tmp_out);
65 } 63 }
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 (*headers_out)[name] += std::string(1, '\0') + value; 99 (*headers_out)[name] += std::string(1, '\0') + value;
102 } 100 }
103 } 101 }
104 (*headers_out)[":status"] = base::IntToString(headers.response_code()); 102 (*headers_out)[":status"] = base::IntToString(headers.response_code());
105 } 103 }
106 104
107 // static 105 // static
108 bool HpackHuffmanAggregator::IsCrossOrigin(const HttpRequestInfo& request) { 106 bool HpackHuffmanAggregator::IsCrossOrigin(const HttpRequestInfo& request) {
109 // Require that the request is top-level, or that it shares 107 // Require that the request is top-level, or that it shares
110 // an origin with its referer. 108 // an origin with its referer.
111 HostPortPair endpoint = HostPortPair(request.url.HostNoBrackets(),
112 request.url.EffectiveIntPort());
113 if ((request.load_flags & LOAD_MAIN_FRAME) == 0) { 109 if ((request.load_flags & LOAD_MAIN_FRAME) == 0) {
114 std::string referer_str; 110 std::string referer_str;
115 if (!request.extra_headers.GetHeader(HttpRequestHeaders::kReferer, 111 if (!request.extra_headers.GetHeader(HttpRequestHeaders::kReferer,
116 &referer_str)) { 112 &referer_str)) {
117 // Require a referer. 113 // Require a referer.
118 return true; 114 return true;
119 } 115 }
120 GURL referer(referer_str); 116 GURL referer(referer_str);
121 HostPortPair referer_endpoint = HostPortPair(referer.HostNoBrackets(), 117 if (!HostPortPair::FromURL(request.url).Equals(
122 referer.EffectiveIntPort()); 118 HostPortPair::FromURL(referer))) {
123 if (!endpoint.Equals(referer_endpoint)) {
124 // Cross-origin request. 119 // Cross-origin request.
125 return true; 120 return true;
126 } 121 }
127 } 122 }
128 return false; 123 return false;
129 } 124 }
130 125
131 HpackEncoder* HpackHuffmanAggregator::ObtainEncoder(const SpdySessionKey& key) { 126 HpackEncoder* HpackHuffmanAggregator::ObtainEncoder(const SpdySessionKey& key) {
132 for (OriginEncoders::iterator it = encoders_.begin(); 127 for (OriginEncoders::iterator it = encoders_.begin();
133 it != encoders_.end(); ++it) { 128 it != encoders_.end(); ++it) {
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 base::LinearHistogram::FactoryGet( 169 base::LinearHistogram::FactoryGet(
175 kHistogramName, kRangeMin, kRangeMax, kBucketCount, 170 kHistogramName, kRangeMin, kRangeMax, kBucketCount,
176 base::HistogramBase::kUmaTargetedHistogramFlag)); 171 base::HistogramBase::kUmaTargetedHistogramFlag));
177 172
178 // Clear counts. 173 // Clear counts.
179 counts_.assign(counts_.size(), 0); 174 counts_.assign(counts_.size(), 0);
180 total_counts_ = 0; 175 total_counts_ = 0;
181 } 176 }
182 177
183 } // namespace net 178 } // namespace net
OLDNEW
« no previous file with comments | « net/spdy/buffered_spdy_framer_unittest.cc ('k') | net/spdy/spdy_framer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698