OLD | NEW |
---|---|
(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 #include "net/http/http_pipelined_host_pool.h" | |
6 | |
7 #include "base/logging.h" | |
8 #include "base/stl_util-inl.h" | |
9 #include "net/http/http_pipelined_host.h" | |
10 #include "net/http/http_stream_factory.h" | |
11 | |
12 namespace net { | |
13 | |
14 HttpPipelinedHostPool::HttpPipelinedHostPool(HttpStreamFactory* factory) | |
15 : factory_(factory) { | |
mmenke
2011/08/03 21:09:39
nit: Should be four spaces.
James Simonsen
2011/08/05 01:39:00
Done.
| |
16 } | |
17 | |
18 HttpPipelinedHostPool::~HttpPipelinedHostPool() { | |
19 DCHECK(host_map_.empty()); | |
20 } | |
21 | |
22 HttpPipelinedHost* HttpPipelinedHostPool::GetPipelinedHost( | |
23 const HostPortPair& origin, bool create_if_not_found) { | |
24 HostMap::iterator it = host_map_.find(origin); | |
25 if (it != host_map_.end()) { | |
26 DCHECK(it->second); | |
27 return it->second; | |
28 } else if (!create_if_not_found) { | |
29 return NULL; | |
30 } | |
31 HttpPipelinedHost* host = new HttpPipelinedHost(this, origin); | |
32 host_map_[origin] = host; | |
33 return host; | |
34 } | |
35 | |
36 void HttpPipelinedHostPool::OnHostIdle(HttpPipelinedHost* host) { | |
37 const HostPortPair& origin = host->origin(); | |
38 DCHECK(ContainsKey(host_map_, origin)); | |
39 host_map_.erase(origin); | |
40 delete host; | |
41 } | |
42 | |
43 void HttpPipelinedHostPool::OnHostHasAdditionalCapacity( | |
44 HttpPipelinedHost* host) { | |
45 factory_->OnHttpPipelinedHostHasAdditionalCapacity(host); | |
46 } | |
47 | |
48 } // namespace net | |
OLD | NEW |