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

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

Issue 1545233002: Convert Pass()→std::move() in //net (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 12 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 9
9 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
10 #include "base/location.h" 11 #include "base/location.h"
11 #include "base/logging.h" 12 #include "base/logging.h"
12 #include "base/numerics/safe_conversions.h" 13 #include "base/numerics/safe_conversions.h"
13 #include "base/single_thread_task_runner.h" 14 #include "base/single_thread_task_runner.h"
14 #include "base/strings/string_util.h" 15 #include "base/strings/string_util.h"
15 #include "base/thread_task_runner_handle.h" 16 #include "base/thread_task_runner_handle.h"
16 #include "base/time/time.h" 17 #include "base/time/time.h"
17 #include "base/values.h" 18 #include "base/values.h"
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after
325 NetLog::TYPE_SOCKET_POOL_BOUND_TO_CONNECT_JOB, 326 NetLog::TYPE_SOCKET_POOL_BOUND_TO_CONNECT_JOB,
326 connect_job->net_log().source().ToEventParametersCallback()); 327 connect_job->net_log().source().ToEventParametersCallback());
327 if (rv == OK) { 328 if (rv == OK) {
328 HandOutSocket(connect_job->PassSocket(), 329 HandOutSocket(connect_job->PassSocket(),
329 connect_job->connect_timing(), 330 connect_job->connect_timing(),
330 handle, 331 handle,
331 request_net_log); 332 request_net_log);
332 request_net_log.EndEvent(NetLog::TYPE_SOCKET_POOL); 333 request_net_log.EndEvent(NetLog::TYPE_SOCKET_POOL);
333 } else if (rv == ERR_IO_PENDING) { 334 } else if (rv == ERR_IO_PENDING) {
334 // TODO(ricea): Implement backup job timer? 335 // TODO(ricea): Implement backup job timer?
335 AddJob(handle, connect_job.Pass()); 336 AddJob(handle, std::move(connect_job));
336 } else { 337 } else {
337 scoped_ptr<StreamSocket> error_socket; 338 scoped_ptr<StreamSocket> error_socket;
338 connect_job->GetAdditionalErrorState(handle); 339 connect_job->GetAdditionalErrorState(handle);
339 error_socket = connect_job->PassSocket(); 340 error_socket = connect_job->PassSocket();
340 if (error_socket) { 341 if (error_socket) {
341 HandOutSocket(error_socket.Pass(), 342 HandOutSocket(std::move(error_socket), connect_job->connect_timing(),
342 connect_job->connect_timing(), 343 handle, request_net_log);
343 handle,
344 request_net_log);
345 } 344 }
346 } 345 }
347 346
348 if (rv != ERR_IO_PENDING) { 347 if (rv != ERR_IO_PENDING) {
349 request_net_log.EndEventWithNetErrorCode(NetLog::TYPE_SOCKET_POOL, rv); 348 request_net_log.EndEventWithNetErrorCode(NetLog::TYPE_SOCKET_POOL, rv);
350 } 349 }
351 350
352 return rv; 351 return rv;
353 } 352 }
354 353
355 void WebSocketTransportClientSocketPool::RequestSockets( 354 void WebSocketTransportClientSocketPool::RequestSockets(
356 const std::string& group_name, 355 const std::string& group_name,
357 const void* params, 356 const void* params,
358 int num_sockets, 357 int num_sockets,
359 const BoundNetLog& net_log) { 358 const BoundNetLog& net_log) {
360 NOTIMPLEMENTED(); 359 NOTIMPLEMENTED();
361 } 360 }
362 361
363 void WebSocketTransportClientSocketPool::CancelRequest( 362 void WebSocketTransportClientSocketPool::CancelRequest(
364 const std::string& group_name, 363 const std::string& group_name,
365 ClientSocketHandle* handle) { 364 ClientSocketHandle* handle) {
366 DCHECK(!handle->is_initialized()); 365 DCHECK(!handle->is_initialized());
367 if (DeleteStalledRequest(handle)) 366 if (DeleteStalledRequest(handle))
368 return; 367 return;
369 scoped_ptr<StreamSocket> socket = handle->PassSocket(); 368 scoped_ptr<StreamSocket> socket = handle->PassSocket();
370 if (socket) 369 if (socket)
371 ReleaseSocket(handle->group_name(), socket.Pass(), handle->id()); 370 ReleaseSocket(handle->group_name(), std::move(socket), handle->id());
372 if (!DeleteJob(handle)) 371 if (!DeleteJob(handle))
373 pending_callbacks_.erase(handle); 372 pending_callbacks_.erase(handle);
374 if (!ReachedMaxSocketsLimit() && !stalled_request_queue_.empty()) 373 if (!ReachedMaxSocketsLimit() && !stalled_request_queue_.empty())
375 ActivateStalledRequest(); 374 ActivateStalledRequest();
376 } 375 }
377 376
378 void WebSocketTransportClientSocketPool::ReleaseSocket( 377 void WebSocketTransportClientSocketPool::ReleaseSocket(
379 const std::string& group_name, 378 const std::string& group_name,
380 scoped_ptr<StreamSocket> socket, 379 scoped_ptr<StreamSocket> socket,
381 int id) { 380 int id) {
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
442 bool include_nested_pools) const { 441 bool include_nested_pools) const {
443 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); 442 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue());
444 dict->SetString("name", name); 443 dict->SetString("name", name);
445 dict->SetString("type", type); 444 dict->SetString("type", type);
446 dict->SetInteger("handed_out_socket_count", handed_out_socket_count_); 445 dict->SetInteger("handed_out_socket_count", handed_out_socket_count_);
447 dict->SetInteger("connecting_socket_count", pending_connects_.size()); 446 dict->SetInteger("connecting_socket_count", pending_connects_.size());
448 dict->SetInteger("idle_socket_count", 0); 447 dict->SetInteger("idle_socket_count", 0);
449 dict->SetInteger("max_socket_count", max_sockets_); 448 dict->SetInteger("max_socket_count", max_sockets_);
450 dict->SetInteger("max_sockets_per_group", max_sockets_); 449 dict->SetInteger("max_sockets_per_group", max_sockets_);
451 dict->SetInteger("pool_generation_number", 0); 450 dict->SetInteger("pool_generation_number", 0);
452 return dict.Pass(); 451 return dict;
453 } 452 }
454 453
455 TimeDelta WebSocketTransportClientSocketPool::ConnectionTimeout() const { 454 TimeDelta WebSocketTransportClientSocketPool::ConnectionTimeout() const {
456 return TimeDelta::FromSeconds(kTransportConnectJobTimeoutInSeconds); 455 return TimeDelta::FromSeconds(kTransportConnectJobTimeoutInSeconds);
457 } 456 }
458 457
459 bool WebSocketTransportClientSocketPool::IsStalled() const { 458 bool WebSocketTransportClientSocketPool::IsStalled() const {
460 return !stalled_request_queue_.empty(); 459 return !stalled_request_queue_.empty();
461 } 460 }
462 461
(...skipping 13 matching lines...) Expand all
476 BoundNetLog request_net_log = job->request_net_log(); 475 BoundNetLog request_net_log = job->request_net_log();
477 CompletionCallback callback = job->callback(); 476 CompletionCallback callback = job->callback();
478 LoadTimingInfo::ConnectTiming connect_timing = job->connect_timing(); 477 LoadTimingInfo::ConnectTiming connect_timing = job->connect_timing();
479 478
480 ClientSocketHandle* const handle = job->handle(); 479 ClientSocketHandle* const handle = job->handle();
481 bool handed_out_socket = false; 480 bool handed_out_socket = false;
482 481
483 if (result == OK) { 482 if (result == OK) {
484 DCHECK(socket.get()); 483 DCHECK(socket.get());
485 handed_out_socket = true; 484 handed_out_socket = true;
486 HandOutSocket(socket.Pass(), connect_timing, handle, request_net_log); 485 HandOutSocket(std::move(socket), connect_timing, handle, request_net_log);
487 request_net_log.EndEvent(NetLog::TYPE_SOCKET_POOL); 486 request_net_log.EndEvent(NetLog::TYPE_SOCKET_POOL);
488 } else { 487 } else {
489 // If we got a socket, it must contain error information so pass that 488 // If we got a socket, it must contain error information so pass that
490 // up so that the caller can retrieve it. 489 // up so that the caller can retrieve it.
491 job->GetAdditionalErrorState(handle); 490 job->GetAdditionalErrorState(handle);
492 if (socket.get()) { 491 if (socket.get()) {
493 handed_out_socket = true; 492 handed_out_socket = true;
494 HandOutSocket(socket.Pass(), connect_timing, handle, request_net_log); 493 HandOutSocket(std::move(socket), connect_timing, handle, request_net_log);
495 } 494 }
496 request_net_log.EndEventWithNetErrorCode(NetLog::TYPE_SOCKET_POOL, result); 495 request_net_log.EndEventWithNetErrorCode(NetLog::TYPE_SOCKET_POOL, result);
497 } 496 }
498 bool delete_succeeded = DeleteJob(handle); 497 bool delete_succeeded = DeleteJob(handle);
499 DCHECK(delete_succeeded); 498 DCHECK(delete_succeeded);
500 if (!handed_out_socket && !stalled_request_queue_.empty() && 499 if (!handed_out_socket && !stalled_request_queue_.empty() &&
501 !ReachedMaxSocketsLimit()) 500 !ReachedMaxSocketsLimit())
502 ActivateStalledRequest(); 501 ActivateStalledRequest();
503 InvokeUserCallbackLater(handle, callback, result); 502 InvokeUserCallbackLater(handle, callback, result);
504 } 503 }
(...skipping 23 matching lines...) Expand all
528 base::checked_cast<int>(pending_connects_.size()) >= 527 base::checked_cast<int>(pending_connects_.size()) >=
529 max_sockets_ - handed_out_socket_count_; 528 max_sockets_ - handed_out_socket_count_;
530 } 529 }
531 530
532 void WebSocketTransportClientSocketPool::HandOutSocket( 531 void WebSocketTransportClientSocketPool::HandOutSocket(
533 scoped_ptr<StreamSocket> socket, 532 scoped_ptr<StreamSocket> socket,
534 const LoadTimingInfo::ConnectTiming& connect_timing, 533 const LoadTimingInfo::ConnectTiming& connect_timing,
535 ClientSocketHandle* handle, 534 ClientSocketHandle* handle,
536 const BoundNetLog& net_log) { 535 const BoundNetLog& net_log) {
537 DCHECK(socket); 536 DCHECK(socket);
538 handle->SetSocket(socket.Pass()); 537 handle->SetSocket(std::move(socket));
539 DCHECK_EQ(ClientSocketHandle::UNUSED, handle->reuse_type()); 538 DCHECK_EQ(ClientSocketHandle::UNUSED, handle->reuse_type());
540 DCHECK_EQ(0, handle->idle_time().InMicroseconds()); 539 DCHECK_EQ(0, handle->idle_time().InMicroseconds());
541 handle->set_pool_id(0); 540 handle->set_pool_id(0);
542 handle->set_connect_timing(connect_timing); 541 handle->set_connect_timing(connect_timing);
543 542
544 net_log.AddEvent( 543 net_log.AddEvent(
545 NetLog::TYPE_SOCKET_POOL_BOUND_TO_SOCKET, 544 NetLog::TYPE_SOCKET_POOL_BOUND_TO_SOCKET,
546 handle->socket()->NetLog().source().ToEventParametersCallback()); 545 handle->socket()->NetLog().source().ToEventParametersCallback());
547 546
548 ++handed_out_socket_count_; 547 ++handed_out_socket_count_;
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
635 const BoundNetLog& net_log) 634 const BoundNetLog& net_log)
636 : params(params), 635 : params(params),
637 priority(priority), 636 priority(priority),
638 handle(handle), 637 handle(handle),
639 callback(callback), 638 callback(callback),
640 net_log(net_log) {} 639 net_log(net_log) {}
641 640
642 WebSocketTransportClientSocketPool::StalledRequest::~StalledRequest() {} 641 WebSocketTransportClientSocketPool::StalledRequest::~StalledRequest() {}
643 642
644 } // namespace net 643 } // namespace net
OLDNEW
« no previous file with comments | « net/socket/unix_domain_server_socket_posix.cc ('k') | net/socket/websocket_transport_connect_sub_job.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698