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

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

Issue 8586015: Slow start pipelining. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add missing files Created 9 years, 1 month 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
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef NET_HTTP_HTTP_PIPELINED_HOST_H_ 5 #ifndef NET_HTTP_HTTP_PIPELINED_HOST_IMPL_H_
6 #define NET_HTTP_HTTP_PIPELINED_HOST_H_ 6 #define NET_HTTP_HTTP_PIPELINED_HOST_IMPL_H_
7 #pragma once 7 #pragma once
8 8
9 #include <set> 9 #include <map>
10 #include <string> 10 #include <string>
11 11
12 #include "base/basictypes.h" 12 #include "base/basictypes.h"
13 #include "base/memory/scoped_ptr.h" 13 #include "base/memory/scoped_ptr.h"
14 #include "net/base/host_port_pair.h" 14 #include "net/base/host_port_pair.h"
15 #include "net/base/net_export.h" 15 #include "net/base/net_export.h"
16 #include "net/http/http_pipelined_connection.h" 16 #include "net/http/http_pipelined_connection.h"
17 #include "net/http/http_pipelined_host.h"
17 18
18 namespace net { 19 namespace net {
19 20
20 class BoundNetLog; 21 class BoundNetLog;
21 class ClientSocketHandle; 22 class ClientSocketHandle;
22 class HttpPipelinedStream; 23 class HttpPipelinedStream;
23 class ProxyInfo; 24 class ProxyInfo;
24 struct SSLConfig; 25 struct SSLConfig;
25 26
26 // Manages all of the pipelining state for specific host with active pipelined 27 // Manages all of the pipelining state for specific host with active pipelined
27 // HTTP requests. Manages connection jobs, constructs pipelined streams, and 28 // HTTP requests. Manages connection jobs, constructs pipelined streams, and
28 // assigns requests to the least loaded pipelined connection. 29 // assigns requests to the least loaded pipelined connection.
29 class NET_EXPORT_PRIVATE HttpPipelinedHost 30 class NET_EXPORT_PRIVATE HttpPipelinedHostImpl
30 : public HttpPipelinedConnection::Delegate { 31 : public HttpPipelinedHost,
32 public HttpPipelinedConnection::Delegate {
31 public: 33 public:
32 class Delegate { 34 HttpPipelinedHostImpl(HttpPipelinedHost::Delegate* delegate,
33 public: 35 const HostPortPair& origin,
34 // Called when a pipelined host has no outstanding requests on any of its 36 HttpPipelinedConnection::Factory* factory,
35 // pipelined connections. 37 Capability capability);
36 virtual void OnHostIdle(HttpPipelinedHost* host) = 0; 38 virtual ~HttpPipelinedHostImpl();
37 39
38 // Called when a pipelined host has newly available pipeline capacity, like 40 // HttpPipelinedHost Interface
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( 41 HttpPipelinedStream* CreateStreamOnNewPipeline(
50 ClientSocketHandle* connection, 42 ClientSocketHandle* connection,
51 const SSLConfig& used_ssl_config, 43 const SSLConfig& used_ssl_config,
52 const ProxyInfo& used_proxy_info, 44 const ProxyInfo& used_proxy_info,
53 const BoundNetLog& net_log, 45 const BoundNetLog& net_log,
54 bool was_npn_negotiated); 46 bool was_npn_negotiated);
mmenke 2011/11/17 22:25:37 This function and the next two should all use virt
James Simonsen 2011/11/18 00:03:56 Done.
55 47
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(); 48 HttpPipelinedStream* CreateStreamOnExistingPipeline();
59 49
60 // Returns true if we have a pipelined connection that can accept new
61 // requests.
62 bool IsExistingPipelineAvailable(); 50 bool IsExistingPipelineAvailable();
63 51
64 // Callbacks for HttpPipelinedConnection. 52 // Callbacks for HttpPipelinedConnection.
65 53
66 // Called when a pipelined connection completes a request. Adds a pending 54 // Called when a pipelined connection completes a request. Adds a pending
67 // request to the pipeline if the pipeline is still usable. 55 // request to the pipeline if the pipeline is still usable.
68 virtual void OnPipelineHasCapacity( 56 virtual void OnPipelineHasCapacity(
69 HttpPipelinedConnection* pipeline) OVERRIDE; 57 HttpPipelinedConnection* pipeline) OVERRIDE;
70 58
71 const HostPortPair& origin() const { return origin_; } 59 virtual void OnPipelineFeedback(
60 HttpPipelinedConnection* pipeline,
61 HttpPipelinedConnection::Feedback feedback) OVERRIDE;
62
63 virtual const HostPortPair& origin() const OVERRIDE;
mmenke 2011/11/17 22:25:37 Now that this is virtual, it's no longer just a li
James Simonsen 2011/11/18 00:03:56 I added it to my task list. This CL is big enough.
72 64
73 private: 65 private:
66 struct PipelineInfo {
67 PipelineInfo();
68
69 int capacity;
70 int num_successes;
71 };
72 typedef std::map<HttpPipelinedConnection*, PipelineInfo> PipelineInfoMap;
73
74 // Called when a pipeline is empty and there are no pending requests. Closes 74 // Called when a pipeline is empty and there are no pending requests. Closes
75 // the connection. 75 // the connection.
76 void OnPipelineEmpty(HttpPipelinedConnection* pipeline); 76 void OnPipelineEmpty(HttpPipelinedConnection* pipeline);
77 77
78 // Adds the next pending request to the pipeline if it's still usuable. 78 // Adds the next pending request to the pipeline if it's still usuable.
79 void AddRequestToPipeline(HttpPipelinedConnection* connection); 79 void AddRequestToPipeline(HttpPipelinedConnection* connection);
80 80
81 int max_pipeline_depth() const { return 3; } 81 int max_pipeline_depth() const { return 3; }
82 82
83 Delegate* delegate_; 83 HttpPipelinedHost::Delegate* delegate_;
84 const HostPortPair origin_; 84 const HostPortPair origin_;
85 std::set<HttpPipelinedConnection*> pipelines_; 85 PipelineInfoMap pipelines_;
86 scoped_ptr<HttpPipelinedConnection::Factory> factory_; 86 scoped_ptr<HttpPipelinedConnection::Factory> factory_;
87 Capability capability_;
87 88
88 DISALLOW_COPY_AND_ASSIGN(HttpPipelinedHost); 89 DISALLOW_COPY_AND_ASSIGN(HttpPipelinedHostImpl);
89 }; 90 };
90 91
91 } // namespace net 92 } // namespace net
92 93
93 #endif // NET_HTTP_HTTP_PIPELINED_HOST_H_ 94 #endif // NET_HTTP_HTTP_PIPELINED_HOST_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698