michael@0: /* -*- Mode: C++; tab-width: 50; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef _LOADMANAGER_H_ michael@0: #define _LOADMANAGER_H_ michael@0: michael@0: #include "LoadMonitor.h" michael@0: #include "webrtc/common_types.h" michael@0: #include "webrtc/video_engine/include/vie_base.h" michael@0: #include "mozilla/TimeStamp.h" michael@0: #include "nsTArray.h" michael@0: michael@0: extern PRLogModuleInfo *gLoadManagerLog; michael@0: michael@0: namespace mozilla { michael@0: michael@0: class LoadManager : public LoadNotificationCallback, michael@0: public webrtc::CPULoadStateCallbackInvoker, michael@0: public webrtc::CpuOveruseObserver michael@0: { michael@0: public: michael@0: LoadManager(int aLoadMeasurementInterval, michael@0: int aAveragingMeasurements, michael@0: float aHighLoadThreshold, michael@0: float aLowLoadThreshold); michael@0: ~LoadManager(); michael@0: michael@0: // LoadNotificationCallback interface michael@0: virtual void LoadChanged(float aSystemLoad, float aProcessLoad) MOZ_OVERRIDE; michael@0: // CpuOveruseObserver interface michael@0: // Called as soon as an overuse is detected. michael@0: virtual void OveruseDetected() MOZ_OVERRIDE; michael@0: // Called periodically when the system is not overused any longer. michael@0: virtual void NormalUsage() MOZ_OVERRIDE; michael@0: // CPULoadStateCallbackInvoker interface michael@0: virtual void AddObserver(webrtc::CPULoadStateObserver * aObserver) MOZ_OVERRIDE; michael@0: virtual void RemoveObserver(webrtc::CPULoadStateObserver * aObserver) MOZ_OVERRIDE; michael@0: michael@0: private: michael@0: void LoadHasChanged(); michael@0: michael@0: nsRefPtr mLoadMonitor; michael@0: float mLoadSum; michael@0: int mLoadSumMeasurements; michael@0: // Set when overuse was signaled to us, and hasn't been un-signaled yet. michael@0: bool mOveruseActive; michael@0: // Load measurement settings michael@0: int mLoadMeasurementInterval; michael@0: int mAveragingMeasurements; michael@0: float mHighLoadThreshold; michael@0: float mLowLoadThreshold; michael@0: michael@0: webrtc::CPULoadState mCurrentState; michael@0: michael@0: nsTArray mObservers; michael@0: }; michael@0: michael@0: } //namespace michael@0: michael@0: #endif /* _LOADMANAGER_H_ */