Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(498)

Side by Side Diff: net/http/http_pipelined_host.h

Issue 7289006: Basic HTTP pipelining support (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Added unit tests Created 9 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(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 // Manages all of the pipelining state for specific host with active pipelined
6 // HTTP requests. Manages connection jobs, constructs pipelined streams, and
7 // 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.
8
9 #ifndef NET_HTTP_HTTP_PIPELINED_HOST_H_
10 #define NET_HTTP_HTTP_PIPELINED_HOST_H_
11 #pragma once
12
13 #include <set>
14 #include <string>
15
16 #include "base/compiler_specific.h"
17 #include "net/base/host_port_pair.h"
18 #include "net/http/http_pipelined_connection.h"
19
20 namespace net {
21
22 class BoundNetLog;
23 class ClientSocketHandle;
24 class ProxyInfo;
25 class SSLConfig;
26
27 class HttpPipelinedHost : public HttpPipelinedConnection::Owner {
28 public:
29 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.
30 public:
31 // Called when a pipelined host has no outstanding requests on any of its
32 // pipelined connections.
33 virtual void OnHostIdle(HttpPipelinedHost* host) = 0;
34
35 // Called when a pipelined host has newly available pipeline capacity, like
36 // when a request completes.
37 virtual void OnHostHasAdditionalCapacity(HttpPipelinedHost* host) = 0;
38 };
39
40 HttpPipelinedHost(Owner* owner, const HostPortPair& origin,
41 HttpPipelinedConnection::Factory* factory);
42 ~HttpPipelinedHost();
43
44 // Returns a new HttpPipelinedConnection registered with this Host.
45 HttpPipelinedConnection* CreateNewPipeline(ClientSocketHandle* connection,
46 const SSLConfig& used_ssl_config,
47 const ProxyInfo& used_proxy_info,
48 const BoundNetLog& net_log,
49 bool was_npn_negotiated);
50
51 // Returns the pipeline that is best to use for a new request and still has
52 // additional capacity. If there are no pipelines that can accept a new
53 // request, then NULL is returned.
54 HttpPipelinedConnection* FindAvailablePipeline();
55
56 // Callbacks for HttpPipelinedConnection.
57
58 // Called when a pipelined connection completes a request. Adds a pending
59 // request to the pipeline if the pipeline is still usable.
60 void OnPipelineHasCapacity(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 Owner* owner_;
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_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698