OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/socket/websocket_transport_client_socket_pool.h" | 5 #include "net/socket/websocket_transport_client_socket_pool.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
(...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
335 NetLogTcpClientSocketPoolRequestedSocket(request_net_log, &casted_params); | 335 NetLogTcpClientSocketPoolRequestedSocket(request_net_log, &casted_params); |
336 | 336 |
337 CHECK(!callback.is_null()); | 337 CHECK(!callback.is_null()); |
338 CHECK(handle); | 338 CHECK(handle); |
339 | 339 |
340 request_net_log.BeginEvent(NetLogEventType::SOCKET_POOL); | 340 request_net_log.BeginEvent(NetLogEventType::SOCKET_POOL); |
341 | 341 |
342 if (ReachedMaxSocketsLimit() && | 342 if (ReachedMaxSocketsLimit() && |
343 respect_limits == ClientSocketPool::RespectLimits::ENABLED) { | 343 respect_limits == ClientSocketPool::RespectLimits::ENABLED) { |
344 request_net_log.AddEvent(NetLogEventType::SOCKET_POOL_STALLED_MAX_SOCKETS); | 344 request_net_log.AddEvent(NetLogEventType::SOCKET_POOL_STALLED_MAX_SOCKETS); |
345 // TODO(ricea): Use emplace_back when C++11 becomes allowed. | 345 stalled_request_queue_.emplace_back(casted_params, priority, handle, |
346 StalledRequest request( | 346 callback, request_net_log); |
347 casted_params, priority, handle, callback, request_net_log); | |
348 stalled_request_queue_.push_back(request); | |
349 StalledRequestQueue::iterator iterator = stalled_request_queue_.end(); | 347 StalledRequestQueue::iterator iterator = stalled_request_queue_.end(); |
350 --iterator; | 348 --iterator; |
351 DCHECK_EQ(handle, iterator->handle); | 349 DCHECK_EQ(handle, iterator->handle); |
352 // Because StalledRequestQueue is a std::list, its iterators are guaranteed | 350 // Because StalledRequestQueue is a std::list, its iterators are guaranteed |
353 // to remain valid as long as the elements are not removed. As long as | 351 // to remain valid as long as the elements are not removed. As long as |
354 // stalled_request_queue_ and stalled_request_map_ are updated in sync, it | 352 // stalled_request_queue_ and stalled_request_map_ are updated in sync, it |
355 // is safe to dereference an iterator in stalled_request_map_ to find the | 353 // is safe to dereference an iterator in stalled_request_map_ to find the |
356 // corresponding list element. | 354 // corresponding list element. |
357 stalled_request_map_.insert( | 355 stalled_request_map_.insert( |
358 StalledRequestMap::value_type(handle, iterator)); | 356 StalledRequestMap::value_type(handle, iterator)); |
(...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
715 handle(handle), | 713 handle(handle), |
716 callback(callback), | 714 callback(callback), |
717 net_log(net_log) {} | 715 net_log(net_log) {} |
718 | 716 |
719 WebSocketTransportClientSocketPool::StalledRequest::StalledRequest( | 717 WebSocketTransportClientSocketPool::StalledRequest::StalledRequest( |
720 const StalledRequest& other) = default; | 718 const StalledRequest& other) = default; |
721 | 719 |
722 WebSocketTransportClientSocketPool::StalledRequest::~StalledRequest() {} | 720 WebSocketTransportClientSocketPool::StalledRequest::~StalledRequest() {} |
723 | 721 |
724 } // namespace net | 722 } // namespace net |
OLD | NEW |