blob: 8d97b1c9720f27b0bb7f3757ee823d4f15b8d458 [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"
namespace content {
BrowserOnlineStateObserver::BrowserOnlineStateObserver() {
net::NetworkChangeNotifier::AddConnectionTypeObserver(this);
}
BrowserOnlineStateObserver::~BrowserOnlineStateObserver() {
net::NetworkChangeNotifier::RemoveConnectionTypeObserver(this);
}
void BrowserOnlineStateObserver::OnConnectionTypeChanged(
net::NetworkChangeNotifier::ConnectionType type) {
bool is_online = !net::NetworkChangeNotifier::IsOffline();
for (RenderProcessHost::iterator it(RenderProcessHost::AllHostsIterator());
!it.IsAtEnd(); it.Advance()) {
it.GetCurrentValue()->Send(
new ViewMsg_NetworkStateChanged(is_online, type));
}
}
} // namespace content