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 3 // found in the LICENSE file. 4 5 #ifndef NET_HTTP_HTTP_PIPELINED_CONNECTION_H_ 6 #define NET_HTTP_HTTP_PIPELINED_CONNECTION_H_ 7 8 #include "net/base/net_export.h" 9 #include "net/base/net_log.h" 10 #include "net/socket/ssl_client_socket.h" 11 12 namespace net { 13 14 class BoundNetLog; 15 class ClientSocketHandle; 16 class HostPortPair; 17 class HttpPipelinedStream; 18 class ProxyInfo; 19 struct SSLConfig; 20 21 class NET_EXPORT_PRIVATE HttpPipelinedConnection { 22 public: 23 enum Feedback { 24 OK, 25 PIPELINE_SOCKET_ERROR, 26 OLD_HTTP_VERSION, 27 MUST_CLOSE_CONNECTION, 28 AUTHENTICATION_REQUIRED, 29 }; 30 31 class Delegate { 32 public: 33 // Called when a pipeline has newly available capacity. This may be because 34 // the first request has been sent and the pipeline is now active. Or, it 35 // may be because a request successfully completed. 36 virtual void OnPipelineHasCapacity(HttpPipelinedConnection* pipeline) = 0; 37 38 // Called every time a pipeline receives headers. Lets the delegate know if 39 // the headers indicate that pipelining can be used. 40 virtual void OnPipelineFeedback(HttpPipelinedConnection* pipeline, 41 Feedback feedback) = 0; 42 }; 43 44 class Factory { 45 public: ~Factory()46 virtual ~Factory() {} 47 48 virtual HttpPipelinedConnection* CreateNewPipeline( 49 ClientSocketHandle* connection, 50 Delegate* delegate, 51 const HostPortPair& origin, 52 const SSLConfig& used_ssl_config, 53 const ProxyInfo& used_proxy_info, 54 const BoundNetLog& net_log, 55 bool was_npn_negotiated, 56 NextProto protocol_negotiated) = 0; 57 }; 58 ~HttpPipelinedConnection()59 virtual ~HttpPipelinedConnection() {} 60 61 // Returns a new stream that uses this pipeline. 62 virtual HttpPipelinedStream* CreateNewStream() = 0; 63 64 // The number of streams currently associated with this pipeline. 65 virtual int depth() const = 0; 66 67 // True if this pipeline can accept new HTTP requests. False if a fatal error 68 // has occurred. 69 virtual bool usable() const = 0; 70 71 // True if this pipeline has bound one request and is ready for additional 72 // requests. 73 virtual bool active() const = 0; 74 75 // The SSLConfig used to establish this connection. 76 virtual const SSLConfig& used_ssl_config() const = 0; 77 78 // The ProxyInfo used to establish this connection. 79 virtual const ProxyInfo& used_proxy_info() const = 0; 80 81 // The BoundNetLog of this pipelined connection. 82 virtual const BoundNetLog& net_log() const = 0; 83 84 // True if this connection was NPN negotiated. 85 virtual bool was_npn_negotiated() const = 0; 86 87 // Protocol negotiated with the server. 88 virtual NextProto protocol_negotiated() const = 0; 89 }; 90 91 } // namespace net 92 93 #endif // NET_HTTP_HTTP_PIPELINED_CONNECTION_H_ 94