Chromium Code Reviews| 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 if (!base::ContainsKey(spdy_session_request_map_, spdy_session_key)) |
|
Bence
2017/03/31 16:21:27
Once you are here, consider removing one of these
xunjieli
2017/03/31 17:45:26
Done.
| |
| 254 break; | 254 break; |
| 255 Request* request = *spdy_session_request_map_[spdy_session_key].begin(); | 255 Request* request = *spdy_session_request_map_[spdy_session_key].begin(); |
| 256 request->Complete(was_alpn_negotiated, negotiated_protocol, using_spdy); | 256 request->Complete(was_alpn_negotiated, negotiated_protocol, using_spdy); |
| 257 RemoveRequestFromSpdySessionRequestMap(request); | |
| 257 if (for_websockets_) { | 258 if (for_websockets_) { |
| 258 // TODO(ricea): Restore this code path when WebSocket over SPDY | 259 // TODO(ricea): Restore this code path when WebSocket over SPDY |
| 259 // implementation is ready. | 260 // implementation is ready. |
| 260 NOTREACHED(); | 261 NOTREACHED(); |
| 261 } else if (request->stream_type() == | 262 } else if (request->stream_type() == |
| 262 HttpStreamRequest::BIDIRECTIONAL_STREAM) { | 263 HttpStreamRequest::BIDIRECTIONAL_STREAM) { |
| 263 request->OnBidirectionalStreamImplReady( | 264 request->OnBidirectionalStreamImplReady( |
| 264 used_ssl_config, used_proxy_info, | 265 used_ssl_config, used_proxy_info, |
| 265 new BidirectionalStreamSpdyImpl(spdy_session, source_dependency)); | 266 new BidirectionalStreamSpdyImpl(spdy_session, source_dependency)); |
| 266 } else { | 267 } 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. | 407 // The number of non-preconnect controllers with a pending main job. |
| 407 factory_dump->AddScalar("main_job_count", | 408 factory_dump->AddScalar("main_job_count", |
| 408 base::trace_event::MemoryAllocatorDump::kUnitsObjects, | 409 base::trace_event::MemoryAllocatorDump::kUnitsObjects, |
| 409 main_job_count); | 410 main_job_count); |
| 410 // The number of preconnect controllers. | 411 // The number of preconnect controllers. |
| 411 factory_dump->AddScalar("preconnect_count", | 412 factory_dump->AddScalar("preconnect_count", |
| 412 base::trace_event::MemoryAllocatorDump::kUnitsObjects, | 413 base::trace_event::MemoryAllocatorDump::kUnitsObjects, |
| 413 preconnect_controller_count); | 414 preconnect_controller_count); |
| 414 } | 415 } |
| 415 | 416 |
| 417 void HttpStreamFactoryImpl::RemoveRequestFromSpdySessionRequestMap( | |
| 418 Request* request) { | |
| 419 const SpdySessionKey* spdy_session_key = request->spdy_session_key(); | |
| 420 if (!spdy_session_key) | |
| 421 return; | |
| 422 if (!base::ContainsKey(spdy_session_request_map_, *spdy_session_key)) | |
|
Bence
2017/03/31 16:21:27
Please use |iterator it = find(*spdy_session_key);
xunjieli
2017/03/31 17:45:26
Done.
| |
| 423 return; | |
| 424 RequestSet& request_set = spdy_session_request_map_[*spdy_session_key]; | |
| 425 if (base::ContainsKey(request_set, request)) | |
|
Bence
2017/03/31 16:21:27
Skip the ContainsKey() call in order to avoid doin
xunjieli
2017/03/31 17:45:26
Done.
| |
| 426 request_set.erase(request); | |
| 427 if (request_set.empty()) | |
| 428 spdy_session_request_map_.erase(*spdy_session_key); | |
|
Bence
2017/03/31 16:21:27
And use the iterator here to avoid the third looku
xunjieli
2017/03/31 17:45:26
Done. Good idea!
| |
| 429 } | |
| 430 | |
| 416 } // namespace net | 431 } // namespace net |
| OLD | NEW |