]> git.ipfire.org Git - thirdparty/squid.git/blobdiff - src/adaptation/AccessCheck.h
SourceFormat Enforcement
[thirdparty/squid.git] / src / adaptation / AccessCheck.h
index 9852e2e6fad38b2ec16c773c7484c0bf5f7fe7c7..cbcda89f8c13836e781d4136fbd65bd43f668327 100644 (file)
@@ -1,9 +1,12 @@
 #ifndef SQUID_ADAPTATION__ACCESS_CHECK_H
 #define SQUID_ADAPTATION__ACCESS_CHECK_H
 
-#include "base/AsyncJob.h"
+#include "acl/Acl.h"
 #include "adaptation/Elements.h"
 #include "adaptation/forward.h"
+#include "adaptation/Initiator.h"
+#include "adaptation/ServiceFilter.h"
+#include "base/AsyncJob.h"
 
 class HttpRequest;
 class HttpReply;
@@ -18,46 +21,43 @@ class AccessRule;
 class AccessCheck: public virtual AsyncJob
 {
 public:
-    typedef void AccessCheckCallback(ServicePointer match, void *data);
+    typedef void AccessCheckCallback(ServiceGroupPointer group, void *data);
 
     // use this to start async ACL checks; returns true if started
     static bool Start(Method method, VectPoint vp, HttpRequest *req,
-                      HttpReply *rep, AccessCheckCallback *cb, void *cbdata);
+                      HttpReply *rep, Adaptation::Initiator *initiator);
 
 protected:
     // use Start to start adaptation checks
-    AccessCheck(Method, VectPoint, HttpRequest *, HttpReply *, AccessCheckCallback *, void *);
+    AccessCheck(const ServiceFilter &aFilter, Adaptation::Initiator *);
     ~AccessCheck();
 
 private:
-    Method method;
-    VectPoint point;
-    HttpRequest *req;
-    HttpReply *rep;
-    AccessCheckCallback *callback;
-    void *callback_data;
+    const ServiceFilter filter;
+    CbcPointer<Adaptation::Initiator> theInitiator; ///< the job which ordered this access check
     ACLFilledChecklist *acl_checklist;
 
     typedef int Candidate;
     typedef Vector<Candidate> Candidates;
     Candidates candidates;
-    Candidate topCandidate() { return *candidates.begin(); }
+    Candidate topCandidate() const { return *candidates.begin(); }
+    ServiceGroupPointer topGroup() const; // may return nil
 
-    void do_callback();
-    ServicePointer findBestService(AccessRule &r, bool preferUp);
-    bool done;
+    void callBack(const ServiceGroupPointer &g);
+    bool isCandidate(AccessRule &r);
 
 public:
-    void check();
     void checkCandidates();
-    static void AccessCheckCallbackWrapper(int, void*);
-#if 0
-    static EVH AccessCheckCallbackEvent;
-#endif
-    void noteAnswer(int answer);
-
-//AsyncJob virtual methods
-    virtual bool doneAll() const { return AsyncJob::doneAll() && done;}
+    static void AccessCheckCallbackWrapper(allow_t, void*);
+    void noteAnswer(allow_t answer);
+
+protected:
+    // AsyncJob API
+    virtual void start();
+    virtual bool doneAll() const { return false; } /// not done until mustStop
+
+    bool usedDynamicRules();
+    void check();
 
 private:
     CBDATA_CLASS2(AccessCheck);