Chromium Code Reviews| Index: net/http/http_pipelined_host.h |
| diff --git a/net/http/http_pipelined_host.h b/net/http/http_pipelined_host.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..62263686c3700bccc2aa170f58675a037f2a2974 |
| --- /dev/null |
| +++ b/net/http/http_pipelined_host.h |
| @@ -0,0 +1,84 @@ |
| +// Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| +// |
| +// Manages all of the pipelining state for specific host with active pipelined |
| +// HTTP requests. Manages connection jobs, constructs pipelined streams, and |
| +// assigns requests to the least loaded pipelined connection. |
|
mmenke
2011/08/23 19:05:25
nit: Move above HttpPipelinedHost.
James Simonsen
2011/08/26 22:19:07
Done.
|
| + |
| +#ifndef NET_HTTP_HTTP_PIPELINED_HOST_H_ |
| +#define NET_HTTP_HTTP_PIPELINED_HOST_H_ |
| +#pragma once |
| + |
| +#include <set> |
| +#include <string> |
| + |
| +#include "base/compiler_specific.h" |
| +#include "net/base/host_port_pair.h" |
| +#include "net/http/http_pipelined_connection.h" |
| + |
| +namespace net { |
| + |
| +class BoundNetLog; |
| +class ClientSocketHandle; |
| +class ProxyInfo; |
| +class SSLConfig; |
| + |
| +class HttpPipelinedHost : public HttpPipelinedConnection::Owner { |
| + public: |
| + class Owner { |
|
mmenke
2011/08/23 19:05:25
"Delegate" is the preferred term for this kind of
James Simonsen
2011/08/26 22:19:07
Done.
|
| + public: |
| + // Called when a pipelined host has no outstanding requests on any of its |
| + // pipelined connections. |
| + virtual void OnHostIdle(HttpPipelinedHost* host) = 0; |
| + |
| + // Called when a pipelined host has newly available pipeline capacity, like |
| + // when a request completes. |
| + virtual void OnHostHasAdditionalCapacity(HttpPipelinedHost* host) = 0; |
| + }; |
| + |
| + HttpPipelinedHost(Owner* owner, const HostPortPair& origin, |
| + HttpPipelinedConnection::Factory* factory); |
| + ~HttpPipelinedHost(); |
| + |
| + // Returns a new HttpPipelinedConnection registered with this Host. |
| + HttpPipelinedConnection* CreateNewPipeline(ClientSocketHandle* connection, |
| + const SSLConfig& used_ssl_config, |
| + const ProxyInfo& used_proxy_info, |
| + const BoundNetLog& net_log, |
| + bool was_npn_negotiated); |
| + |
| + // Returns the pipeline that is best to use for a new request and still has |
| + // additional capacity. If there are no pipelines that can accept a new |
| + // request, then NULL is returned. |
| + HttpPipelinedConnection* FindAvailablePipeline(); |
| + |
| + // Callbacks for HttpPipelinedConnection. |
| + |
| + // Called when a pipelined connection completes a request. Adds a pending |
| + // request to the pipeline if the pipeline is still usable. |
| + void OnPipelineHasCapacity(HttpPipelinedConnection* pipeline) OVERRIDE; |
| + |
| + const HostPortPair& origin() const { return origin_; } |
| + |
| + private: |
| + // Called when a pipeline is empty and there are no pending requests. Closes |
| + // the connection. |
| + void OnPipelineEmpty(HttpPipelinedConnection* pipeline); |
| + |
| + // Adds the next pending request to the pipeline if it's still usuable. |
| + void AddRequestToPipeline(HttpPipelinedConnection* connection); |
| + |
| + int max_pipeline_depth() const { return 3; } |
| + |
| + Owner* owner_; |
| + const HostPortPair origin_; |
| + std::set<HttpPipelinedConnection*> pipelines_; |
| + HttpPipelinedConnection::Factory* factory_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(HttpPipelinedHost); |
| +}; |
| + |
| +} // namespace net |
| + |
| +#endif // NET_HTTP_HTTP_PIPELINED_HOST_H_ |