OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 "google_apis/gcm/engine/connection_factory_impl.h" | 5 #include "google_apis/gcm/engine/connection_factory_impl.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/location.h" | 9 #include "base/location.h" |
10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 net::HttpNetworkSession* gcm_network_session, | 54 net::HttpNetworkSession* gcm_network_session, |
55 net::HttpNetworkSession* http_network_session, | 55 net::HttpNetworkSession* http_network_session, |
56 net::NetLog* net_log, | 56 net::NetLog* net_log, |
57 GCMStatsRecorder* recorder) | 57 GCMStatsRecorder* recorder) |
58 : mcs_endpoints_(mcs_endpoints), | 58 : mcs_endpoints_(mcs_endpoints), |
59 next_endpoint_(0), | 59 next_endpoint_(0), |
60 last_successful_endpoint_(0), | 60 last_successful_endpoint_(0), |
61 backoff_policy_(backoff_policy), | 61 backoff_policy_(backoff_policy), |
62 gcm_network_session_(gcm_network_session), | 62 gcm_network_session_(gcm_network_session), |
63 http_network_session_(http_network_session), | 63 http_network_session_(http_network_session), |
64 bound_net_log_( | 64 net_log_( |
65 net::BoundNetLog::Make(net_log, net::NetLogSourceType::SOCKET)), | 65 net::NetLogWithSource::Make(net_log, net::NetLogSourceType::SOCKET)), |
66 pac_request_(NULL), | 66 pac_request_(NULL), |
67 connecting_(false), | 67 connecting_(false), |
68 waiting_for_backoff_(false), | 68 waiting_for_backoff_(false), |
69 waiting_for_network_online_(false), | 69 waiting_for_network_online_(false), |
70 logging_in_(false), | 70 logging_in_(false), |
71 recorder_(recorder), | 71 recorder_(recorder), |
72 listener_(NULL), | 72 listener_(NULL), |
73 weak_ptr_factory_(this) { | 73 weak_ptr_factory_(this) { |
74 DCHECK_GE(mcs_endpoints_.size(), 1U); | 74 DCHECK_GE(mcs_endpoints_.size(), 1U); |
75 DCHECK(!http_network_session_ || | 75 DCHECK(!http_network_session_ || |
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
309 recorder_->RecordConnectionInitiated(current_endpoint.host()); | 309 recorder_->RecordConnectionInitiated(current_endpoint.host()); |
310 RebuildNetworkSessionAuthCache(); | 310 RebuildNetworkSessionAuthCache(); |
311 int status = gcm_network_session_->proxy_service()->ResolveProxy( | 311 int status = gcm_network_session_->proxy_service()->ResolveProxy( |
312 current_endpoint, | 312 current_endpoint, |
313 std::string(), | 313 std::string(), |
314 &proxy_info_, | 314 &proxy_info_, |
315 base::Bind(&ConnectionFactoryImpl::OnProxyResolveDone, | 315 base::Bind(&ConnectionFactoryImpl::OnProxyResolveDone, |
316 weak_ptr_factory_.GetWeakPtr()), | 316 weak_ptr_factory_.GetWeakPtr()), |
317 &pac_request_, | 317 &pac_request_, |
318 NULL, | 318 NULL, |
319 bound_net_log_); | 319 net_log_); |
320 if (status != net::ERR_IO_PENDING) | 320 if (status != net::ERR_IO_PENDING) |
321 OnProxyResolveDone(status); | 321 OnProxyResolveDone(status); |
322 } | 322 } |
323 | 323 |
324 void ConnectionFactoryImpl::InitHandler() { | 324 void ConnectionFactoryImpl::InitHandler() { |
325 // May be null in tests. | 325 // May be null in tests. |
326 mcs_proto::LoginRequest login_request; | 326 mcs_proto::LoginRequest login_request; |
327 if (!request_builder_.is_null()) { | 327 if (!request_builder_.is_null()) { |
328 request_builder_.Run(&login_request); | 328 request_builder_.Run(&login_request); |
329 DCHECK(login_request.IsInitialized()); | 329 DCHECK(login_request.IsInitialized()); |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
456 | 456 |
457 net::SSLConfig ssl_config; | 457 net::SSLConfig ssl_config; |
458 gcm_network_session_->ssl_config_service()->GetSSLConfig(&ssl_config); | 458 gcm_network_session_->ssl_config_service()->GetSSLConfig(&ssl_config); |
459 status = net::InitSocketHandleForTlsConnect( | 459 status = net::InitSocketHandleForTlsConnect( |
460 net::HostPortPair::FromURL(GetCurrentEndpoint()), | 460 net::HostPortPair::FromURL(GetCurrentEndpoint()), |
461 gcm_network_session_, | 461 gcm_network_session_, |
462 proxy_info_, | 462 proxy_info_, |
463 ssl_config, | 463 ssl_config, |
464 ssl_config, | 464 ssl_config, |
465 net::PRIVACY_MODE_DISABLED, | 465 net::PRIVACY_MODE_DISABLED, |
466 bound_net_log_, | 466 net_log_, |
467 &socket_handle_, | 467 &socket_handle_, |
468 base::Bind(&ConnectionFactoryImpl::OnConnectDone, | 468 base::Bind(&ConnectionFactoryImpl::OnConnectDone, |
469 weak_ptr_factory_.GetWeakPtr())); | 469 weak_ptr_factory_.GetWeakPtr())); |
470 if (status != net::ERR_IO_PENDING) | 470 if (status != net::ERR_IO_PENDING) |
471 OnConnectDone(status); | 471 OnConnectDone(status); |
472 } | 472 } |
473 | 473 |
474 // This has largely been copied from | 474 // This has largely been copied from |
475 // HttpStreamFactoryImpl::Job::ReconsiderProxyAfterError. This should be | 475 // HttpStreamFactoryImpl::Job::ReconsiderProxyAfterError. This should be |
476 // refactored into some common place. | 476 // refactored into some common place. |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
527 gcm_network_session_->ssl_config_service()->GetSSLConfig(&ssl_config); | 527 gcm_network_session_->ssl_config_service()->GetSSLConfig(&ssl_config); |
528 if (proxy_info_.is_https() && ssl_config.send_client_cert) { | 528 if (proxy_info_.is_https() && ssl_config.send_client_cert) { |
529 gcm_network_session_->ssl_client_auth_cache()->Remove( | 529 gcm_network_session_->ssl_client_auth_cache()->Remove( |
530 proxy_info_.proxy_server().host_port_pair()); | 530 proxy_info_.proxy_server().host_port_pair()); |
531 } | 531 } |
532 | 532 |
533 int status = gcm_network_session_->proxy_service()->ReconsiderProxyAfterError( | 533 int status = gcm_network_session_->proxy_service()->ReconsiderProxyAfterError( |
534 GetCurrentEndpoint(), std::string(), error, &proxy_info_, | 534 GetCurrentEndpoint(), std::string(), error, &proxy_info_, |
535 base::Bind(&ConnectionFactoryImpl::OnProxyResolveDone, | 535 base::Bind(&ConnectionFactoryImpl::OnProxyResolveDone, |
536 weak_ptr_factory_.GetWeakPtr()), | 536 weak_ptr_factory_.GetWeakPtr()), |
537 &pac_request_, NULL, bound_net_log_); | 537 &pac_request_, NULL, net_log_); |
538 if (status == net::OK || status == net::ERR_IO_PENDING) { | 538 if (status == net::OK || status == net::ERR_IO_PENDING) { |
539 CloseSocket(); | 539 CloseSocket(); |
540 } else { | 540 } else { |
541 // If ReconsiderProxyAfterError() failed synchronously, it means | 541 // If ReconsiderProxyAfterError() failed synchronously, it means |
542 // there was nothing left to fall-back to, so fail the transaction | 542 // there was nothing left to fall-back to, so fail the transaction |
543 // with the last connection error we got. | 543 // with the last connection error we got. |
544 status = error; | 544 status = error; |
545 } | 545 } |
546 | 546 |
547 // If there is new proxy info, post OnProxyResolveDone to retry it. Otherwise, | 547 // If there is new proxy info, post OnProxyResolveDone to retry it. Otherwise, |
(...skipping 26 matching lines...) Expand all Loading... |
574 | 574 |
575 void ConnectionFactoryImpl::RebuildNetworkSessionAuthCache() { | 575 void ConnectionFactoryImpl::RebuildNetworkSessionAuthCache() { |
576 if (!http_network_session_ || !http_network_session_->http_auth_cache()) | 576 if (!http_network_session_ || !http_network_session_->http_auth_cache()) |
577 return; | 577 return; |
578 | 578 |
579 gcm_network_session_->http_auth_cache()->UpdateAllFrom( | 579 gcm_network_session_->http_auth_cache()->UpdateAllFrom( |
580 *http_network_session_->http_auth_cache()); | 580 *http_network_session_->http_auth_cache()); |
581 } | 581 } |
582 | 582 |
583 } // namespace gcm | 583 } // namespace gcm |
OLD | NEW |