summaryrefslogtreecommitdiffstats
path: root/dom/media/systemservices/DeviceChangeCallback.h
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commit5f8de423f190bbb79a62f804151bc24824fa32d8 (patch)
tree10027f336435511475e392454359edea8e25895d /dom/media/systemservices/DeviceChangeCallback.h
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloadUXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip
Add m-esr52 at 52.6.0
Diffstat (limited to 'dom/media/systemservices/DeviceChangeCallback.h')
-rw-r--r--dom/media/systemservices/DeviceChangeCallback.h61
1 files changed, 61 insertions, 0 deletions
diff --git a/dom/media/systemservices/DeviceChangeCallback.h b/dom/media/systemservices/DeviceChangeCallback.h
new file mode 100644
index 000000000..d153e9cd4
--- /dev/null
+++ b/dom/media/systemservices/DeviceChangeCallback.h
@@ -0,0 +1,61 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set sw=2 ts=8 et ft=cpp : */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this file,
+ * You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#ifndef mozilla_DeviceChangeCallback_h
+#define mozilla_DeviceChangeCallback_h
+
+namespace mozilla {
+
+class DeviceChangeCallback
+{
+public:
+ virtual void OnDeviceChange()
+ {
+ MutexAutoLock lock(mCallbackMutex);
+ for (DeviceChangeCallback* observer : mDeviceChangeCallbackList)
+ {
+ observer->OnDeviceChange();
+ }
+ }
+
+ virtual int AddDeviceChangeCallback(DeviceChangeCallback* aCallback)
+ {
+ MutexAutoLock lock(mCallbackMutex);
+ if (mDeviceChangeCallbackList.IndexOf(aCallback) == mDeviceChangeCallbackList.NoIndex)
+ mDeviceChangeCallbackList.AppendElement(aCallback);
+ return 0;
+ }
+
+ virtual int RemoveDeviceChangeCallback(DeviceChangeCallback* aCallback)
+ {
+ MutexAutoLock lock(mCallbackMutex);
+ return RemoveDeviceChangeCallbackLocked(aCallback);
+ }
+
+ virtual int RemoveDeviceChangeCallbackLocked(DeviceChangeCallback* aCallback)
+ {
+ mCallbackMutex.AssertCurrentThreadOwns();
+ if (mDeviceChangeCallbackList.IndexOf(aCallback) != mDeviceChangeCallbackList.NoIndex)
+ mDeviceChangeCallbackList.RemoveElement(aCallback);
+ return 0;
+ }
+
+ DeviceChangeCallback() : mCallbackMutex("mozilla::media::DeviceChangeCallback::mCallbackMutex")
+ {
+ }
+
+ virtual ~DeviceChangeCallback()
+ {
+ }
+
+protected:
+ nsTArray<DeviceChangeCallback*> mDeviceChangeCallbackList;
+ Mutex mCallbackMutex;
+};
+
+} // namespace mozilla
+
+#endif // mozilla_DeviceChangeCallback_h