]> git.ipfire.org Git - thirdparty/squid.git/blob - src/adaptation/Initiator.h
SourceFormat Enforcement
[thirdparty/squid.git] / src / adaptation / Initiator.h
1 /*
2 * Copyright (C) 1996-2014 The Squid Software Foundation and contributors
3 *
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.
7 */
8
9 #ifndef SQUID_ADAPTATION__INITIATOR_H
10 #define SQUID_ADAPTATION__INITIATOR_H
11
12 #include "adaptation/forward.h"
13 #include "base/AsyncJob.h"
14 #include "base/CbcPointer.h"
15
16 /*
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.
23 */
24
25 namespace Adaptation
26 {
27
28 class Initiator: virtual public AsyncJob
29 {
30 public:
31 Initiator(): AsyncJob("Initiator") {}
32 virtual ~Initiator() {}
33
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;
40
41 protected:
42 ///< starts freshly created initiate and returns a safe pointer to it
43 CbcPointer<Initiate> initiateAdaptation(Initiate *x);
44
45 /// clears the pointer (does not call announceInitiatorAbort)
46 void clearAdaptation(CbcPointer<Initiate> &x);
47
48 /// inform the transaction about abnormal termination and clear the pointer
49 void announceInitiatorAbort(CbcPointer<Initiate> &x);
50
51 /// Must(initiated(initiate)) instead of Must(initiate.set()), for clarity
52 bool initiated(const CbcPointer<AsyncJob> &job) const { return job.set(); }
53 };
54
55 } // namespace Adaptation
56
57 #endif /* SQUID_ADAPTATION__INITIATOR_H */
58