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