NetworkActivityMonitor.h 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
  2. *
  3. * This Source Code Form is subject to the terms of the Mozilla Public
  4. * License, v. 2.0. If a copy of the MPL was not distributed with this
  5. * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
  6. #ifndef NetworkActivityMonitor_h___
  7. #define NetworkActivityMonitor_h___
  8. #include <stdint.h>
  9. #include "nscore.h"
  10. #include "prio.h"
  11. #include "prinrval.h"
  12. namespace mozilla { namespace net {
  13. class NetworkActivityMonitor
  14. {
  15. public:
  16. enum Direction {
  17. kUpload = 0,
  18. kDownload = 1
  19. };
  20. NetworkActivityMonitor();
  21. ~NetworkActivityMonitor();
  22. static nsresult Init(int32_t blipInterval);
  23. static nsresult Shutdown();
  24. static nsresult AttachIOLayer(PRFileDesc *fd);
  25. static nsresult DataInOut(Direction direction);
  26. private:
  27. nsresult Init_Internal(int32_t blipInterval);
  28. void PostNotification(Direction direction);
  29. static NetworkActivityMonitor * gInstance;
  30. PRIntervalTime mBlipInterval;
  31. PRIntervalTime mLastNotificationTime[2];
  32. };
  33. } // namespace net
  34. } // namespace mozilla
  35. #endif /* NetworkActivityMonitor_h___ */