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.
5 #ifndef NET_HTTP_HTTP_PIPELINED_HOST_H_
6 #define NET_HTTP_HTTP_PIPELINED_HOST_H_
8 #include "net/base/host_port_pair.h"
9 #include "net/base/net_export.h"
10 #include "net/http/http_pipelined_connection.h"
11 #include "net/http/http_pipelined_host_capability.h"
20 class ClientSocketHandle
;
22 class HttpPipelinedStream
;
26 // Manages all of the pipelining state for specific host with active pipelined
27 // HTTP requests. Manages connection jobs, constructs pipelined streams, and
28 // assigns requests to the least loaded pipelined connection.
29 class NET_EXPORT_PRIVATE HttpPipelinedHost
{
31 class NET_EXPORT_PRIVATE Key
{
33 Key(const HostPortPair
& origin
);
35 // The host and port associated with this key.
36 const HostPortPair
& origin() const { return origin_
; }
38 bool operator<(const Key
& rhs
) const;
41 const HostPortPair origin_
;
46 // Called when a pipelined host has no outstanding requests on any of its
47 // pipelined connections.
48 virtual void OnHostIdle(HttpPipelinedHost
* host
) = 0;
50 // Called when a pipelined host has newly available pipeline capacity, like
51 // when a request completes.
52 virtual void OnHostHasAdditionalCapacity(HttpPipelinedHost
* host
) = 0;
54 // Called when a host determines if pipelining can be used.
55 virtual void OnHostDeterminedCapability(
56 HttpPipelinedHost
* host
,
57 HttpPipelinedHostCapability capability
) = 0;
64 // Returns a new HttpPipelinedHost.
65 virtual HttpPipelinedHost
* CreateNewHost(
66 Delegate
* delegate
, const Key
& key
,
67 HttpPipelinedConnection::Factory
* factory
,
68 HttpPipelinedHostCapability capability
,
69 bool force_pipelining
) = 0;
72 virtual ~HttpPipelinedHost() {}
74 // Constructs a new pipeline on |connection| and returns a new
75 // HttpPipelinedStream that uses it.
76 virtual HttpPipelinedStream
* CreateStreamOnNewPipeline(
77 ClientSocketHandle
* connection
,
78 const SSLConfig
& used_ssl_config
,
79 const ProxyInfo
& used_proxy_info
,
80 const BoundNetLog
& net_log
,
81 bool was_npn_negotiated
,
82 NextProto protocol_negotiated
) = 0;
84 // Tries to find an existing pipeline with capacity for a new request. If
85 // successful, returns a new stream on that pipeline. Otherwise, returns NULL.
86 virtual HttpPipelinedStream
* CreateStreamOnExistingPipeline() = 0;
88 // Returns true if we have a pipelined connection that can accept new
90 virtual bool IsExistingPipelineAvailable() const = 0;
92 // Returns a Key that uniquely identifies this host.
93 virtual const Key
& GetKey() const = 0;
95 // Creates a Value summary of this host's pipelines. Caller assumes
96 // ownership of the returned Value.
97 virtual base::Value
* PipelineInfoToValue() const = 0;
102 #endif // NET_HTTP_HTTP_PIPELINED_HOST_H_