]>
Commit | Line | Data |
---|---|---|
b6b637eb AR |
1 | #ifndef SQUID_ADAPTATION__ACCESS_CHECK_H |
2 | #define SQUID_ADAPTATION__ACCESS_CHECK_H | |
62c7f90e | 3 | |
d1e045c3 | 4 | #include "base/AsyncJob.h" |
62c7f90e AR |
5 | #include "adaptation/Elements.h" |
6 | #include "adaptation/forward.h" | |
7 | ||
8 | class HttpRequest; | |
9 | class HttpReply; | |
127dce76 | 10 | class ACLFilledChecklist; |
62c7f90e | 11 | |
26ac0430 AJ |
12 | namespace Adaptation |
13 | { | |
62c7f90e AR |
14 | |
15 | class AccessRule; | |
16 | ||
17 | // checks adaptation_access rules to find a matching adaptation service | |
18 | class AccessCheck: public virtual AsyncJob | |
19 | { | |
62c7f90e AR |
20 | public: |
21 | typedef void AccessCheckCallback(ServicePointer match, void *data); | |
abd4b611 AR |
22 | |
23 | // use this to start async ACL checks; returns true if started | |
26ac0430 AJ |
24 | static bool Start(Method method, VectPoint vp, HttpRequest *req, |
25 | HttpReply *rep, AccessCheckCallback *cb, void *cbdata); | |
abd4b611 AR |
26 | |
27 | protected: | |
28 | // use Start to start adaptation checks | |
62c7f90e AR |
29 | AccessCheck(Method, VectPoint, HttpRequest *, HttpReply *, AccessCheckCallback *, void *); |
30 | ~AccessCheck(); | |
31 | ||
32 | private: | |
33 | Method method; | |
34 | VectPoint point; | |
35 | HttpRequest *req; | |
36 | HttpReply *rep; | |
37 | AccessCheckCallback *callback; | |
38 | void *callback_data; | |
127dce76 | 39 | ACLFilledChecklist *acl_checklist; |
62c7f90e AR |
40 | |
41 | typedef int Candidate; | |
42 | typedef Vector<Candidate> Candidates; | |
43 | Candidates candidates; | |
44 | Candidate topCandidate() { return *candidates.begin(); } | |
45 | ||
46 | void do_callback(); | |
47 | ServicePointer findBestService(AccessRule &r, bool preferUp); | |
48 | bool done; | |
49 | ||
50 | public: | |
51 | void check(); | |
52 | void checkCandidates(); | |
53 | static void AccessCheckCallbackWrapper(int, void*); | |
54 | #if 0 | |
55 | static EVH AccessCheckCallbackEvent; | |
56 | #endif | |
57 | void noteAnswer(int answer); | |
58 | ||
59 | //AsyncJob virtual methods | |
60 | virtual bool doneAll() const { return AsyncJob::doneAll() && done;} | |
61 | ||
62 | private: | |
63 | CBDATA_CLASS2(AccessCheck); | |
64 | }; | |
65 | ||
66 | } // namespace Adaptation | |
67 | ||
b6b637eb | 68 | #endif /* SQUID_ADAPTATION__ACCESS_CHECK_H */ |