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

Unified Diff: chromecast/net/connectivity_checker.cc

Issue 995933002: Observe IP address change in connectivity_checker. (Closed) Base URL: https://chromium.googlesource.com/chromium/src/@master
Patch Set: Observe IP address change in connectivity_checker. Created 5 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chromecast/net/connectivity_checker.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chromecast/net/connectivity_checker.cc
diff --git a/chromecast/net/connectivity_checker.cc b/chromecast/net/connectivity_checker.cc
index 0c78b5d93aafe782076b476bde524ff87ed95366..4047770007c67fd60db9162ad00aba9c332e3521 100644
--- a/chromecast/net/connectivity_checker.cc
+++ b/chromecast/net/connectivity_checker.cc
@@ -60,12 +60,15 @@ void ConnectivityChecker::Initialize() {
url_request_context_.reset(builder.Build());
net::NetworkChangeNotifier::AddConnectionTypeObserver(this);
+ net::NetworkChangeNotifier::AddIPAddressObserver(this);
loop_proxy_->PostTask(FROM_HERE,
base::Bind(&ConnectivityChecker::Check, this));
}
ConnectivityChecker::~ConnectivityChecker() {
DCHECK(loop_proxy_.get());
+ net::NetworkChangeNotifier::RemoveIPAddressObserver(this);
+ net::NetworkChangeNotifier::RemoveConnectionTypeObserver(this);
loop_proxy_->DeleteSoon(FROM_HERE, url_request_context_.release());
loop_proxy_->DeleteSoon(FROM_HERE, url_request_.release());
}
@@ -116,6 +119,7 @@ void ConnectivityChecker::Check() {
void ConnectivityChecker::OnConnectionTypeChanged(
net::NetworkChangeNotifier::ConnectionType type) {
+ VLOG(2) << "OnConnectionTypeChanged " << type;
if (type == net::NetworkChangeNotifier::CONNECTION_NONE)
SetConnectivity(false);
@@ -123,6 +127,13 @@ void ConnectivityChecker::OnConnectionTypeChanged(
Check();
}
+void ConnectivityChecker::OnIPAddressChanged() {
+ VLOG(2) << "OnIPAddressChanged";
+
+ Cancel();
+ Check();
+}
+
void ConnectivityChecker::OnResponseStarted(net::URLRequest* request) {
int http_response_code =
(request->status().is_success() &&
« no previous file with comments | « chromecast/net/connectivity_checker.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698