summaryrefslogtreecommitdiffstats
path: root/ppapi/cpp/extensions/event_base.cc
diff options
context:
space:
mode:
authoryzshen@chromium.org <yzshen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-03-12 17:50:15 +0000
committeryzshen@chromium.org <yzshen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-03-12 17:50:15 +0000
commit470020d2a3558be5acd4b74c29f0df38c9d9edd6 (patch)
tree8e172ee53536cdf024b8873fe7bc6b0c196c1667 /ppapi/cpp/extensions/event_base.cc
parent34ee051a834b135745ab07374f838cc7381d908e (diff)
downloadchromium_src-470020d2a3558be5acd4b74c29f0df38c9d9edd6.zip
chromium_src-470020d2a3558be5acd4b74c29f0df38c9d9edd6.tar.gz
chromium_src-470020d2a3558be5acd4b74c29f0df38c9d9edd6.tar.bz2
Reland: Add C/C++ interfaces for PPB_Ext_Alarms_Dev and PPB_Ext_Events_Dev.
This CL also adds necessary C++ utilities to support these interfaces. An example of using these APIs: https://codereview.chromium.org/12387051/ BUG=None TEST=None The original CL is here: https://codereview.chromium.org/12295043/ Review URL: https://codereview.chromium.org/12755016 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@187610 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi/cpp/extensions/event_base.cc')
-rw-r--r--ppapi/cpp/extensions/event_base.cc44
1 files changed, 44 insertions, 0 deletions
diff --git a/ppapi/cpp/extensions/event_base.cc b/ppapi/cpp/extensions/event_base.cc
new file mode 100644
index 0000000..210b213
--- /dev/null
+++ b/ppapi/cpp/extensions/event_base.cc
@@ -0,0 +1,44 @@
+// Copyright (c) 2013 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 "ppapi/cpp/extensions/event_base.h"
+
+#include "ppapi/cpp/extensions/dev/events_dev.h"
+
+namespace pp {
+namespace ext {
+namespace internal {
+
+GenericEventBase::GenericEventBase(
+ const InstanceHandle& instance,
+ const PP_Ext_EventListener& pp_listener)
+ : instance_(instance),
+ listener_id_(0),
+ pp_listener_(pp_listener) {
+}
+
+GenericEventBase::~GenericEventBase() {
+ StopListening();
+}
+
+bool GenericEventBase::StartListening() {
+ if (IsListening())
+ return true;
+
+ listener_id_ = events::Events_Dev::AddListener(instance_.pp_instance(),
+ pp_listener_);
+ return IsListening();
+}
+
+void GenericEventBase::StopListening() {
+ if (!IsListening())
+ return;
+
+ events::Events_Dev::RemoveListener(instance_.pp_instance(), listener_id_);
+ listener_id_ = 0;
+}
+
+} // namespace internal
+} // namespace ext
+} // namespace pp