content/media/webrtc/LoadMonitor.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/content/media/webrtc/LoadMonitor.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,63 @@
     1.4 +/* -*- Mode: C++; tab-width: 50; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
     1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.8 +
     1.9 +#ifndef _LOADMONITOR_H_
    1.10 +#define _LOADMONITOR_H_
    1.11 +
    1.12 +#include "mozilla/Mutex.h"
    1.13 +#include "mozilla/CondVar.h"
    1.14 +#include "mozilla/RefPtr.h"
    1.15 +#include "mozilla/Atomics.h"
    1.16 +#include "nsAutoPtr.h"
    1.17 +#include "nsCOMPtr.h"
    1.18 +#include "nsIThread.h"
    1.19 +#include "nsIObserver.h"
    1.20 +
    1.21 +namespace mozilla {
    1.22 +class LoadInfoUpdateRunner;
    1.23 +class LoadInfoCollectRunner;
    1.24 +
    1.25 +class LoadNotificationCallback
    1.26 +{
    1.27 +public:
    1.28 +    virtual void LoadChanged(float aSystemLoad, float aProcessLoad) = 0;
    1.29 +};
    1.30 +
    1.31 +class LoadMonitor MOZ_FINAL : public nsIObserver
    1.32 +{
    1.33 +public:
    1.34 +    NS_DECL_THREADSAFE_ISUPPORTS
    1.35 +    NS_DECL_NSIOBSERVER
    1.36 +
    1.37 +    LoadMonitor(int aLoadUpdateInterval);
    1.38 +    ~LoadMonitor();
    1.39 +
    1.40 +    nsresult Init(nsRefPtr<LoadMonitor> &self);
    1.41 +    void SetLoadChangeCallback(LoadNotificationCallback* aCallback);
    1.42 +    void Shutdown();
    1.43 +    float GetSystemLoad();
    1.44 +    float GetProcessLoad();
    1.45 +
    1.46 +    friend class LoadInfoCollectRunner;
    1.47 +
    1.48 +private:
    1.49 +
    1.50 +    void SetProcessLoad(float load);
    1.51 +    void SetSystemLoad(float load);
    1.52 +    void FireCallbacks();
    1.53 +
    1.54 +    int                  mLoadUpdateInterval;
    1.55 +    mozilla::Mutex       mLock;
    1.56 +    mozilla::CondVar     mCondVar;
    1.57 +    bool                 mShutdownPending;
    1.58 +    nsCOMPtr<nsIThread>  mLoadInfoThread;
    1.59 +    float                mSystemLoad;
    1.60 +    float                mProcessLoad;
    1.61 +    LoadNotificationCallback* mLoadNotificationCallback;
    1.62 +};
    1.63 +
    1.64 +} //namespace
    1.65 +
    1.66 +#endif /* _LOADMONITOR_H_ */

mercurial