| 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_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 NET_EXPORT_PRIVATE Key { |
| 33 public: |
| 34 Key(const HostPortPair& origin); |
| 35 |
| 36 // The host and port associated with this key. |
| 37 const HostPortPair& origin() const { return origin_; } |
| 38 |
| 39 bool operator<(const Key& rhs) const; |
| 40 |
| 41 private: |
| 42 const HostPortPair origin_; |
| 43 }; |
| 44 |
| 31 class Delegate { | 45 class Delegate { |
| 32 public: | 46 public: |
| 33 // Called when a pipelined host has no outstanding requests on any of its | 47 // Called when a pipelined host has no outstanding requests on any of its |
| 34 // pipelined connections. | 48 // pipelined connections. |
| 35 virtual void OnHostIdle(HttpPipelinedHost* host) = 0; | 49 virtual void OnHostIdle(HttpPipelinedHost* host) = 0; |
| 36 | 50 |
| 37 // Called when a pipelined host has newly available pipeline capacity, like | 51 // Called when a pipelined host has newly available pipeline capacity, like |
| 38 // when a request completes. | 52 // when a request completes. |
| 39 virtual void OnHostHasAdditionalCapacity(HttpPipelinedHost* host) = 0; | 53 virtual void OnHostHasAdditionalCapacity(HttpPipelinedHost* host) = 0; |
| 40 | 54 |
| 41 // Called when a host determines if pipelining can be used. | 55 // Called when a host determines if pipelining can be used. |
| 42 virtual void OnHostDeterminedCapability( | 56 virtual void OnHostDeterminedCapability( |
| 43 HttpPipelinedHost* host, | 57 HttpPipelinedHost* host, |
| 44 HttpPipelinedHostCapability capability) = 0; | 58 HttpPipelinedHostCapability capability) = 0; |
| 45 }; | 59 }; |
| 46 | 60 |
| 47 class Factory { | 61 class Factory { |
| 48 public: | 62 public: |
| 49 virtual ~Factory() {} | 63 virtual ~Factory() {} |
| 50 | 64 |
| 51 // Returns a new HttpPipelinedHost. | 65 // Returns a new HttpPipelinedHost. |
| 52 virtual HttpPipelinedHost* CreateNewHost( | 66 virtual HttpPipelinedHost* CreateNewHost( |
| 53 Delegate* delegate, const HostPortPair& origin, | 67 Delegate* delegate, const Key& key, |
| 54 HttpPipelinedConnection::Factory* factory, | 68 HttpPipelinedConnection::Factory* factory, |
| 55 HttpPipelinedHostCapability capability) = 0; | 69 HttpPipelinedHostCapability capability, |
| 70 bool force_pipelining) = 0; |
| 56 }; | 71 }; |
| 57 | 72 |
| 58 virtual ~HttpPipelinedHost() {} | 73 virtual ~HttpPipelinedHost() {} |
| 59 | 74 |
| 60 // Constructs a new pipeline on |connection| and returns a new | 75 // Constructs a new pipeline on |connection| and returns a new |
| 61 // HttpPipelinedStream that uses it. | 76 // HttpPipelinedStream that uses it. |
| 62 virtual HttpPipelinedStream* CreateStreamOnNewPipeline( | 77 virtual HttpPipelinedStream* CreateStreamOnNewPipeline( |
| 63 ClientSocketHandle* connection, | 78 ClientSocketHandle* connection, |
| 64 const SSLConfig& used_ssl_config, | 79 const SSLConfig& used_ssl_config, |
| 65 const ProxyInfo& used_proxy_info, | 80 const ProxyInfo& used_proxy_info, |
| 66 const BoundNetLog& net_log, | 81 const BoundNetLog& net_log, |
| 67 bool was_npn_negotiated, | 82 bool was_npn_negotiated, |
| 68 SSLClientSocket::NextProto protocol_negotiated) = 0; | 83 SSLClientSocket::NextProto protocol_negotiated) = 0; |
| 69 | 84 |
| 70 // Tries to find an existing pipeline with capacity for a new request. If | 85 // 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. | 86 // successful, returns a new stream on that pipeline. Otherwise, returns NULL. |
| 72 virtual HttpPipelinedStream* CreateStreamOnExistingPipeline() = 0; | 87 virtual HttpPipelinedStream* CreateStreamOnExistingPipeline() = 0; |
| 73 | 88 |
| 74 // Returns true if we have a pipelined connection that can accept new | 89 // Returns true if we have a pipelined connection that can accept new |
| 75 // requests. | 90 // requests. |
| 76 virtual bool IsExistingPipelineAvailable() const = 0; | 91 virtual bool IsExistingPipelineAvailable() const = 0; |
| 77 | 92 |
| 78 // Returns the host and port associated with this class. | 93 // Returns a Key that uniquely identifies this host. |
| 79 virtual const HostPortPair& origin() const = 0; | 94 virtual const Key& GetKey() const = 0; |
| 80 | 95 |
| 81 // Creates a Value summary of this host's pipelines. Caller assumes | 96 // Creates a Value summary of this host's pipelines. Caller assumes |
| 82 // ownership of the returned Value. | 97 // ownership of the returned Value. |
| 83 virtual base::Value* PipelineInfoToValue() const = 0; | 98 virtual base::Value* PipelineInfoToValue() const = 0; |
| 84 | |
| 85 }; | 99 }; |
| 86 | 100 |
| 87 } // namespace net | 101 } // namespace net |
| 88 | 102 |
| 89 #endif // NET_HTTP_HTTP_PIPELINED_HOST_H_ | 103 #endif // NET_HTTP_HTTP_PIPELINED_HOST_H_ |
| OLD | NEW |