]> git.ipfire.org Git - thirdparty/squid.git/blob - src/adaptation/AccessCheck.h
Author: Various Translators
[thirdparty/squid.git] / src / adaptation / AccessCheck.h
1 #ifndef SQUID_ADAPTATION__ACCESS_CHECK_H
2 #define SQUID_ADAPTATION__ACCESS_CHECK_H
3
4 #include "base/AsyncJob.h"
5 #include "adaptation/Elements.h"
6 #include "adaptation/forward.h"
7
8 class HttpRequest;
9 class HttpReply;
10 class ACLFilledChecklist;
11
12 namespace Adaptation
13 {
14
15 class AccessRule;
16
17 // checks adaptation_access rules to find a matching adaptation service
18 class AccessCheck: public virtual AsyncJob
19 {
20 public:
21 typedef void AccessCheckCallback(ServicePointer match, void *data);
22
23 // use this to start async ACL checks; returns true if started
24 static bool Start(Method method, VectPoint vp, HttpRequest *req,
25 HttpReply *rep, AccessCheckCallback *cb, void *cbdata);
26
27 protected:
28 // use Start to start adaptation checks
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;
39 ACLFilledChecklist *acl_checklist;
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
68 #endif /* SQUID_ADAPTATION__ACCESS_CHECK_H */