blob: b6ce8efb95a3320d4262e1f084f040dd110ebaf2 [file] [log] [blame]
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "content/browser/net/browser_online_state_observer.h"
#include "content/common/view_messages.h"
#include "content/browser/renderer_host/render_process_host_impl.h"
BrowserOnlineStateObserver::BrowserOnlineStateObserver() {
net::NetworkChangeNotifier::AddConnectionTypeObserver(this);
}
BrowserOnlineStateObserver::~BrowserOnlineStateObserver() {
net::NetworkChangeNotifier::RemoveConnectionTypeObserver(this);
}
void BrowserOnlineStateObserver::OnConnectionTypeChanged(
net::NetworkChangeNotifier::ConnectionType type) {
for (content::RenderProcessHost::iterator it(
content::RenderProcessHost::AllHostsIterator());
!it.IsAtEnd(); it.Advance()) {
it.GetCurrentValue()->Send(new ViewMsg_NetworkStateChanged(
type != net::NetworkChangeNotifier::CONNECTION_NONE));
}
}