]> git.ipfire.org Git - thirdparty/squid.git/blob - src/adaptation/AccessCheck.h
Moved src/ICAP/AsyncJob.* to src/base/ to prepare for the src/ICAP move to
[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
11 namespace Adaptation
12 {
13
14 class AccessRule;
15
16 // checks adaptation_access rules to find a matching adaptation service
17 class AccessCheck: public virtual AsyncJob
18 {
19 public:
20 typedef void AccessCheckCallback(ServicePointer match, void *data);
21
22 // use this to start async ACL checks; returns true if started
23 static bool Start(Method method, VectPoint vp, HttpRequest *req,
24 HttpReply *rep, AccessCheckCallback *cb, void *cbdata);
25
26 protected:
27 // use Start to start adaptation checks
28 AccessCheck(Method, VectPoint, HttpRequest *, HttpReply *, AccessCheckCallback *, void *);
29 ~AccessCheck();
30
31 private:
32 Method method;
33 VectPoint point;
34 HttpRequest *req;
35 HttpReply *rep;
36 AccessCheckCallback *callback;
37 void *callback_data;
38 ACLChecklist *acl_checklist;
39
40 typedef int Candidate;
41 typedef Vector<Candidate> Candidates;
42 Candidates candidates;
43 Candidate topCandidate() { return *candidates.begin(); }
44
45 void do_callback();
46 ServicePointer findBestService(AccessRule &r, bool preferUp);
47 bool done;
48
49 public:
50 void check();
51 void checkCandidates();
52 static void AccessCheckCallbackWrapper(int, void*);
53 #if 0
54 static EVH AccessCheckCallbackEvent;
55 #endif
56 void noteAnswer(int answer);
57
58 //AsyncJob virtual methods
59 virtual bool doneAll() const { return AsyncJob::doneAll() && done;}
60
61 private:
62 CBDATA_CLASS2(AccessCheck);
63 };
64
65 } // namespace Adaptation
66
67 #endif /* SQUID_ADAPTATION__ACCESS_CHECK_H */