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 HttpStreamFactory; |
| 18 |
| 19 // Manages all of the pipelining state for specific host with active pipelined |
| 20 // HTTP requests. Manages connection jobs, constructs pipelined streams, and |
| 21 // assigns requests to the least loaded pipelined connection. |
| 22 class HttpPipelinedHostPool : public HttpPipelinedHost::Delegate { |
| 23 public: |
| 24 explicit HttpPipelinedHostPool(HttpStreamFactory* factory); |
| 25 ~HttpPipelinedHostPool(); |
| 26 |
| 27 // Returns the HttpPipelinedHost used for this origin, or a new one if none |
| 28 // exists. |
| 29 HttpPipelinedHost* GetOrCreatePipelinedHost(const HostPortPair& origin) { |
| 30 return GetPipelinedHost(origin, true); |
| 31 } |
| 32 |
| 33 // Returns the HttpPipelinedHost used for this origin, or NULL if none exists. |
| 34 HttpPipelinedHost* GetPipelinedHostIfExists(const HostPortPair& origin) { |
| 35 return GetPipelinedHost(origin, false); |
| 36 } |
| 37 |
| 38 // Callbacks for HttpPipelinedHost. |
| 39 virtual void OnHostIdle(HttpPipelinedHost* host) OVERRIDE; |
| 40 |
| 41 virtual void OnHostHasAdditionalCapacity(HttpPipelinedHost* host) OVERRIDE; |
| 42 |
| 43 private: |
| 44 HttpPipelinedHost* GetPipelinedHost(const HostPortPair& origin, |
| 45 bool create_if_not_found); |
| 46 |
| 47 HttpStreamFactory* factory_; |
| 48 typedef std::map<const HostPortPair, HttpPipelinedHost*> HostMap; |
| 49 HostMap host_map_; |
| 50 |
| 51 DISALLOW_COPY_AND_ASSIGN(HttpPipelinedHostPool); |
| 52 }; |
| 53 |
| 54 } // namespace net |
| 55 |
| 56 #endif // NET_HTTP_HTTP_PIPELINED_HOST_POOL_H_ |
OLD | NEW |