OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 | 4 |
5 #ifndef NET_HTTP_HTTP_PIPELINED_HOST_POOL_H_ | 5 #ifndef NET_HTTP_HTTP_PIPELINED_HOST_POOL_H_ |
6 #define NET_HTTP_HTTP_PIPELINED_HOST_POOL_H_ | 6 #define NET_HTTP_HTTP_PIPELINED_HOST_POOL_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <map> | 9 #include <map> |
10 | 10 |
11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
(...skipping 16 matching lines...) Expand all Loading... |
28 // HTTP requests. Manages connection jobs, constructs pipelined streams, and | 28 // HTTP requests. Manages connection jobs, constructs pipelined streams, and |
29 // assigns requests to the least loaded pipelined connection. | 29 // assigns requests to the least loaded pipelined connection. |
30 class NET_EXPORT_PRIVATE HttpPipelinedHostPool | 30 class NET_EXPORT_PRIVATE HttpPipelinedHostPool |
31 : public HttpPipelinedHost::Delegate { | 31 : public HttpPipelinedHost::Delegate { |
32 public: | 32 public: |
33 class Delegate { | 33 class Delegate { |
34 public: | 34 public: |
35 // Called when a HttpPipelinedHost has new capacity. Attempts to allocate | 35 // Called when a HttpPipelinedHost has new capacity. Attempts to allocate |
36 // any pending pipeline-capable requests to pipelines. | 36 // any pending pipeline-capable requests to pipelines. |
37 virtual void OnHttpPipelinedHostHasAdditionalCapacity( | 37 virtual void OnHttpPipelinedHostHasAdditionalCapacity( |
38 const HostPortPair& origin) = 0; | 38 HttpPipelinedHost* host) = 0; |
39 }; | 39 }; |
40 | 40 |
41 HttpPipelinedHostPool(Delegate* delegate, | 41 HttpPipelinedHostPool(Delegate* delegate, |
42 HttpPipelinedHost::Factory* factory, | 42 HttpPipelinedHost::Factory* factory, |
43 HttpServerProperties* http_server_properties_); | 43 HttpServerProperties* http_server_properties_, |
| 44 bool force_pipelining); |
44 virtual ~HttpPipelinedHostPool(); | 45 virtual ~HttpPipelinedHostPool(); |
45 | 46 |
46 // Returns true if pipelining might work for |origin|. Generally, this returns | 47 // Returns true if pipelining might work for |key|. Generally, this returns |
47 // true, unless |origin| is known to have failed pipelining recently. | 48 // true, unless |key| is known to have failed pipelining recently. |
48 bool IsHostEligibleForPipelining(const HostPortPair& origin); | 49 bool IsKeyEligibleForPipelining(const HttpPipelinedHost::Key& key); |
49 | 50 |
50 // Constructs a new pipeline on |connection| and returns a new | 51 // Constructs a new pipeline on |connection| and returns a new |
51 // HttpPipelinedStream that uses it. | 52 // HttpPipelinedStream that uses it. |
52 HttpPipelinedStream* CreateStreamOnNewPipeline( | 53 HttpPipelinedStream* CreateStreamOnNewPipeline( |
53 const HostPortPair& origin, | 54 const HttpPipelinedHost::Key& key, |
54 ClientSocketHandle* connection, | 55 ClientSocketHandle* connection, |
55 const SSLConfig& used_ssl_config, | 56 const SSLConfig& used_ssl_config, |
56 const ProxyInfo& used_proxy_info, | 57 const ProxyInfo& used_proxy_info, |
57 const BoundNetLog& net_log, | 58 const BoundNetLog& net_log, |
58 bool was_npn_negotiated, | 59 bool was_npn_negotiated, |
59 SSLClientSocket::NextProto protocol_negotiated); | 60 SSLClientSocket::NextProto protocol_negotiated); |
60 | 61 |
61 // Tries to find an existing pipeline with capacity for a new request. If | 62 // Tries to find an existing pipeline with capacity for a new request. If |
62 // successful, returns a new stream on that pipeline. Otherwise, returns NULL. | 63 // successful, returns a new stream on that pipeline. Otherwise, returns NULL. |
63 HttpPipelinedStream* CreateStreamOnExistingPipeline( | 64 HttpPipelinedStream* CreateStreamOnExistingPipeline( |
64 const HostPortPair& origin); | 65 const HttpPipelinedHost::Key& key); |
65 | 66 |
66 // Returns true if a pipelined connection already exists for this origin and | 67 // Returns true if a pipelined connection already exists for |key| and |
67 // can accept new requests. | 68 // can accept new requests. |
68 bool IsExistingPipelineAvailableForOrigin(const HostPortPair& origin); | 69 bool IsExistingPipelineAvailableForKey(const HttpPipelinedHost::Key& key); |
69 | 70 |
70 // Callbacks for HttpPipelinedHost. | 71 // Callbacks for HttpPipelinedHost. |
71 virtual void OnHostIdle(HttpPipelinedHost* host) OVERRIDE; | 72 virtual void OnHostIdle(HttpPipelinedHost* host) OVERRIDE; |
72 | 73 |
73 virtual void OnHostHasAdditionalCapacity(HttpPipelinedHost* host) OVERRIDE; | 74 virtual void OnHostHasAdditionalCapacity(HttpPipelinedHost* host) OVERRIDE; |
74 | 75 |
75 virtual void OnHostDeterminedCapability( | 76 virtual void OnHostDeterminedCapability( |
76 HttpPipelinedHost* host, | 77 HttpPipelinedHost* host, |
77 HttpPipelinedHostCapability capability) OVERRIDE; | 78 HttpPipelinedHostCapability capability) OVERRIDE; |
78 | 79 |
79 // Creates a Value summary of this pool's |host_map_|. Caller assumes | 80 // Creates a Value summary of this pool's |host_map_|. Caller assumes |
80 // ownership of the returned Value. | 81 // ownership of the returned Value. |
81 base::Value* PipelineInfoToValue() const; | 82 base::Value* PipelineInfoToValue() const; |
82 | 83 |
83 private: | 84 private: |
84 typedef std::map<const HostPortPair, HttpPipelinedHost*> HostMap; | 85 typedef std::map<HttpPipelinedHost::Key, HttpPipelinedHost*> HostMap; |
85 | 86 |
86 HttpPipelinedHost* GetPipelinedHost(const HostPortPair& origin, | 87 HttpPipelinedHost* GetPipelinedHost(const HttpPipelinedHost::Key& key, |
87 bool create_if_not_found); | 88 bool create_if_not_found); |
88 | 89 |
89 Delegate* delegate_; | 90 Delegate* delegate_; |
90 scoped_ptr<HttpPipelinedHost::Factory> factory_; | 91 scoped_ptr<HttpPipelinedHost::Factory> factory_; |
91 HostMap host_map_; | 92 HostMap host_map_; |
92 HttpServerProperties* http_server_properties_; | 93 HttpServerProperties* http_server_properties_; |
| 94 bool force_pipelining_; |
93 | 95 |
94 DISALLOW_COPY_AND_ASSIGN(HttpPipelinedHostPool); | 96 DISALLOW_COPY_AND_ASSIGN(HttpPipelinedHostPool); |
95 }; | 97 }; |
96 | 98 |
97 } // namespace net | 99 } // namespace net |
98 | 100 |
99 #endif // NET_HTTP_HTTP_PIPELINED_HOST_POOL_H_ | 101 #endif // NET_HTTP_HTTP_PIPELINED_HOST_POOL_H_ |
OLD | NEW |