Roll src/third_party/WebKit d9c6159:8139f33 (svn 201974:201975)
[chromium-blink-merge.git] / chromecast / net / connectivity_checker.cc
blob873ab1e1a5789bfbc45a0ebcfad72a899a7d0671
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "chromecast/net/connectivity_checker.h"
7 #include "chromecast/net/connectivity_checker_impl.h"
9 namespace chromecast {
11 ConnectivityChecker::ConnectivityChecker()
12 : connectivity_observer_list_(
13 new base::ObserverListThreadSafe<ConnectivityObserver>()) {
16 ConnectivityChecker::~ConnectivityChecker() {
19 void ConnectivityChecker::AddConnectivityObserver(
20 ConnectivityObserver* observer) {
21 connectivity_observer_list_->AddObserver(observer);
24 void ConnectivityChecker::RemoveConnectivityObserver(
25 ConnectivityObserver* observer) {
26 connectivity_observer_list_->RemoveObserver(observer);
29 void ConnectivityChecker::Notify(bool connected) {
30 DCHECK(connectivity_observer_list_.get());
31 connectivity_observer_list_->Notify(
32 FROM_HERE, &ConnectivityObserver::OnConnectivityChanged, connected);
35 // static
36 scoped_refptr<ConnectivityChecker> ConnectivityChecker::Create(
37 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner) {
38 return make_scoped_refptr(new ConnectivityCheckerImpl(task_runner));
41 } // namespace chromecast