OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #include "net/spdy/spdy_session_pool.h" | 5 #include "net/spdy/spdy_session_pool.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
155 } | 155 } |
156 return spdy_session; | 156 return spdy_session; |
157 } | 157 } |
158 if (url_it->second.empty()) { | 158 if (url_it->second.empty()) { |
159 unclaimed_pushed_streams_.erase(url_it); | 159 unclaimed_pushed_streams_.erase(url_it); |
160 } | 160 } |
161 } | 161 } |
162 | 162 |
163 AvailableSessionMap::iterator it = LookupAvailableSessionByKey(key); | 163 AvailableSessionMap::iterator it = LookupAvailableSessionByKey(key); |
164 if (it != available_sessions_.end()) { | 164 if (it != available_sessions_.end()) { |
165 UMA_HISTOGRAM_ENUMERATION( | 165 if (key.Equals(it->second->spdy_session_key())) { |
166 "Net.SpdySessionGet", FOUND_EXISTING, SPDY_SESSION_GET_MAX); | 166 UMA_HISTOGRAM_ENUMERATION("Net.SpdySessionGet", FOUND_EXISTING, |
167 net_log.AddEvent( | 167 SPDY_SESSION_GET_MAX); |
168 NetLogEventType::HTTP2_SESSION_POOL_FOUND_EXISTING_SESSION, | 168 net_log.AddEvent( |
169 it->second->net_log().source().ToEventParametersCallback()); | 169 NetLogEventType::HTTP2_SESSION_POOL_FOUND_EXISTING_SESSION, |
| 170 it->second->net_log().source().ToEventParametersCallback()); |
| 171 } else { |
| 172 UMA_HISTOGRAM_ENUMERATION("Net.SpdySessionGet", |
| 173 FOUND_EXISTING_FROM_IP_POOL, |
| 174 SPDY_SESSION_GET_MAX); |
| 175 net_log.AddEvent( |
| 176 NetLogEventType:: |
| 177 HTTP2_SESSION_POOL_FOUND_EXISTING_SESSION_FROM_IP_POOL, |
| 178 it->second->net_log().source().ToEventParametersCallback()); |
| 179 } |
170 return it->second; | 180 return it->second; |
171 } | 181 } |
172 | 182 |
173 // Look up the key's from the resolver's cache. | 183 // Look up IP addresses from resolver cache. |
174 HostResolver::RequestInfo resolve_info(key.host_port_pair()); | 184 HostResolver::RequestInfo resolve_info(key.host_port_pair()); |
175 AddressList addresses; | 185 AddressList addresses; |
176 int rv = resolver_->ResolveFromCache(resolve_info, &addresses, net_log); | 186 int rv = resolver_->ResolveFromCache(resolve_info, &addresses, net_log); |
177 DCHECK_NE(rv, ERR_IO_PENDING); | 187 DCHECK_NE(rv, ERR_IO_PENDING); |
178 if (rv != OK) | 188 if (rv != OK) |
179 return base::WeakPtr<SpdySession>(); | 189 return base::WeakPtr<SpdySession>(); |
180 | 190 |
181 // Check if we have a session through a domain alias. | 191 // Check if we have a session through a domain alias. |
182 for (AddressList::const_iterator address_it = addresses.begin(); | 192 for (AddressList::const_iterator address_it = addresses.begin(); |
183 address_it != addresses.end(); | 193 address_it != addresses.end(); |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
275 while (!available_sessions_.empty()) { | 285 while (!available_sessions_.empty()) { |
276 CloseCurrentSessionsHelper(ERR_ABORTED, "Closing all sessions.", | 286 CloseCurrentSessionsHelper(ERR_ABORTED, "Closing all sessions.", |
277 false /* idle_only */); | 287 false /* idle_only */); |
278 } | 288 } |
279 } | 289 } |
280 | 290 |
281 void SpdySessionPool::RegisterUnclaimedPushedStream( | 291 void SpdySessionPool::RegisterUnclaimedPushedStream( |
282 GURL url, | 292 GURL url, |
283 base::WeakPtr<SpdySession> spdy_session) { | 293 base::WeakPtr<SpdySession> spdy_session) { |
284 DCHECK(!url.is_empty()); | 294 DCHECK(!url.is_empty()); |
285 // This SpdySessionPool must own |spdy_session|. | 295 // This SpdySessionPool must own |spdy_session|. |
286 DCHECK(base::ContainsKey(sessions_, spdy_session.get())); | 296 DCHECK(base::ContainsKey(sessions_, spdy_session.get())); |
287 UnclaimedPushedStreamMap::iterator url_it = | 297 UnclaimedPushedStreamMap::iterator url_it = |
288 unclaimed_pushed_streams_.lower_bound(url); | 298 unclaimed_pushed_streams_.lower_bound(url); |
289 if (url_it == unclaimed_pushed_streams_.end() || url_it->first != url) { | 299 if (url_it == unclaimed_pushed_streams_.end() || url_it->first != url) { |
290 WeakSessionList list; | 300 WeakSessionList list; |
291 list.push_back(std::move(spdy_session)); | 301 list.push_back(std::move(spdy_session)); |
292 UnclaimedPushedStreamMap::value_type value(std::move(url), std::move(list)); | 302 UnclaimedPushedStreamMap::value_type value(std::move(url), std::move(list)); |
293 unclaimed_pushed_streams_.insert(url_it, std::move(value)); | 303 unclaimed_pushed_streams_.insert(url_it, std::move(value)); |
294 return; | 304 return; |
295 } | 305 } |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
483 | 493 |
484 if (idle_only && (*it)->is_active()) | 494 if (idle_only && (*it)->is_active()) |
485 continue; | 495 continue; |
486 | 496 |
487 (*it)->CloseSessionOnError(error, description); | 497 (*it)->CloseSessionOnError(error, description); |
488 DCHECK(!IsSessionAvailable(*it)); | 498 DCHECK(!IsSessionAvailable(*it)); |
489 } | 499 } |
490 } | 500 } |
491 | 501 |
492 } // namespace net | 502 } // namespace net |
OLD | NEW |