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/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/memory/ptr_util.h" |
9 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
10 #include "chromecast/net/net_switches.h" | 11 #include "chromecast/net/net_switches.h" |
11 #include "net/base/request_priority.h" | 12 #include "net/base/request_priority.h" |
12 #include "net/http/http_response_headers.h" | 13 #include "net/http/http_response_headers.h" |
13 #include "net/http/http_response_info.h" | 14 #include "net/http/http_response_info.h" |
14 #include "net/http/http_status_code.h" | 15 #include "net/http/http_status_code.h" |
15 #include "net/proxy/proxy_config.h" | 16 #include "net/proxy/proxy_config.h" |
16 #include "net/proxy/proxy_config_service_fixed.h" | 17 #include "net/proxy/proxy_config_service_fixed.h" |
17 #include "net/socket/ssl_client_socket.h" | 18 #include "net/socket/ssl_client_socket.h" |
18 #include "net/url_request/url_request_context.h" | 19 #include "net/url_request/url_request_context.h" |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 } | 58 } |
58 | 59 |
59 void ConnectivityCheckerImpl::Initialize() { | 60 void ConnectivityCheckerImpl::Initialize() { |
60 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); | 61 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
61 base::CommandLine::StringType check_url_str = | 62 base::CommandLine::StringType check_url_str = |
62 command_line->GetSwitchValueNative(switches::kConnectivityCheckUrl); | 63 command_line->GetSwitchValueNative(switches::kConnectivityCheckUrl); |
63 connectivity_check_url_.reset(new GURL( | 64 connectivity_check_url_.reset(new GURL( |
64 check_url_str.empty() ? kDefaultConnectivityCheckUrl : check_url_str)); | 65 check_url_str.empty() ? kDefaultConnectivityCheckUrl : check_url_str)); |
65 | 66 |
66 net::URLRequestContextBuilder builder; | 67 net::URLRequestContextBuilder builder; |
67 builder.set_proxy_config_service(make_scoped_ptr( | 68 builder.set_proxy_config_service(base::WrapUnique( |
68 new net::ProxyConfigServiceFixed(net::ProxyConfig::CreateDirect()))); | 69 new net::ProxyConfigServiceFixed(net::ProxyConfig::CreateDirect()))); |
69 builder.DisableHttpCache(); | 70 builder.DisableHttpCache(); |
70 url_request_context_ = builder.Build(); | 71 url_request_context_ = builder.Build(); |
71 | 72 |
72 net::NetworkChangeNotifier::AddNetworkChangeObserver(this); | 73 net::NetworkChangeNotifier::AddNetworkChangeObserver(this); |
73 task_runner_->PostTask(FROM_HERE, | 74 task_runner_->PostTask(FROM_HERE, |
74 base::Bind(&ConnectivityCheckerImpl::Check, this)); | 75 base::Bind(&ConnectivityCheckerImpl::Check, this)); |
75 } | 76 } |
76 | 77 |
77 ConnectivityCheckerImpl::~ConnectivityCheckerImpl() { | 78 ConnectivityCheckerImpl::~ConnectivityCheckerImpl() { |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
212 | 213 |
213 void ConnectivityCheckerImpl::Cancel() { | 214 void ConnectivityCheckerImpl::Cancel() { |
214 if (!url_request_.get()) | 215 if (!url_request_.get()) |
215 return; | 216 return; |
216 VLOG(2) << "Cancel connectivity check in progress"; | 217 VLOG(2) << "Cancel connectivity check in progress"; |
217 url_request_.reset(nullptr); // URLRequest::Cancel() is called in destructor. | 218 url_request_.reset(nullptr); // URLRequest::Cancel() is called in destructor. |
218 timeout_.Cancel(); | 219 timeout_.Cancel(); |
219 } | 220 } |
220 | 221 |
221 } // namespace chromecast | 222 } // namespace chromecast |
OLD | NEW |