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

Side by Side Diff: google_apis/gcm/engine/connection_factory_impl.cc

Issue 1232193002: Replace MessageLoop::current() with ThreadTaskRunnerHandle::Get() in GCM (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 5 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 (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 "base/message_loop/message_loop.h" 7 #include "base/location.h"
8 #include "base/metrics/histogram.h" 8 #include "base/metrics/histogram.h"
9 #include "base/metrics/sparse_histogram.h" 9 #include "base/metrics/sparse_histogram.h"
10 #include "base/profiler/scoped_tracker.h" 10 #include "base/profiler/scoped_tracker.h"
11 #include "base/thread_task_runner_handle.h"
11 #include "google_apis/gcm/engine/connection_handler_impl.h" 12 #include "google_apis/gcm/engine/connection_handler_impl.h"
12 #include "google_apis/gcm/monitoring/gcm_stats_recorder.h" 13 #include "google_apis/gcm/monitoring/gcm_stats_recorder.h"
13 #include "google_apis/gcm/protocol/mcs.pb.h" 14 #include "google_apis/gcm/protocol/mcs.pb.h"
14 #include "net/base/load_flags.h" 15 #include "net/base/load_flags.h"
15 #include "net/base/net_errors.h" 16 #include "net/base/net_errors.h"
16 #include "net/http/http_network_session.h" 17 #include "net/http/http_network_session.h"
17 #include "net/http/http_request_headers.h" 18 #include "net/http/http_request_headers.h"
18 #include "net/proxy/proxy_info.h" 19 #include "net/proxy/proxy_info.h"
19 #include "net/socket/client_socket_handle.h" 20 #include "net/socket/client_socket_handle.h"
20 #include "net/socket/client_socket_pool_manager.h" 21 #include "net/socket/client_socket_pool_manager.h"
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 return; 130 return;
130 } 131 }
131 132
132 if (backoff_entry_->ShouldRejectRequest()) { 133 if (backoff_entry_->ShouldRejectRequest()) {
133 DVLOG(1) << "Delaying MCS endpoint connection for " 134 DVLOG(1) << "Delaying MCS endpoint connection for "
134 << backoff_entry_->GetTimeUntilRelease().InMilliseconds() 135 << backoff_entry_->GetTimeUntilRelease().InMilliseconds()
135 << " milliseconds."; 136 << " milliseconds.";
136 waiting_for_backoff_ = true; 137 waiting_for_backoff_ = true;
137 recorder_->RecordConnectionDelayedDueToBackoff( 138 recorder_->RecordConnectionDelayedDueToBackoff(
138 backoff_entry_->GetTimeUntilRelease().InMilliseconds()); 139 backoff_entry_->GetTimeUntilRelease().InMilliseconds());
139 base::MessageLoop::current()->PostDelayedTask( 140 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
140 FROM_HERE, 141 FROM_HERE,
141 base::Bind(&ConnectionFactoryImpl::ConnectWithBackoff, 142 base::Bind(&ConnectionFactoryImpl::ConnectWithBackoff,
142 weak_ptr_factory_.GetWeakPtr()), 143 weak_ptr_factory_.GetWeakPtr()),
143 backoff_entry_->GetTimeUntilRelease()); 144 backoff_entry_->GetTimeUntilRelease());
144 return; 145 return;
145 } 146 }
146 147
147 DVLOG(1) << "Attempting connection to MCS endpoint."; 148 DVLOG(1) << "Attempting connection to MCS endpoint.";
148 waiting_for_backoff_ = false; 149 waiting_for_backoff_ = false;
149 // It's necessary to close the socket before attempting any new connection, 150 // It's necessary to close the socket before attempting any new connection,
(...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after
540 } else { 541 } else {
541 // If ReconsiderProxyAfterError() failed synchronously, it means 542 // If ReconsiderProxyAfterError() failed synchronously, it means
542 // there was nothing left to fall-back to, so fail the transaction 543 // there was nothing left to fall-back to, so fail the transaction
543 // with the last connection error we got. 544 // with the last connection error we got.
544 status = error; 545 status = error;
545 } 546 }
546 547
547 // If there is new proxy info, post OnProxyResolveDone to retry it. Otherwise, 548 // If there is new proxy info, post OnProxyResolveDone to retry it. Otherwise,
548 // if there was an error falling back, fail synchronously. 549 // if there was an error falling back, fail synchronously.
549 if (status == net::OK) { 550 if (status == net::OK) {
550 base::MessageLoop::current()->PostTask( 551 base::ThreadTaskRunnerHandle::Get()->PostTask(
551 FROM_HERE, 552 FROM_HERE,
552 base::Bind(&ConnectionFactoryImpl::OnProxyResolveDone, 553 base::Bind(&ConnectionFactoryImpl::OnProxyResolveDone,
553 weak_ptr_factory_.GetWeakPtr(), status)); 554 weak_ptr_factory_.GetWeakPtr(), status));
554 status = net::ERR_IO_PENDING; 555 status = net::ERR_IO_PENDING;
555 } 556 }
556 return status; 557 return status;
557 } 558 }
558 559
559 void ConnectionFactoryImpl::ReportSuccessfulProxyConnection() { 560 void ConnectionFactoryImpl::ReportSuccessfulProxyConnection() {
560 if (gcm_network_session_.get() && gcm_network_session_->proxy_service()) 561 if (gcm_network_session_.get() && gcm_network_session_->proxy_service())
(...skipping 13 matching lines...) Expand all
574 575
575 void ConnectionFactoryImpl::RebuildNetworkSessionAuthCache() { 576 void ConnectionFactoryImpl::RebuildNetworkSessionAuthCache() {
576 if (!http_network_session_.get() || !http_network_session_->http_auth_cache()) 577 if (!http_network_session_.get() || !http_network_session_->http_auth_cache())
577 return; 578 return;
578 579
579 gcm_network_session_->http_auth_cache()->UpdateAllFrom( 580 gcm_network_session_->http_auth_cache()->UpdateAllFrom(
580 *http_network_session_->http_auth_cache()); 581 *http_network_session_->http_auth_cache());
581 } 582 }
582 583
583 } // namespace gcm 584 } // namespace gcm
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698