Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(276)

Side by Side Diff: net/socket/websocket_transport_client_socket_pool.cc

Issue 2341233002: Replace NULL with nullptr in WebSocket code in net/socket/ (Closed)
Patch Set: Rebase Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 269 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 WebSocketTransportClientSocketPool::WebSocketTransportClientSocketPool( 280 WebSocketTransportClientSocketPool::WebSocketTransportClientSocketPool(
281 int max_sockets, 281 int max_sockets,
282 int max_sockets_per_group, 282 int max_sockets_per_group,
283 HostResolver* host_resolver, 283 HostResolver* host_resolver,
284 ClientSocketFactory* client_socket_factory, 284 ClientSocketFactory* client_socket_factory,
285 NetLog* net_log) 285 NetLog* net_log)
286 : TransportClientSocketPool(max_sockets, 286 : TransportClientSocketPool(max_sockets,
287 max_sockets_per_group, 287 max_sockets_per_group,
288 host_resolver, 288 host_resolver,
289 client_socket_factory, 289 client_socket_factory,
290 NULL, 290 nullptr,
291 net_log), 291 net_log),
292 connect_job_delegate_(this), 292 connect_job_delegate_(this),
293 pool_net_log_(net_log), 293 pool_net_log_(net_log),
294 client_socket_factory_(client_socket_factory), 294 client_socket_factory_(client_socket_factory),
295 host_resolver_(host_resolver), 295 host_resolver_(host_resolver),
296 max_sockets_(max_sockets), 296 max_sockets_(max_sockets),
297 handed_out_socket_count_(0), 297 handed_out_socket_count_(0),
298 flushing_(false), 298 flushing_(false),
299 weak_factory_(this) {} 299 weak_factory_(this) {}
300 300
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
423 // then OnConnectJobComplete(). The |flushing_| flag tells this object to 423 // then OnConnectJobComplete(). The |flushing_| flag tells this object to
424 // ignore spurious calls to OnConnectJobComplete(). It is safe to ignore those 424 // ignore spurious calls to OnConnectJobComplete(). It is safe to ignore those
425 // calls because this method will delete the jobs and call their callbacks 425 // calls because this method will delete the jobs and call their callbacks
426 // anyway. 426 // anyway.
427 flushing_ = true; 427 flushing_ = true;
428 for (PendingConnectsMap::iterator it = pending_connects_.begin(); 428 for (PendingConnectsMap::iterator it = pending_connects_.begin();
429 it != pending_connects_.end(); 429 it != pending_connects_.end();
430 ++it) { 430 ++it) {
431 InvokeUserCallbackLater( 431 InvokeUserCallbackLater(
432 it->second->handle(), it->second->callback(), error); 432 it->second->handle(), it->second->callback(), error);
433 delete it->second, it->second = NULL; 433 delete it->second, it->second = nullptr;
434 } 434 }
435 pending_connects_.clear(); 435 pending_connects_.clear();
436 for (StalledRequestQueue::iterator it = stalled_request_queue_.begin(); 436 for (StalledRequestQueue::iterator it = stalled_request_queue_.begin();
437 it != stalled_request_queue_.end(); 437 it != stalled_request_queue_.end();
438 ++it) { 438 ++it) {
439 InvokeUserCallbackLater(it->handle, it->callback, error); 439 InvokeUserCallbackLater(it->handle, it->callback, error);
440 } 440 }
441 stalled_request_map_.clear(); 441 stalled_request_map_.clear();
442 stalled_request_queue_.clear(); 442 stalled_request_queue_.clear();
443 flushing_ = false; 443 flushing_ = false;
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
544 544
545 bool handed_out_socket = TryHandOutSocket(result, job); 545 bool handed_out_socket = TryHandOutSocket(result, job);
546 546
547 CompletionCallback callback = job->callback(); 547 CompletionCallback callback = job->callback();
548 548
549 ClientSocketHandle* const handle = job->handle(); 549 ClientSocketHandle* const handle = job->handle();
550 550
551 bool delete_succeeded = DeleteJob(handle); 551 bool delete_succeeded = DeleteJob(handle);
552 DCHECK(delete_succeeded); 552 DCHECK(delete_succeeded);
553 553
554 job = NULL; 554 job = nullptr;
555 555
556 if (!handed_out_socket) 556 if (!handed_out_socket)
557 ActivateStalledRequest(); 557 ActivateStalledRequest();
558 558
559 InvokeUserCallbackLater(handle, callback, result); 559 InvokeUserCallbackLater(handle, callback, result);
560 } 560 }
561 561
562 void WebSocketTransportClientSocketPool::InvokeUserCallbackLater( 562 void WebSocketTransportClientSocketPool::InvokeUserCallbackLater(
563 ClientSocketHandle* handle, 563 ClientSocketHandle* handle,
564 const CompletionCallback& callback, 564 const CompletionCallback& callback,
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
616 616
617 bool WebSocketTransportClientSocketPool::DeleteJob(ClientSocketHandle* handle) { 617 bool WebSocketTransportClientSocketPool::DeleteJob(ClientSocketHandle* handle) {
618 PendingConnectsMap::iterator it = pending_connects_.find(handle); 618 PendingConnectsMap::iterator it = pending_connects_.find(handle);
619 if (it == pending_connects_.end()) 619 if (it == pending_connects_.end())
620 return false; 620 return false;
621 // Deleting a ConnectJob which holds an endpoint lock can lead to a different 621 // Deleting a ConnectJob which holds an endpoint lock can lead to a different
622 // ConnectJob proceeding to connect. If the connect proceeds synchronously 622 // ConnectJob proceeding to connect. If the connect proceeds synchronously
623 // (usually because of a failure) then it can trigger that job to be 623 // (usually because of a failure) then it can trigger that job to be
624 // deleted. |it| remains valid because std::map guarantees that erase() does 624 // deleted. |it| remains valid because std::map guarantees that erase() does
625 // not invalid iterators to other entries. 625 // not invalid iterators to other entries.
626 delete it->second, it->second = NULL; 626 delete it->second, it->second = nullptr;
627 DCHECK(pending_connects_.find(handle) == it); 627 DCHECK(pending_connects_.find(handle) == it);
628 pending_connects_.erase(it); 628 pending_connects_.erase(it);
629 return true; 629 return true;
630 } 630 }
631 631
632 const WebSocketTransportConnectJob* 632 const WebSocketTransportConnectJob*
633 WebSocketTransportClientSocketPool::LookupConnectJob( 633 WebSocketTransportClientSocketPool::LookupConnectJob(
634 const ClientSocketHandle* handle) const { 634 const ClientSocketHandle* handle) const {
635 PendingConnectsMap::const_iterator it = pending_connects_.find(handle); 635 PendingConnectsMap::const_iterator it = pending_connects_.find(handle);
636 CHECK(it != pending_connects_.end()); 636 CHECK(it != pending_connects_.end());
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
694 handle(handle), 694 handle(handle),
695 callback(callback), 695 callback(callback),
696 net_log(net_log) {} 696 net_log(net_log) {}
697 697
698 WebSocketTransportClientSocketPool::StalledRequest::StalledRequest( 698 WebSocketTransportClientSocketPool::StalledRequest::StalledRequest(
699 const StalledRequest& other) = default; 699 const StalledRequest& other) = default;
700 700
701 WebSocketTransportClientSocketPool::StalledRequest::~StalledRequest() {} 701 WebSocketTransportClientSocketPool::StalledRequest::~StalledRequest() {}
702 702
703 } // namespace net 703 } // namespace net
OLDNEW
« no previous file with comments | « net/socket/websocket_endpoint_lock_manager.cc ('k') | net/socket/websocket_transport_client_socket_pool_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698