CaptivePortalService.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /* This Source Code Form is subject to the terms of the Mozilla Public
  2. * License, v. 2.0. If a copy of the MPL was not distributed with this
  3. * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
  4. #ifndef CaptivePortalService_h_
  5. #define CaptivePortalService_h_
  6. #include "nsICaptivePortalService.h"
  7. #include "nsICaptivePortalDetector.h"
  8. #include "nsIObserver.h"
  9. #include "nsWeakReference.h"
  10. #include "nsITimer.h"
  11. #include "nsCOMArray.h"
  12. #include "mozilla/TimeStamp.h"
  13. namespace mozilla {
  14. namespace net {
  15. class CaptivePortalService
  16. : public nsICaptivePortalService
  17. , public nsIObserver
  18. , public nsSupportsWeakReference
  19. , public nsITimerCallback
  20. , public nsICaptivePortalCallback
  21. {
  22. public:
  23. NS_DECL_ISUPPORTS
  24. NS_DECL_NSICAPTIVEPORTALSERVICE
  25. NS_DECL_NSIOBSERVER
  26. NS_DECL_NSITIMERCALLBACK
  27. NS_DECL_NSICAPTIVEPORTALCALLBACK
  28. CaptivePortalService();
  29. nsresult Initialize();
  30. nsresult Start();
  31. nsresult Stop();
  32. // This method is only called in the content process, in order to mirror
  33. // the captive portal state in the parent process.
  34. void SetStateInChild(int32_t aState);
  35. private:
  36. virtual ~CaptivePortalService();
  37. nsresult PerformCheck();
  38. nsresult RearmTimer();
  39. nsCOMPtr<nsICaptivePortalDetector> mCaptivePortalDetector;
  40. int32_t mState;
  41. nsCOMPtr<nsITimer> mTimer;
  42. bool mStarted;
  43. bool mInitialized;
  44. bool mRequestInProgress;
  45. bool mEverBeenCaptive;
  46. uint32_t mDelay;
  47. int32_t mSlackCount;
  48. uint32_t mMinInterval;
  49. uint32_t mMaxInterval;
  50. float mBackoffFactor;
  51. // This holds a timestamp when the last time when the captive portal check
  52. // has changed state.
  53. mozilla::TimeStamp mLastChecked;
  54. };
  55. } // namespace net
  56. } // namespace mozilla
  57. #endif // CaptivePortalService_h_