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

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

Issue 8770035: Save pipelining capabilities for the most used hosts between sessions. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merged Created 9 years 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_host_impl_unittest.cc ('k') | net/http/http_pipelined_host_pool.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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" 12 #include "base/gtest_prod_util.h"
13 #include "base/memory/mru_cache.h"
14 #include "base/memory/scoped_ptr.h" 13 #include "base/memory/scoped_ptr.h"
15 #include "net/http/http_pipelined_host.h" 14 #include "net/http/http_pipelined_host.h"
15 #include "net/http/http_pipelined_host_capability.h"
16 16
17 namespace net { 17 namespace net {
18 18
19 class HostPortPair; 19 class HostPortPair;
20 class HttpPipelinedStream; 20 class HttpPipelinedStream;
21 class HttpServerProperties;
21 22
22 // Manages all of the pipelining state for specific host with active pipelined 23 // Manages all of the pipelining state for specific host with active pipelined
23 // HTTP requests. Manages connection jobs, constructs pipelined streams, and 24 // HTTP requests. Manages connection jobs, constructs pipelined streams, and
24 // assigns requests to the least loaded pipelined connection. 25 // assigns requests to the least loaded pipelined connection.
25 class NET_EXPORT_PRIVATE HttpPipelinedHostPool 26 class NET_EXPORT_PRIVATE HttpPipelinedHostPool
26 : public HttpPipelinedHost::Delegate { 27 : public HttpPipelinedHost::Delegate {
27 public: 28 public:
28 class Delegate { 29 class Delegate {
29 public: 30 public:
30 // Called when a HttpPipelinedHost has new capacity. Attempts to allocate 31 // Called when a HttpPipelinedHost has new capacity. Attempts to allocate
31 // any pending pipeline-capable requests to pipelines. 32 // any pending pipeline-capable requests to pipelines.
32 virtual void OnHttpPipelinedHostHasAdditionalCapacity( 33 virtual void OnHttpPipelinedHostHasAdditionalCapacity(
33 const HostPortPair& origin) = 0; 34 const HostPortPair& origin) = 0;
34 }; 35 };
35 36
36 HttpPipelinedHostPool(Delegate* delegate, 37 HttpPipelinedHostPool(Delegate* delegate,
37 HttpPipelinedHost::Factory* factory); 38 HttpPipelinedHost::Factory* factory,
39 HttpServerProperties* http_server_properties_);
38 virtual ~HttpPipelinedHostPool(); 40 virtual ~HttpPipelinedHostPool();
39 41
40 // Returns true if pipelining might work for |origin|. Generally, this returns 42 // Returns true if pipelining might work for |origin|. Generally, this returns
41 // true, unless |origin| is known to have failed pipelining recently. 43 // true, unless |origin| is known to have failed pipelining recently.
42 bool IsHostEligibleForPipelining(const HostPortPair& origin); 44 bool IsHostEligibleForPipelining(const HostPortPair& origin);
43 45
44 // Constructs a new pipeline on |connection| and returns a new 46 // Constructs a new pipeline on |connection| and returns a new
45 // HttpPipelinedStream that uses it. 47 // HttpPipelinedStream that uses it.
46 HttpPipelinedStream* CreateStreamOnNewPipeline( 48 HttpPipelinedStream* CreateStreamOnNewPipeline(
47 const HostPortPair& origin, 49 const HostPortPair& origin,
(...skipping 12 matching lines...) Expand all
60 // can accept new requests. 62 // can accept new requests.
61 bool IsExistingPipelineAvailableForOrigin(const HostPortPair& origin); 63 bool IsExistingPipelineAvailableForOrigin(const HostPortPair& origin);
62 64
63 // Callbacks for HttpPipelinedHost. 65 // Callbacks for HttpPipelinedHost.
64 virtual void OnHostIdle(HttpPipelinedHost* host) OVERRIDE; 66 virtual void OnHostIdle(HttpPipelinedHost* host) OVERRIDE;
65 67
66 virtual void OnHostHasAdditionalCapacity(HttpPipelinedHost* host) OVERRIDE; 68 virtual void OnHostHasAdditionalCapacity(HttpPipelinedHost* host) OVERRIDE;
67 69
68 virtual void OnHostDeterminedCapability( 70 virtual void OnHostDeterminedCapability(
69 HttpPipelinedHost* host, 71 HttpPipelinedHost* host,
70 HttpPipelinedHost::Capability capability) OVERRIDE; 72 HttpPipelinedHostCapability capability) OVERRIDE;
71 73
72 private: 74 private:
73 typedef base::MRUCache<HostPortPair,
74 HttpPipelinedHost::Capability> CapabilityMap;
75 typedef std::map<const HostPortPair, HttpPipelinedHost*> HostMap; 75 typedef std::map<const HostPortPair, HttpPipelinedHost*> HostMap;
76 76
77 HttpPipelinedHost* GetPipelinedHost(const HostPortPair& origin, 77 HttpPipelinedHost* GetPipelinedHost(const HostPortPair& origin,
78 bool create_if_not_found); 78 bool create_if_not_found);
79 79
80 HttpPipelinedHost::Capability GetHostCapability(const HostPortPair& origin);
81
82 Delegate* delegate_; 80 Delegate* delegate_;
83 scoped_ptr<HttpPipelinedHost::Factory> factory_; 81 scoped_ptr<HttpPipelinedHost::Factory> factory_;
84 HostMap host_map_; 82 HostMap host_map_;
85 CapabilityMap known_capability_map_; 83 HttpServerProperties* http_server_properties_;
86 84
87 DISALLOW_COPY_AND_ASSIGN(HttpPipelinedHostPool); 85 DISALLOW_COPY_AND_ASSIGN(HttpPipelinedHostPool);
88 }; 86 };
89 87
90 } // namespace net 88 } // namespace net
91 89
92 #endif // NET_HTTP_HTTP_PIPELINED_HOST_POOL_H_ 90 #endif // NET_HTTP_HTTP_PIPELINED_HOST_POOL_H_
OLDNEW
« no previous file with comments | « net/http/http_pipelined_host_impl_unittest.cc ('k') | net/http/http_pipelined_host_pool.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698