OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2011 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 #ifndef NET_HTTP_HTTP_PIPELINED_HOST_POOL_H_ |
| 6 #define NET_HTTP_HTTP_PIPELINED_HOST_POOL_H_ |
| 7 #pragma once |
| 8 |
| 9 #include <map> |
| 10 |
| 11 #include "base/basictypes.h" |
| 12 #include "net/http/http_pipelined_host.h" |
| 13 |
| 14 namespace net { |
| 15 |
| 16 class HostPortPair; |
| 17 class HttpPipelinedStream; |
| 18 class HttpStreamFactoryImpl; |
| 19 |
| 20 // Manages all of the pipelining state for specific host with active pipelined |
| 21 // HTTP requests. Manages connection jobs, constructs pipelined streams, and |
| 22 // assigns requests to the least loaded pipelined connection. |
| 23 class HttpPipelinedHostPool : public HttpPipelinedHost::Delegate { |
| 24 public: |
| 25 explicit HttpPipelinedHostPool(HttpStreamFactoryImpl* factory); |
| 26 ~HttpPipelinedHostPool(); |
| 27 |
| 28 // Constructs a new pipeline on |connection| and returns a new |
| 29 // HttpPipelinedStream that uses it. |
| 30 HttpPipelinedStream* CreateStreamOnNewPipeline( |
| 31 const HostPortPair& origin, |
| 32 ClientSocketHandle* connection, |
| 33 const SSLConfig& used_ssl_config, |
| 34 const ProxyInfo& used_proxy_info, |
| 35 const BoundNetLog& net_log, |
| 36 bool was_npn_negotiated); |
| 37 |
| 38 // Tries to find an existing pipeline with capacity for a new request. If |
| 39 // successful, returns a new stream on that pipeline. Otherwise, returns NULL. |
| 40 HttpPipelinedStream* CreateStreamOnExistingPipeline( |
| 41 const HostPortPair& origin); |
| 42 |
| 43 // Returns true if a pipelined connection already exists for this origin and |
| 44 // can accept new requests. |
| 45 bool IsExistingPipelineAvailableForOrigin(const HostPortPair& origin); |
| 46 |
| 47 // Callbacks for HttpPipelinedHost. |
| 48 virtual void OnHostIdle(HttpPipelinedHost* host) OVERRIDE; |
| 49 |
| 50 virtual void OnHostHasAdditionalCapacity(HttpPipelinedHost* host) OVERRIDE; |
| 51 |
| 52 private: |
| 53 typedef std::map<const HostPortPair, HttpPipelinedHost*> HostMap; |
| 54 |
| 55 HttpPipelinedHost* GetPipelinedHost(const HostPortPair& origin, |
| 56 bool create_if_not_found); |
| 57 |
| 58 HttpStreamFactoryImpl* factory_; |
| 59 HostMap host_map_; |
| 60 |
| 61 DISALLOW_COPY_AND_ASSIGN(HttpPipelinedHostPool); |
| 62 }; |
| 63 |
| 64 } // namespace net |
| 65 |
| 66 #endif // NET_HTTP_HTTP_PIPELINED_HOST_POOL_H_ |
OLD | NEW |