Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(6266)

Unified Diff: chrome/browser/extensions/api/dial/dial_registry.cc

Issue 11444020: DIAL extension API skeleton. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: abc.... Created 8 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/extensions/api/dial/dial_registry.h ('k') | chrome/browser/extensions/event_names.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/extensions/api/dial/dial_registry.cc
diff --git a/chrome/browser/extensions/api/dial/dial_registry.cc b/chrome/browser/extensions/api/dial/dial_registry.cc
new file mode 100644
index 0000000000000000000000000000000000000000..0b064a280e72dcc77e1076525866391edb234175
--- /dev/null
+++ b/chrome/browser/extensions/api/dial/dial_registry.cc
@@ -0,0 +1,41 @@
+// 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 "chrome/browser/extensions/api/dial/dial_registry.h"
+
+#include "chrome/browser/extensions/api/dial/dial_api.h"
+#include "chrome/browser/extensions/api/dial/dial_device_data.h"
+#include "chrome/common/extensions/api/dial.h"
+
+namespace extensions {
+
+DialRegistry::DialRegistry(Observer* dial_api)
+ : num_listeners_(0), discovering_(false), dial_api_(dial_api) { }
+
+DialRegistry::~DialRegistry() {
+ DCHECK(thread_checker_.CalledOnValidThread());
+}
+
+void DialRegistry::OnListenerAdded() {
+ DCHECK(thread_checker_.CalledOnValidThread());
+ if (++num_listeners_ == 1) {
+ DVLOG(1) << "Listener added; starting periodic discovery.";
+ discovering_ = true;
+ }
+}
+
+void DialRegistry::OnListenerRemoved() {
+ DCHECK(thread_checker_.CalledOnValidThread());
+ if (--num_listeners_ == 0) {
+ DVLOG(1) << "Listeners removed; stopping periodic discovery.";
+ discovering_ = false;
+ }
+}
+
+bool DialRegistry::DiscoverNow() {
+ DCHECK(thread_checker_.CalledOnValidThread());
+ return discovering_;
+}
+
+} // namespace extensions
« no previous file with comments | « chrome/browser/extensions/api/dial/dial_registry.h ('k') | chrome/browser/extensions/event_names.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698