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

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: Merge Created 9 years, 2 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
« no previous file with comments | « net/http/http_pipelined_connection_impl_unittest.cc ('k') | net/http/http_pipelined_host.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #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/basictypes.h"
13 #include "base/memory/scoped_ptr.h"
14 #include "net/base/host_port_pair.h"
15 #include "net/base/net_export.h"
16 #include "net/http/http_pipelined_connection.h"
17
18 namespace net {
19
20 class BoundNetLog;
21 class ClientSocketHandle;
22 class HttpPipelinedStream;
23 class ProxyInfo;
24 struct SSLConfig;
25
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
30 : public HttpPipelinedConnection::Delegate {
31 public:
32 class Delegate {
33 public:
34 // Called when a pipelined host has no outstanding requests on any of its
35 // pipelined connections.
36 virtual void OnHostIdle(HttpPipelinedHost* host) = 0;
37
38 // Called when a pipelined host has newly available pipeline capacity, like
39 // when a request completes.
40 virtual void OnHostHasAdditionalCapacity(HttpPipelinedHost* host) = 0;
41 };
42
43 HttpPipelinedHost(Delegate* delegate, const HostPortPair& origin,
44 HttpPipelinedConnection::Factory* factory);
45 virtual ~HttpPipelinedHost();
46
47 // Constructs a new pipeline on |connection| and returns a new
48 // HttpPipelinedStream that uses it.
49 HttpPipelinedStream* CreateStreamOnNewPipeline(
50 ClientSocketHandle* connection,
51 const SSLConfig& used_ssl_config,
52 const ProxyInfo& used_proxy_info,
53 const BoundNetLog& net_log,
54 bool was_npn_negotiated);
55
56 // Tries to find an existing pipeline with capacity for a new request. If
57 // successful, returns a new stream on that pipeline. Otherwise, returns NULL.
58 HttpPipelinedStream* CreateStreamOnExistingPipeline();
59
60 // Returns true if we have a pipelined connection that can accept new
61 // requests.
62 bool IsExistingPipelineAvailable();
63
64 // Callbacks for HttpPipelinedConnection.
65
66 // Called when a pipelined connection completes a request. Adds a pending
67 // request to the pipeline if the pipeline is still usable.
68 virtual void OnPipelineHasCapacity(
69 HttpPipelinedConnection* pipeline) OVERRIDE;
70
71 const HostPortPair& origin() const { return origin_; }
72
73 private:
74 // Called when a pipeline is empty and there are no pending requests. Closes
75 // the connection.
76 void OnPipelineEmpty(HttpPipelinedConnection* pipeline);
77
78 // Adds the next pending request to the pipeline if it's still usuable.
79 void AddRequestToPipeline(HttpPipelinedConnection* connection);
80
81 int max_pipeline_depth() const { return 3; }
82
83 Delegate* delegate_;
84 const HostPortPair origin_;
85 std::set<HttpPipelinedConnection*> pipelines_;
86 scoped_ptr<HttpPipelinedConnection::Factory> factory_;
87
88 DISALLOW_COPY_AND_ASSIGN(HttpPipelinedHost);
89 };
90
91 } // namespace net
92
93 #endif // NET_HTTP_HTTP_PIPELINED_HOST_H_
OLDNEW
« no previous file with comments | « net/http/http_pipelined_connection_impl_unittest.cc ('k') | net/http/http_pipelined_host.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698