2 * Copyright (C) 1996-2017 The Squid Software Foundation and contributors
4 * Squid software is distributed under GPLv2+ license and includes
5 * contributions from numerous individuals and organizations.
6 * Please see the COPYING and CONTRIBUTORS files for details.
9 #ifndef SQUID_ADAPTATION__INITIATOR_H
10 #define SQUID_ADAPTATION__INITIATOR_H
12 #include "adaptation/forward.h"
13 #include "base/AsyncJob.h"
14 #include "base/CbcPointer.h"
17 * The ICAP Initiator is an ICAP vectoring point that initates ICAP
18 * transactions. This interface exists to allow ICAP transactions to
19 * signal their initiators that they have the answer from the ICAP server
20 * or that the ICAP query has aborted and there will be no answer. It
21 * is also handy for implementing common initiator actions such as starting
22 * or aborting an ICAP transaction.
28 class Initiator
: virtual public AsyncJob
31 Initiator(): AsyncJob("Initiator") {}
32 virtual ~Initiator() {}
34 /// AccessCheck calls this back with a possibly nil service group
35 /// to signal whether adaptation is needed and where it should start.
36 virtual void noteAdaptationAclCheckDone(Adaptation::ServiceGroupPointer group
);
37 /// called with the initial adaptation decision (adapt, block, error);
38 /// virgin and/or adapted body transmission may continue after this
39 virtual void noteAdaptationAnswer(const Answer
&answer
) = 0;
42 ///< starts freshly created initiate and returns a safe pointer to it
43 CbcPointer
<Initiate
> initiateAdaptation(Initiate
*x
);
45 /// clears the pointer (does not call announceInitiatorAbort)
46 void clearAdaptation(CbcPointer
<Initiate
> &x
);
48 /// inform the transaction about abnormal termination and clear the pointer
49 void announceInitiatorAbort(CbcPointer
<Initiate
> &x
);
51 /// Must(initiated(initiate)) instead of Must(initiate.set()), for clarity
52 bool initiated(const CbcPointer
<AsyncJob
> &job
) const { return job
.set(); }
55 } // namespace Adaptation
57 #endif /* SQUID_ADAPTATION__INITIATOR_H */