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

Side by Side Diff: net/http/http_pipelined_host_pool.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_POOL_H_ 5 #ifndef NET_HTTP_HTTP_PIPELINED_HOST_POOL_H_
6 #define NET_HTTP_HTTP_PIPELINED_HOST_POOL_H_ 6 #define NET_HTTP_HTTP_PIPELINED_HOST_POOL_H_
7 #pragma once 7 #pragma once
8 8
9 #include <map> 9 #include <map>
10 10
11 #include "base/basictypes.h" 11 #include "base/basictypes.h"
12 #include "base/gtest_prod_util.h"
13 #include "base/memory/mru_cache.h"
14 #include "base/memory/scoped_ptr.h"
12 #include "net/http/http_pipelined_host.h" 15 #include "net/http/http_pipelined_host.h"
13 16
14 namespace net { 17 namespace net {
15 18
16 class HostPortPair; 19 class HostPortPair;
17 class HttpPipelinedStream; 20 class HttpPipelinedStream;
18 class HttpStreamFactoryImpl;
19 21
20 // Manages all of the pipelining state for specific host with active pipelined 22 // Manages all of the pipelining state for specific host with active pipelined
21 // HTTP requests. Manages connection jobs, constructs pipelined streams, and 23 // HTTP requests. Manages connection jobs, constructs pipelined streams, and
22 // assigns requests to the least loaded pipelined connection. 24 // assigns requests to the least loaded pipelined connection.
23 class HttpPipelinedHostPool : public HttpPipelinedHost::Delegate { 25 class HttpPipelinedHostPool : public HttpPipelinedHost::Delegate {
24 public: 26 public:
25 explicit HttpPipelinedHostPool(HttpStreamFactoryImpl* factory); 27 class Delegate {
28 public:
29 // Called when a HttpPipelinedHost has new capacity. Attempts to allocate
30 // any pending pipeline-capable requests to pipelines.
31 virtual void OnHttpPipelinedHostHasAdditionalCapacity(
32 const HostPortPair& origin) = 0;
33 };
34
35 HttpPipelinedHostPool(Delegate* delegate,
36 HttpPipelinedHost::Factory* factory);
26 ~HttpPipelinedHostPool(); 37 ~HttpPipelinedHostPool();
27 38
39 // Returns true if pipelining might work for |origin|. Generally, this returns
40 // true, unless |origin| is known to have failed pipelining recently.
41 bool IsHostEligibleForPipelining(const HostPortPair& origin);
42
28 // Constructs a new pipeline on |connection| and returns a new 43 // Constructs a new pipeline on |connection| and returns a new
29 // HttpPipelinedStream that uses it. 44 // HttpPipelinedStream that uses it.
30 HttpPipelinedStream* CreateStreamOnNewPipeline( 45 HttpPipelinedStream* CreateStreamOnNewPipeline(
31 const HostPortPair& origin, 46 const HostPortPair& origin,
32 ClientSocketHandle* connection, 47 ClientSocketHandle* connection,
33 const SSLConfig& used_ssl_config, 48 const SSLConfig& used_ssl_config,
34 const ProxyInfo& used_proxy_info, 49 const ProxyInfo& used_proxy_info,
35 const BoundNetLog& net_log, 50 const BoundNetLog& net_log,
36 bool was_npn_negotiated); 51 bool was_npn_negotiated);
37 52
38 // Tries to find an existing pipeline with capacity for a new request. If 53 // Tries to find an existing pipeline with capacity for a new request. If
39 // successful, returns a new stream on that pipeline. Otherwise, returns NULL. 54 // successful, returns a new stream on that pipeline. Otherwise, returns NULL.
40 HttpPipelinedStream* CreateStreamOnExistingPipeline( 55 HttpPipelinedStream* CreateStreamOnExistingPipeline(
41 const HostPortPair& origin); 56 const HostPortPair& origin);
42 57
43 // Returns true if a pipelined connection already exists for this origin and 58 // Returns true if a pipelined connection already exists for this origin and
44 // can accept new requests. 59 // can accept new requests.
45 bool IsExistingPipelineAvailableForOrigin(const HostPortPair& origin); 60 bool IsExistingPipelineAvailableForOrigin(const HostPortPair& origin);
46 61
47 // Callbacks for HttpPipelinedHost. 62 // Callbacks for HttpPipelinedHost.
48 virtual void OnHostIdle(HttpPipelinedHost* host) OVERRIDE; 63 virtual void OnHostIdle(HttpPipelinedHost* host) OVERRIDE;
49 64
50 virtual void OnHostHasAdditionalCapacity(HttpPipelinedHost* host) OVERRIDE; 65 virtual void OnHostHasAdditionalCapacity(HttpPipelinedHost* host) OVERRIDE;
51 66
67 virtual void OnHostDeterminedCapability(
68 HttpPipelinedHost* host,
69 HttpPipelinedHost::Capability capability) OVERRIDE;
70
52 private: 71 private:
72 typedef base::MRUCache<HostPortPair,
73 HttpPipelinedHost::Capability> CapabilityMap;
53 typedef std::map<const HostPortPair, HttpPipelinedHost*> HostMap; 74 typedef std::map<const HostPortPair, HttpPipelinedHost*> HostMap;
54 75
55 HttpPipelinedHost* GetPipelinedHost(const HostPortPair& origin, 76 HttpPipelinedHost* GetPipelinedHost(const HostPortPair& origin,
56 bool create_if_not_found); 77 bool create_if_not_found);
57 78
58 HttpStreamFactoryImpl* factory_; 79 Delegate* delegate_;
80 scoped_ptr<HttpPipelinedHost::Factory> factory_;
59 HostMap host_map_; 81 HostMap host_map_;
82 CapabilityMap known_capability_map_;
60 83
61 DISALLOW_COPY_AND_ASSIGN(HttpPipelinedHostPool); 84 DISALLOW_COPY_AND_ASSIGN(HttpPipelinedHostPool);
62 }; 85 };
63 86
64 } // namespace net 87 } // namespace net
65 88
66 #endif // NET_HTTP_HTTP_PIPELINED_HOST_POOL_H_ 89 #endif // NET_HTTP_HTTP_PIPELINED_HOST_POOL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698