summaryrefslogtreecommitdiffstats
path: root/chromecast/net/connectivity_checker.cc
blob: 873ab1e1a5789bfbc45a0ebcfad72a899a7d0671 (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
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
// Copyright 2015 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 "chromecast/net/connectivity_checker.h"

#include "chromecast/net/connectivity_checker_impl.h"

namespace chromecast {

ConnectivityChecker::ConnectivityChecker()
    : connectivity_observer_list_(
          new base::ObserverListThreadSafe<ConnectivityObserver>()) {
}

ConnectivityChecker::~ConnectivityChecker() {
}

void ConnectivityChecker::AddConnectivityObserver(
    ConnectivityObserver* observer) {
  connectivity_observer_list_->AddObserver(observer);
}

void ConnectivityChecker::RemoveConnectivityObserver(
    ConnectivityObserver* observer) {
  connectivity_observer_list_->RemoveObserver(observer);
}

void ConnectivityChecker::Notify(bool connected) {
  DCHECK(connectivity_observer_list_.get());
  connectivity_observer_list_->Notify(
      FROM_HERE, &ConnectivityObserver::OnConnectivityChanged, connected);
}

// static
scoped_refptr<ConnectivityChecker> ConnectivityChecker::Create(
    const scoped_refptr<base::SingleThreadTaskRunner>& task_runner) {
  return make_scoped_refptr(new ConnectivityCheckerImpl(task_runner));
}

}  // namespace chromecast