summaryrefslogtreecommitdiffstats
path: root/content/browser/net/browser_online_state_observer.cc
blob: 57f3d151714cf9d1f66b284c503652f932c6ccb5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
// Copyright (c) 2011 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::AddOnlineStateObserver(this);
}

BrowserOnlineStateObserver::~BrowserOnlineStateObserver() {
  net::NetworkChangeNotifier::RemoveOnlineStateObserver(this);
}

void BrowserOnlineStateObserver::OnOnlineStateChanged(bool online) {
  for (content::RenderProcessHost::iterator it(
          content::RenderProcessHost::AllHostsIterator());
       !it.IsAtEnd(); it.Advance()) {
    it.GetCurrentValue()->Send(new ViewMsg_NetworkStateChanged(online));
  }
}