| 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/http/http_stream_factory_impl.h" | 5 #include "net/http/http_stream_factory_impl.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <tuple> | 8 #include <tuple> |
| 9 | 9 |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 243 if (!spdy_session) | 243 if (!spdy_session) |
| 244 break; | 244 break; |
| 245 const SpdySessionKey& spdy_session_key = spdy_session->spdy_session_key(); | 245 const SpdySessionKey& spdy_session_key = spdy_session->spdy_session_key(); |
| 246 // Each iteration may empty out the RequestSet for |spdy_session_key| in | 246 // Each iteration may empty out the RequestSet for |spdy_session_key| in |
| 247 // |spdy_session_request_map_|. So each time, check for RequestSet and use | 247 // |spdy_session_request_map_|. So each time, check for RequestSet and use |
| 248 // the first one. | 248 // the first one. |
| 249 // | 249 // |
| 250 // TODO(willchan): If it's important, switch RequestSet out for a FIFO | 250 // TODO(willchan): If it's important, switch RequestSet out for a FIFO |
| 251 // queue (Order by priority first, then FIFO within same priority). Unclear | 251 // queue (Order by priority first, then FIFO within same priority). Unclear |
| 252 // that it matters here. | 252 // that it matters here. |
| 253 if (!base::ContainsKey(spdy_session_request_map_, spdy_session_key)) | 253 auto iter = spdy_session_request_map_.find(spdy_session_key); |
| 254 if (iter == spdy_session_request_map_.end()) |
| 254 break; | 255 break; |
| 255 Request* request = *spdy_session_request_map_[spdy_session_key].begin(); | 256 Request* request = *iter->second.begin(); |
| 256 request->Complete(was_alpn_negotiated, negotiated_protocol, using_spdy); | 257 request->Complete(was_alpn_negotiated, negotiated_protocol, using_spdy); |
| 258 RemoveRequestFromSpdySessionRequestMap(request); |
| 257 if (for_websockets_) { | 259 if (for_websockets_) { |
| 258 // TODO(ricea): Restore this code path when WebSocket over SPDY | 260 // TODO(ricea): Restore this code path when WebSocket over SPDY |
| 259 // implementation is ready. | 261 // implementation is ready. |
| 260 NOTREACHED(); | 262 NOTREACHED(); |
| 261 } else if (request->stream_type() == | 263 } else if (request->stream_type() == |
| 262 HttpStreamRequest::BIDIRECTIONAL_STREAM) { | 264 HttpStreamRequest::BIDIRECTIONAL_STREAM) { |
| 263 request->OnBidirectionalStreamImplReady( | 265 request->OnBidirectionalStreamImplReady( |
| 264 used_ssl_config, used_proxy_info, | 266 used_ssl_config, used_proxy_info, |
| 265 new BidirectionalStreamSpdyImpl(spdy_session, source_dependency)); | 267 new BidirectionalStreamSpdyImpl(spdy_session, source_dependency)); |
| 266 } else { | 268 } else { |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 406 // The number of non-preconnect controllers with a pending main job. | 408 // The number of non-preconnect controllers with a pending main job. |
| 407 factory_dump->AddScalar("main_job_count", | 409 factory_dump->AddScalar("main_job_count", |
| 408 base::trace_event::MemoryAllocatorDump::kUnitsObjects, | 410 base::trace_event::MemoryAllocatorDump::kUnitsObjects, |
| 409 main_job_count); | 411 main_job_count); |
| 410 // The number of preconnect controllers. | 412 // The number of preconnect controllers. |
| 411 factory_dump->AddScalar("preconnect_count", | 413 factory_dump->AddScalar("preconnect_count", |
| 412 base::trace_event::MemoryAllocatorDump::kUnitsObjects, | 414 base::trace_event::MemoryAllocatorDump::kUnitsObjects, |
| 413 preconnect_controller_count); | 415 preconnect_controller_count); |
| 414 } | 416 } |
| 415 | 417 |
| 418 void HttpStreamFactoryImpl::RemoveRequestFromSpdySessionRequestMap( |
| 419 Request* request) { |
| 420 const SpdySessionKey* spdy_session_key = request->spdy_session_key(); |
| 421 if (!spdy_session_key) |
| 422 return; |
| 423 auto iter = spdy_session_request_map_.find(*spdy_session_key); |
| 424 if (iter == spdy_session_request_map_.end()) |
| 425 return; |
| 426 RequestSet& request_set = iter->second; |
| 427 // erase() is no-op if |request| isn't contained in |request_set|. |
| 428 request_set.erase(request); |
| 429 if (request_set.empty()) |
| 430 spdy_session_request_map_.erase(iter); |
| 431 } |
| 432 |
| 416 } // namespace net | 433 } // namespace net |
| OLD | NEW |