summaryrefslogtreecommitdiffstats
path: root/dom/media/systemservices/LoadMonitor.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/LoadMonitor.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/LoadMonitor.h')
-rw-r--r--dom/media/systemservices/LoadMonitor.h61
1 files changed, 61 insertions, 0 deletions
diff --git a/dom/media/systemservices/LoadMonitor.h b/dom/media/systemservices/LoadMonitor.h
new file mode 100644
index 000000000..3731b97dc
--- /dev/null
+++ b/dom/media/systemservices/LoadMonitor.h
@@ -0,0 +1,61 @@
+/* -*- Mode: C++; tab-width: 50; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/* 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 _LOADMONITOR_H_
+#define _LOADMONITOR_H_
+
+#include "mozilla/Mutex.h"
+#include "mozilla/CondVar.h"
+#include "mozilla/RefPtr.h"
+#include "mozilla/Atomics.h"
+#include "nsCOMPtr.h"
+#include "nsIThread.h"
+#include "nsIObserver.h"
+
+namespace mozilla {
+class LoadInfoCollectRunner;
+
+class LoadNotificationCallback
+{
+public:
+ virtual void LoadChanged(float aSystemLoad, float aProcessLoad) = 0;
+};
+
+class LoadMonitor final : public nsIObserver
+{
+public:
+ NS_DECL_THREADSAFE_ISUPPORTS
+ NS_DECL_NSIOBSERVER
+
+ explicit LoadMonitor(int aLoadUpdateInterval);
+
+ nsresult Init(RefPtr<LoadMonitor> &self);
+ void SetLoadChangeCallback(LoadNotificationCallback* aCallback);
+ void Shutdown();
+ float GetSystemLoad();
+ float GetProcessLoad();
+
+ friend class LoadInfoCollectRunner;
+
+private:
+ ~LoadMonitor();
+
+ void SetProcessLoad(float load);
+ void SetSystemLoad(float load);
+ void FireCallbacks();
+
+ int mLoadUpdateInterval;
+ mozilla::Mutex mLock;
+ mozilla::CondVar mCondVar;
+ bool mShutdownPending;
+ nsCOMPtr<nsIThread> mLoadInfoThread;
+ float mSystemLoad;
+ float mProcessLoad;
+ LoadNotificationCallback* mLoadNotificationCallback;
+};
+
+} //namespace
+
+#endif /* _LOADMONITOR_H_ */