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

Side by Side Diff: chrome/browser/chromeos/net/network_portal_detector_impl.cc

Issue 2033753002: Remove use of deprecated MessageLoop methods in chrome/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: manual change Created 4 years, 6 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 "chrome/browser/chromeos/net/network_portal_detector_impl.h" 5 #include "chrome/browser/chromeos/net/network_portal_detector_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
11 #include "base/location.h"
11 #include "base/logging.h" 12 #include "base/logging.h"
12 #include "base/message_loop/message_loop.h"
13 #include "base/metrics/histogram.h" 13 #include "base/metrics/histogram.h"
14 #include "base/single_thread_task_runner.h"
14 #include "base/strings/stringprintf.h" 15 #include "base/strings/stringprintf.h"
16 #include "base/threading/thread_task_runner_handle.h"
15 #include "chrome/browser/chrome_notification_types.h" 17 #include "chrome/browser/chrome_notification_types.h"
16 #include "chrome/browser/chromeos/net/network_portal_notification_controller.h" 18 #include "chrome/browser/chromeos/net/network_portal_notification_controller.h"
17 #include "chromeos/dbus/dbus_thread_manager.h" 19 #include "chromeos/dbus/dbus_thread_manager.h"
18 #include "chromeos/dbus/shill_profile_client.h" 20 #include "chromeos/dbus/shill_profile_client.h"
19 #include "chromeos/login/login_state.h" 21 #include "chromeos/login/login_state.h"
20 #include "chromeos/network/network_state.h" 22 #include "chromeos/network/network_state.h"
21 #include "chromeos/network/network_state_handler.h" 23 #include "chromeos/network/network_state_handler.h"
22 #include "components/device_event_log/device_event_log.h" 24 #include "components/device_event_log/device_event_log.h"
23 #include "content/public/browser/notification_service.h" 25 #include "content/public/browser/notification_service.h"
24 #include "content/public/common/content_switches.h" 26 #include "content/public/common/content_switches.h"
(...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after
423 if (!IsEnabled()) 425 if (!IsEnabled())
424 return; 426 return;
425 427
426 attempt_task_.Cancel(); 428 attempt_task_.Cancel();
427 attempt_timeout_.Cancel(); 429 attempt_timeout_.Cancel();
428 state_ = STATE_PORTAL_CHECK_PENDING; 430 state_ = STATE_PORTAL_CHECK_PENDING;
429 431
430 next_attempt_delay_ = std::max(delay, strategy_->GetDelayTillNextAttempt()); 432 next_attempt_delay_ = std::max(delay, strategy_->GetDelayTillNextAttempt());
431 attempt_task_.Reset(base::Bind(&NetworkPortalDetectorImpl::StartAttempt, 433 attempt_task_.Reset(base::Bind(&NetworkPortalDetectorImpl::StartAttempt,
432 weak_factory_.GetWeakPtr())); 434 weak_factory_.GetWeakPtr()));
433 base::MessageLoop::current()->PostDelayedTask( 435 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
434 FROM_HERE, attempt_task_.callback(), next_attempt_delay_); 436 FROM_HERE, attempt_task_.callback(), next_attempt_delay_);
435 } 437 }
436 438
437 void NetworkPortalDetectorImpl::StartAttempt() { 439 void NetworkPortalDetectorImpl::StartAttempt() {
438 DCHECK(is_portal_check_pending()); 440 DCHECK(is_portal_check_pending());
439 DCHECK(portal_test_url_.is_valid()); 441 DCHECK(portal_test_url_.is_valid());
440 442
441 state_ = STATE_CHECKING_FOR_PORTAL; 443 state_ = STATE_CHECKING_FOR_PORTAL;
442 attempt_start_time_ = NowTicks(); 444 attempt_start_time_ = NowTicks();
443 445
444 captive_portal_detector_->DetectCaptivePortal( 446 captive_portal_detector_->DetectCaptivePortal(
445 portal_test_url_, 447 portal_test_url_,
446 base::Bind(&NetworkPortalDetectorImpl::OnAttemptCompleted, 448 base::Bind(&NetworkPortalDetectorImpl::OnAttemptCompleted,
447 weak_factory_.GetWeakPtr())); 449 weak_factory_.GetWeakPtr()));
448 attempt_timeout_.Reset( 450 attempt_timeout_.Reset(
449 base::Bind(&NetworkPortalDetectorImpl::OnAttemptTimeout, 451 base::Bind(&NetworkPortalDetectorImpl::OnAttemptTimeout,
450 weak_factory_.GetWeakPtr())); 452 weak_factory_.GetWeakPtr()));
451 453
452 base::MessageLoop::current()->PostDelayedTask( 454 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
453 FROM_HERE, 455 FROM_HERE, attempt_timeout_.callback(),
454 attempt_timeout_.callback(),
455 strategy_->GetNextAttemptTimeout()); 456 strategy_->GetNextAttemptTimeout());
456 } 457 }
457 458
458 void NetworkPortalDetectorImpl::OnAttemptTimeout() { 459 void NetworkPortalDetectorImpl::OnAttemptTimeout() {
459 DCHECK(CalledOnValidThread()); 460 DCHECK(CalledOnValidThread());
460 DCHECK(is_checking_for_portal()); 461 DCHECK(is_checking_for_portal());
461 462
462 NET_LOG(ERROR) << "Portal detection timeout: " 463 NET_LOG(ERROR) << "Portal detection timeout: "
463 << " name=" << default_network_name_ 464 << " name=" << default_network_name_
464 << " id=" << default_network_id_; 465 << " id=" << default_network_id_;
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
641 } 642 }
642 643
643 void NetworkPortalDetectorImpl::ResetStrategyAndCounters() { 644 void NetworkPortalDetectorImpl::ResetStrategyAndCounters() {
644 last_detection_result_ = CAPTIVE_PORTAL_STATUS_UNKNOWN; 645 last_detection_result_ = CAPTIVE_PORTAL_STATUS_UNKNOWN;
645 same_detection_result_count_ = 0; 646 same_detection_result_count_ = 0;
646 no_response_result_count_ = 0; 647 no_response_result_count_ = 0;
647 strategy_->Reset(); 648 strategy_->Reset();
648 } 649 }
649 650
650 } // namespace chromeos 651 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698