| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "chromecast/net/connectivity_checker_impl.h" | 5 #include "chromecast/net/connectivity_checker_impl.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/location.h" | 8 #include "base/location.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 | 66 |
| 67 void ConnectivityCheckerImpl::Initialize() { | 67 void ConnectivityCheckerImpl::Initialize() { |
| 68 DCHECK(task_runner_->BelongsToCurrentThread()); | 68 DCHECK(task_runner_->BelongsToCurrentThread()); |
| 69 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); | 69 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
| 70 base::CommandLine::StringType check_url_str = | 70 base::CommandLine::StringType check_url_str = |
| 71 command_line->GetSwitchValueNative(switches::kConnectivityCheckUrl); | 71 command_line->GetSwitchValueNative(switches::kConnectivityCheckUrl); |
| 72 connectivity_check_url_.reset(new GURL( | 72 connectivity_check_url_.reset(new GURL( |
| 73 check_url_str.empty() ? kDefaultConnectivityCheckUrl : check_url_str)); | 73 check_url_str.empty() ? kDefaultConnectivityCheckUrl : check_url_str)); |
| 74 | 74 |
| 75 net::URLRequestContextBuilder builder; | 75 net::URLRequestContextBuilder builder; |
| 76 builder.set_proxy_config_service(base::WrapUnique( | 76 builder.set_proxy_config_service( |
| 77 new net::ProxyConfigServiceFixed(net::ProxyConfig::CreateDirect()))); | 77 base::MakeUnique<net::ProxyConfigServiceFixed>( |
| 78 net::ProxyConfig::CreateDirect())); |
| 78 builder.DisableHttpCache(); | 79 builder.DisableHttpCache(); |
| 79 url_request_context_ = builder.Build(); | 80 url_request_context_ = builder.Build(); |
| 80 | 81 |
| 81 net::NetworkChangeNotifier::AddNetworkChangeObserver(this); | 82 net::NetworkChangeNotifier::AddNetworkChangeObserver(this); |
| 82 task_runner_->PostTask(FROM_HERE, | 83 task_runner_->PostTask(FROM_HERE, |
| 83 base::Bind(&ConnectivityCheckerImpl::Check, this)); | 84 base::Bind(&ConnectivityCheckerImpl::Check, this)); |
| 84 } | 85 } |
| 85 | 86 |
| 86 ConnectivityCheckerImpl::~ConnectivityCheckerImpl() { | 87 ConnectivityCheckerImpl::~ConnectivityCheckerImpl() { |
| 87 DCHECK(task_runner_.get()); | 88 DCHECK(task_runner_.get()); |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 235 void ConnectivityCheckerImpl::Cancel() { | 236 void ConnectivityCheckerImpl::Cancel() { |
| 236 DCHECK(task_runner_->BelongsToCurrentThread()); | 237 DCHECK(task_runner_->BelongsToCurrentThread()); |
| 237 if (!url_request_.get()) | 238 if (!url_request_.get()) |
| 238 return; | 239 return; |
| 239 VLOG(2) << "Cancel connectivity check in progress"; | 240 VLOG(2) << "Cancel connectivity check in progress"; |
| 240 url_request_.reset(nullptr); // URLRequest::Cancel() is called in destructor. | 241 url_request_.reset(nullptr); // URLRequest::Cancel() is called in destructor. |
| 241 timeout_.Cancel(); | 242 timeout_.Cancel(); |
| 242 } | 243 } |
| 243 | 244 |
| 244 } // namespace chromecast | 245 } // namespace chromecast |
| OLD | NEW |