OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2012 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. |
| 4 |
| 5 #include "chrome/browser/extensions/api/dial/dial_registry.h" |
| 6 |
| 7 #include "chrome/browser/extensions/api/dial/dial_api.h" |
| 8 #include "chrome/browser/extensions/api/dial/dial_device_data.h" |
| 9 #include "chrome/common/extensions/api/dial.h" |
| 10 |
| 11 namespace extensions { |
| 12 |
| 13 DialRegistry::DialRegistry(Observer* dial_api) |
| 14 : num_listeners_(0), discovering_(false), dial_api_(dial_api) { } |
| 15 |
| 16 DialRegistry::~DialRegistry() { |
| 17 DCHECK(thread_checker_.CalledOnValidThread()); |
| 18 } |
| 19 |
| 20 void DialRegistry::OnListenerAdded() { |
| 21 DCHECK(thread_checker_.CalledOnValidThread()); |
| 22 if (++num_listeners_ == 1) { |
| 23 DVLOG(1) << "Listener added; starting periodic discovery."; |
| 24 discovering_ = true; |
| 25 } |
| 26 } |
| 27 |
| 28 void DialRegistry::OnListenerRemoved() { |
| 29 DCHECK(thread_checker_.CalledOnValidThread()); |
| 30 if (--num_listeners_ == 0) { |
| 31 DVLOG(1) << "Listeners removed; stopping periodic discovery."; |
| 32 discovering_ = false; |
| 33 } |
| 34 } |
| 35 |
| 36 bool DialRegistry::DiscoverNow() { |
| 37 DCHECK(thread_checker_.CalledOnValidThread()); |
| 38 return discovering_; |
| 39 } |
| 40 |
| 41 } // namespace extensions |
OLD | NEW |