OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 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_H_ | 5 #ifndef NET_HTTP_HTTP_PIPELINED_HOST_H_ |
6 #define NET_HTTP_HTTP_PIPELINED_HOST_H_ | 6 #define NET_HTTP_HTTP_PIPELINED_HOST_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "net/base/host_port_pair.h" | |
9 #include "net/base/net_export.h" | 10 #include "net/base/net_export.h" |
10 #include "net/http/http_pipelined_connection.h" | 11 #include "net/http/http_pipelined_connection.h" |
11 #include "net/http/http_pipelined_host_capability.h" | 12 #include "net/http/http_pipelined_host_capability.h" |
12 | 13 |
13 namespace base { | 14 namespace base { |
14 class Value; | 15 class Value; |
15 } | 16 } |
16 | 17 |
17 namespace net { | 18 namespace net { |
18 | 19 |
19 class BoundNetLog; | 20 class BoundNetLog; |
20 class ClientSocketHandle; | 21 class ClientSocketHandle; |
21 class HostPortPair; | 22 class HostPortPair; |
22 class HttpPipelinedStream; | 23 class HttpPipelinedStream; |
23 class ProxyInfo; | 24 class ProxyInfo; |
24 struct SSLConfig; | 25 struct SSLConfig; |
25 | 26 |
26 // Manages all of the pipelining state for specific host with active pipelined | 27 // Manages all of the pipelining state for specific host with active pipelined |
27 // HTTP requests. Manages connection jobs, constructs pipelined streams, and | 28 // HTTP requests. Manages connection jobs, constructs pipelined streams, and |
28 // assigns requests to the least loaded pipelined connection. | 29 // assigns requests to the least loaded pipelined connection. |
29 class NET_EXPORT_PRIVATE HttpPipelinedHost { | 30 class NET_EXPORT_PRIVATE HttpPipelinedHost { |
30 public: | 31 public: |
32 class Key { | |
mmenke
2012/02/23 18:54:58
Doesn't look to me like any of the unit tests beat
James Simonsen
2012/02/23 23:49:46
Good point. Done.
| |
33 public: | |
34 Key(const HostPortPair& origin, bool force_pipelining); | |
35 | |
36 // The host and port associated with this key. | |
37 const HostPortPair& origin() const { return origin_; } | |
38 | |
39 // True if this key forces requests to pipeline. | |
40 bool force_pipelining() const { return force_pipelining_; } | |
41 | |
42 bool operator<(const Key& rhs) const; | |
43 | |
44 private: | |
45 const HostPortPair origin_; | |
46 bool force_pipelining_; | |
47 }; | |
48 | |
31 class Delegate { | 49 class Delegate { |
32 public: | 50 public: |
33 // Called when a pipelined host has no outstanding requests on any of its | 51 // Called when a pipelined host has no outstanding requests on any of its |
34 // pipelined connections. | 52 // pipelined connections. |
35 virtual void OnHostIdle(HttpPipelinedHost* host) = 0; | 53 virtual void OnHostIdle(HttpPipelinedHost* host) = 0; |
36 | 54 |
37 // Called when a pipelined host has newly available pipeline capacity, like | 55 // Called when a pipelined host has newly available pipeline capacity, like |
38 // when a request completes. | 56 // when a request completes. |
39 virtual void OnHostHasAdditionalCapacity(HttpPipelinedHost* host) = 0; | 57 virtual void OnHostHasAdditionalCapacity(HttpPipelinedHost* host) = 0; |
40 | 58 |
41 // Called when a host determines if pipelining can be used. | 59 // Called when a host determines if pipelining can be used. |
42 virtual void OnHostDeterminedCapability( | 60 virtual void OnHostDeterminedCapability( |
43 HttpPipelinedHost* host, | 61 HttpPipelinedHost* host, |
44 HttpPipelinedHostCapability capability) = 0; | 62 HttpPipelinedHostCapability capability) = 0; |
45 }; | 63 }; |
46 | 64 |
47 class Factory { | 65 class Factory { |
48 public: | 66 public: |
49 virtual ~Factory() {} | 67 virtual ~Factory() {} |
50 | 68 |
51 // Returns a new HttpPipelinedHost. | 69 // Returns a new HttpPipelinedHost. |
52 virtual HttpPipelinedHost* CreateNewHost( | 70 virtual HttpPipelinedHost* CreateNewHost( |
53 Delegate* delegate, const HostPortPair& origin, | 71 Delegate* delegate, const Key& key, |
54 HttpPipelinedConnection::Factory* factory, | 72 HttpPipelinedConnection::Factory* factory, |
55 HttpPipelinedHostCapability capability) = 0; | 73 HttpPipelinedHostCapability capability) = 0; |
56 }; | 74 }; |
57 | 75 |
58 virtual ~HttpPipelinedHost() {} | 76 virtual ~HttpPipelinedHost() {} |
59 | 77 |
60 // Constructs a new pipeline on |connection| and returns a new | 78 // Constructs a new pipeline on |connection| and returns a new |
61 // HttpPipelinedStream that uses it. | 79 // HttpPipelinedStream that uses it. |
62 virtual HttpPipelinedStream* CreateStreamOnNewPipeline( | 80 virtual HttpPipelinedStream* CreateStreamOnNewPipeline( |
63 ClientSocketHandle* connection, | 81 ClientSocketHandle* connection, |
64 const SSLConfig& used_ssl_config, | 82 const SSLConfig& used_ssl_config, |
65 const ProxyInfo& used_proxy_info, | 83 const ProxyInfo& used_proxy_info, |
66 const BoundNetLog& net_log, | 84 const BoundNetLog& net_log, |
67 bool was_npn_negotiated, | 85 bool was_npn_negotiated, |
68 SSLClientSocket::NextProto protocol_negotiated) = 0; | 86 SSLClientSocket::NextProto protocol_negotiated) = 0; |
69 | 87 |
70 // Tries to find an existing pipeline with capacity for a new request. If | 88 // Tries to find an existing pipeline with capacity for a new request. If |
71 // successful, returns a new stream on that pipeline. Otherwise, returns NULL. | 89 // successful, returns a new stream on that pipeline. Otherwise, returns NULL. |
72 virtual HttpPipelinedStream* CreateStreamOnExistingPipeline() = 0; | 90 virtual HttpPipelinedStream* CreateStreamOnExistingPipeline() = 0; |
73 | 91 |
74 // Returns true if we have a pipelined connection that can accept new | 92 // Returns true if we have a pipelined connection that can accept new |
75 // requests. | 93 // requests. |
76 virtual bool IsExistingPipelineAvailable() const = 0; | 94 virtual bool IsExistingPipelineAvailable() const = 0; |
77 | 95 |
78 // Returns the host and port associated with this class. | 96 // Returns a Key that uniquely identifies this host. |
79 virtual const HostPortPair& origin() const = 0; | 97 virtual const Key& key() const = 0; |
80 | 98 |
81 // Creates a Value summary of this host's pipelines. Caller assumes | 99 // Creates a Value summary of this host's pipelines. Caller assumes |
82 // ownership of the returned Value. | 100 // ownership of the returned Value. |
83 virtual base::Value* PipelineInfoToValue() const = 0; | 101 virtual base::Value* PipelineInfoToValue() const = 0; |
84 | |
85 }; | 102 }; |
86 | 103 |
87 } // namespace net | 104 } // namespace net |
88 | 105 |
89 #endif // NET_HTTP_HTTP_PIPELINED_HOST_H_ | 106 #endif // NET_HTTP_HTTP_PIPELINED_HOST_H_ |
OLD | NEW |