Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 HostPortPair endpoint = HostPortPair( |
| 53 request.url.EffectiveIntPort()); | 53 request.url.HostNoBrackets(), |
| 54 static_cast<uint16>(request.url.EffectiveIntPort())); | |
|
mmenke
2014/11/18 21:06:39
While you're here, this is just HostPortPair::From
Peter Kasting
2014/11/18 23:38:43
Done.
| |
| 54 HpackEncoder* encoder = ObtainEncoder( | 55 HpackEncoder* encoder = ObtainEncoder( |
| 55 SpdySessionKey(endpoint, proxy, request.privacy_mode)); | 56 SpdySessionKey(endpoint, proxy, request.privacy_mode)); |
| 56 | 57 |
| 57 // Convert and encode the request and response header sets. | 58 // Convert and encode the request and response header sets. |
| 58 { | 59 { |
| 59 SpdyHeaderBlock headers; | 60 SpdyHeaderBlock headers; |
| 60 CreateSpdyHeadersFromHttpRequest( | 61 CreateSpdyHeadersFromHttpRequest( |
| 61 request, request_headers, SPDY4, false, &headers); | 62 request, request_headers, SPDY4, false, &headers); |
| 62 | 63 |
| 63 std::string tmp_out; | 64 std::string tmp_out; |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 101 (*headers_out)[name] += std::string(1, '\0') + value; | 102 (*headers_out)[name] += std::string(1, '\0') + value; |
| 102 } | 103 } |
| 103 } | 104 } |
| 104 (*headers_out)[":status"] = base::IntToString(headers.response_code()); | 105 (*headers_out)[":status"] = base::IntToString(headers.response_code()); |
| 105 } | 106 } |
| 106 | 107 |
| 107 // static | 108 // static |
| 108 bool HpackHuffmanAggregator::IsCrossOrigin(const HttpRequestInfo& request) { | 109 bool HpackHuffmanAggregator::IsCrossOrigin(const HttpRequestInfo& request) { |
| 109 // Require that the request is top-level, or that it shares | 110 // Require that the request is top-level, or that it shares |
| 110 // an origin with its referer. | 111 // an origin with its referer. |
| 111 HostPortPair endpoint = HostPortPair(request.url.HostNoBrackets(), | 112 HostPortPair endpoint = HostPortPair( |
| 112 request.url.EffectiveIntPort()); | 113 request.url.HostNoBrackets(), |
| 114 static_cast<uint16>(request.url.EffectiveIntPort())); | |
|
mmenke
2014/11/18 21:06:39
HostPortPair::FromURL(request.url)
Peter Kasting
2014/11/18 23:38:43
Done.
| |
| 113 if ((request.load_flags & LOAD_MAIN_FRAME) == 0) { | 115 if ((request.load_flags & LOAD_MAIN_FRAME) == 0) { |
| 114 std::string referer_str; | 116 std::string referer_str; |
| 115 if (!request.extra_headers.GetHeader(HttpRequestHeaders::kReferer, | 117 if (!request.extra_headers.GetHeader(HttpRequestHeaders::kReferer, |
| 116 &referer_str)) { | 118 &referer_str)) { |
| 117 // Require a referer. | 119 // Require a referer. |
| 118 return true; | 120 return true; |
| 119 } | 121 } |
| 120 GURL referer(referer_str); | 122 GURL referer(referer_str); |
| 121 HostPortPair referer_endpoint = HostPortPair(referer.HostNoBrackets(), | 123 HostPortPair referer_endpoint = HostPortPair( |
| 122 referer.EffectiveIntPort()); | 124 referer.HostNoBrackets(), |
| 125 static_cast<uint16>(referer.EffectiveIntPort())); | |
|
mmenke
2014/11/18 21:06:39
HostPortPair::FromURL(request.url)
Peter Kasting
2014/11/18 23:38:43
Done.
| |
| 123 if (!endpoint.Equals(referer_endpoint)) { | 126 if (!endpoint.Equals(referer_endpoint)) { |
| 124 // Cross-origin request. | 127 // Cross-origin request. |
| 125 return true; | 128 return true; |
| 126 } | 129 } |
| 127 } | 130 } |
| 128 return false; | 131 return false; |
| 129 } | 132 } |
| 130 | 133 |
| 131 HpackEncoder* HpackHuffmanAggregator::ObtainEncoder(const SpdySessionKey& key) { | 134 HpackEncoder* HpackHuffmanAggregator::ObtainEncoder(const SpdySessionKey& key) { |
| 132 for (OriginEncoders::iterator it = encoders_.begin(); | 135 for (OriginEncoders::iterator it = encoders_.begin(); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 174 base::LinearHistogram::FactoryGet( | 177 base::LinearHistogram::FactoryGet( |
| 175 kHistogramName, kRangeMin, kRangeMax, kBucketCount, | 178 kHistogramName, kRangeMin, kRangeMax, kBucketCount, |
| 176 base::HistogramBase::kUmaTargetedHistogramFlag)); | 179 base::HistogramBase::kUmaTargetedHistogramFlag)); |
| 177 | 180 |
| 178 // Clear counts. | 181 // Clear counts. |
| 179 counts_.assign(counts_.size(), 0); | 182 counts_.assign(counts_.size(), 0); |
| 180 total_counts_ = 0; | 183 total_counts_ = 0; |
| 181 } | 184 } |
| 182 | 185 |
| 183 } // namespace net | 186 } // namespace net |
| OLD | NEW |