OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include <list> |
| 6 #include <vector> |
| 7 |
| 8 #include "net/base/net_export.h" |
| 9 #include "net/spdy/spdy_header_block.h" |
| 10 #include "net/spdy/spdy_protocol.h" |
| 11 #include "net/spdy/spdy_session_key.h" |
| 12 |
| 13 namespace net { |
| 14 |
| 15 class HpackEncoder; |
| 16 class HttpRequestHeaders; |
| 17 struct HttpRequestInfo; |
| 18 class HttpResponseHeaders; |
| 19 class ProxyServer; |
| 20 |
| 21 namespace test { |
| 22 class HpackHuffmanAggregatorPeer; |
| 23 } // namespace test |
| 24 |
| 25 class NET_EXPORT_PRIVATE HpackHuffmanAggregator { |
| 26 public: |
| 27 friend class test::HpackHuffmanAggregatorPeer; |
| 28 |
| 29 HpackHuffmanAggregator(); |
| 30 ~HpackHuffmanAggregator(); |
| 31 |
| 32 // Encodes the request and response headers of the transaction with an |
| 33 // HpackEncoder keyed on the transaction's SpdySessionKey. Literal headers |
| 34 // emitted by that encoder are aggregated into internal character counts, |
| 35 // which are periodically published to a UMA histogram. |
| 36 void AggregateTransactionCharacterCounts( |
| 37 const HttpRequestInfo& request, |
| 38 const HttpRequestHeaders& request_headers, |
| 39 const ProxyServer& proxy, |
| 40 const HttpResponseHeaders& response_headers); |
| 41 |
| 42 // Returns whether the aggregator is enabled for the session by a field trial. |
| 43 static bool UseAggregator(); |
| 44 |
| 45 private: |
| 46 // Returns true if the request is considered cross-origin, |
| 47 // and should not be aggregated. |
| 48 static bool IsCrossOrigin(const HttpRequestInfo& request); |
| 49 |
| 50 // Converts |headers| into SPDY headers block |headers_out|. |
| 51 static void CreateSpdyHeadersFromHttpResponse( |
| 52 const HttpResponseHeaders& headers, |
| 53 SpdyHeaderBlock* headers_out); |
| 54 |
| 55 // Creates or returns an encoder for the origin key. |
| 56 HpackEncoder* ObtainEncoder(const SpdySessionKey& key); |
| 57 |
| 58 // Publishes aggregated counts to a UMA histogram. |
| 59 void PublishCounts(); |
| 60 |
| 61 typedef std::pair<SpdySessionKey, HpackEncoder*> OriginEncoder; |
| 62 typedef std::list<OriginEncoder> OriginEncoders; |
| 63 |
| 64 std::vector<size_t> counts_; |
| 65 size_t total_counts_; |
| 66 |
| 67 OriginEncoders encoders_; |
| 68 size_t max_encoders_; |
| 69 }; |
| 70 |
| 71 } // namespace net |
OLD | NEW |