]> git.ipfire.org Git - thirdparty/squid.git/blobdiff - src/adaptation/Initiator.h
Source Format Enforcement (#532)
[thirdparty/squid.git] / src / adaptation / Initiator.h
index ba2a1254f10957db81ea04346fc915398a8c56d2..fa9d8949235ca0f2f8fe70e21ee180757bb6e828 100644 (file)
@@ -1,8 +1,17 @@
+/*
+ * Copyright (C) 1996-2020 The Squid Software Foundation and contributors
+ *
+ * Squid software is distributed under GPLv2+ license and includes
+ * contributions from numerous individuals and organizations.
+ * Please see the COPYING and CONTRIBUTORS files for details.
+ */
+
 #ifndef SQUID_ADAPTATION__INITIATOR_H
 #define SQUID_ADAPTATION__INITIATOR_H
 
-#include "base/AsyncJob.h"
 #include "adaptation/forward.h"
+#include "base/AsyncJob.h"
+#include "base/CbcPointer.h"
 
 /*
  * The ICAP Initiator is an ICAP vectoring point that initates ICAP
@@ -13,8 +22,6 @@
  * or aborting an ICAP transaction.
  */
 
-class HttpMsg;
-
 namespace Adaptation
 {
 
@@ -24,23 +31,28 @@ public:
     Initiator(): AsyncJob("Initiator") {}
     virtual ~Initiator() {}
 
-    // called when ICAP response headers are successfully interpreted
-    virtual void noteAdaptationAnswer(HttpMsg *message) = 0;
-
-    // called when valid ICAP response headers are no longer expected
-    // the final parameter is set to disable bypass or retries
-    virtual void noteAdaptationQueryAbort(bool final) = 0;
+    /// AccessCheck calls this back with a possibly nil service group
+    /// to signal whether adaptation is needed and where it should start.
+    virtual void noteAdaptationAclCheckDone(Adaptation::ServiceGroupPointer group);
+    /// called with the initial adaptation decision (adapt, block, error);
+    /// virgin and/or adapted body transmission may continue after this
+    virtual void noteAdaptationAnswer(const Answer &answer) = 0;
 
 protected:
-    Initiate *initiateAdaptation(Initiate *x); // locks and returns x
+    ///< starts freshly created initiate and returns a safe pointer to it
+    CbcPointer<Initiate> initiateAdaptation(Initiate *x);
 
-    // done with x (and not calling announceInitiatorAbort)
-    void clearAdaptation(Initiate *&x); // unlocks x
+    /// clears the pointer (does not call announceInitiatorAbort)
+    void clearAdaptation(CbcPointer<Initiate> &x);
 
-    // inform the transaction about abnormal termination and clear it
-    void announceInitiatorAbort(Initiate *&x); // unlocks x
+    /// inform the transaction about abnormal termination and clear the pointer
+    void announceInitiatorAbort(CbcPointer<Initiate> &x);
+
+    /// Must(initiated(initiate)) instead of Must(initiate.set()), for clarity
+    bool initiated(const CbcPointer<AsyncJob> &job) const { return job.set(); }
 };
 
 } // namespace Adaptation
 
 #endif /* SQUID_ADAPTATION__INITIATOR_H */
+