OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef NET_HTTP_HTTP_PIPELINED_HOST_H_ | |
6 #define NET_HTTP_HTTP_PIPELINED_HOST_H_ | |
7 #pragma once | |
8 | |
9 #include <set> | |
10 #include <string> | |
11 | |
12 #include "base/compiler_specific.h" | |
13 #include "net/base/host_port_pair.h" | |
14 #include "net/http/http_pipelined_connection.h" | |
15 | |
16 namespace net { | |
17 | |
18 class BoundNetLog; | |
19 class ClientSocketHandle; | |
20 class ProxyInfo; | |
21 class SSLConfig; | |
22 | |
23 // Manages all of the pipelining state for specific host with active pipelined | |
24 // HTTP requests. Manages connection jobs, constructs pipelined streams, and | |
25 // assigns requests to the least loaded pipelined connection. | |
26 class HttpPipelinedHost : public HttpPipelinedConnection::Delegate { | |
mmenke
2011/09/15 19:28:16
Need to use "class NET_EXPORT_PRIVATE HttpPipeline
James Simonsen
2011/09/17 01:23:02
Done.
| |
27 public: | |
28 class Delegate { | |
29 public: | |
30 // Called when a pipelined host has no outstanding requests on any of its | |
31 // pipelined connections. | |
32 virtual void OnHostIdle(HttpPipelinedHost* host) = 0; | |
33 | |
34 // Called when a pipelined host has newly available pipeline capacity, like | |
35 // when a request completes. | |
36 virtual void OnHostHasAdditionalCapacity(HttpPipelinedHost* host) = 0; | |
37 }; | |
38 | |
39 HttpPipelinedHost(Delegate* delegate, const HostPortPair& origin, | |
40 HttpPipelinedConnection::Factory* factory); | |
41 ~HttpPipelinedHost(); | |
42 | |
43 // Returns a new HttpPipelinedConnection registered with this Host. | |
44 HttpPipelinedConnection* CreateNewPipeline(ClientSocketHandle* connection, | |
45 const SSLConfig& used_ssl_config, | |
46 const ProxyInfo& used_proxy_info, | |
47 const BoundNetLog& net_log, | |
48 bool was_npn_negotiated); | |
49 | |
50 // Returns the pipeline that is best to use for a new request and still has | |
51 // additional capacity. If there are no pipelines that can accept a new | |
52 // request, then NULL is returned. | |
53 HttpPipelinedConnection* FindAvailablePipeline(); | |
54 | |
55 // Callbacks for HttpPipelinedConnection. | |
56 | |
57 // Called when a pipelined connection completes a request. Adds a pending | |
58 // request to the pipeline if the pipeline is still usable. | |
59 virtual void OnPipelineHasCapacity( | |
60 HttpPipelinedConnection* pipeline) OVERRIDE; | |
61 | |
62 const HostPortPair& origin() const { return origin_; } | |
63 | |
64 private: | |
65 // Called when a pipeline is empty and there are no pending requests. Closes | |
66 // the connection. | |
67 void OnPipelineEmpty(HttpPipelinedConnection* pipeline); | |
68 | |
69 // Adds the next pending request to the pipeline if it's still usuable. | |
70 void AddRequestToPipeline(HttpPipelinedConnection* connection); | |
71 | |
72 int max_pipeline_depth() const { return 3; } | |
73 | |
74 Delegate* delegate_; | |
75 const HostPortPair origin_; | |
76 std::set<HttpPipelinedConnection*> pipelines_; | |
77 HttpPipelinedConnection::Factory* factory_; | |
78 | |
79 DISALLOW_COPY_AND_ASSIGN(HttpPipelinedHost); | |
80 }; | |
81 | |
82 } // namespace net | |
83 | |
84 #endif // NET_HTTP_HTTP_PIPELINED_HOST_H_ | |
OLD | NEW |