Source code

Revision control

Other Tools

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
5
#ifndef CaptivePortalService_h_
6
#define CaptivePortalService_h_
7
8
#include "nsICaptivePortalService.h"
9
#include "nsICaptivePortalDetector.h"
10
#include "nsINamed.h"
11
#include "nsIObserver.h"
12
#include "nsWeakReference.h"
13
#include "nsITimer.h"
14
#include "nsCOMArray.h"
15
#include "mozilla/TimeStamp.h"
16
17
namespace mozilla {
18
namespace net {
19
20
class CaptivePortalService : public nsICaptivePortalService,
21
public nsIObserver,
22
public nsSupportsWeakReference,
23
public nsITimerCallback,
24
public nsICaptivePortalCallback,
25
public nsINamed {
26
public:
27
NS_DECL_ISUPPORTS
28
NS_DECL_NSICAPTIVEPORTALSERVICE
29
NS_DECL_NSIOBSERVER
30
NS_DECL_NSITIMERCALLBACK
31
NS_DECL_NSICAPTIVEPORTALCALLBACK
32
NS_DECL_NSINAMED
33
34
nsresult Initialize();
35
nsresult Start();
36
nsresult Stop();
37
38
static already_AddRefed<nsICaptivePortalService> GetSingleton();
39
40
// This method is only called in the content process, in order to mirror
41
// the captive portal state in the parent process.
42
void SetStateInChild(int32_t aState);
43
44
private:
45
CaptivePortalService();
46
virtual ~CaptivePortalService();
47
nsresult PerformCheck();
48
nsresult RearmTimer();
49
void NotifyConnectivityAvailable(bool aCaptive);
50
51
nsCOMPtr<nsICaptivePortalDetector> mCaptivePortalDetector;
52
int32_t mState;
53
54
nsCOMPtr<nsITimer> mTimer;
55
bool mStarted;
56
bool mInitialized;
57
bool mRequestInProgress;
58
bool mEverBeenCaptive;
59
60
uint32_t mDelay;
61
int32_t mSlackCount;
62
63
uint32_t mMinInterval;
64
uint32_t mMaxInterval;
65
float mBackoffFactor;
66
67
// This holds a timestamp when the last time when the captive portal check
68
// has changed state.
69
mozilla::TimeStamp mLastChecked;
70
};
71
72
} // namespace net
73
} // namespace mozilla
74
75
#endif // CaptivePortalService_h_