]>
Commit | Line | Data |
---|---|---|
bbc27441 | 1 | /* |
5b74111a | 2 | * Copyright (C) 1996-2018 The Squid Software Foundation and contributors |
bbc27441 AJ |
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 | ||
2e4a5466 AR |
9 | #ifndef SQUID_ADAPTATION__INITIATOR_H |
10 | #define SQUID_ADAPTATION__INITIATOR_H | |
11 | ||
1adcebc3 | 12 | #include "adaptation/forward.h" |
d1e045c3 | 13 | #include "base/AsyncJob.h" |
4299f876 | 14 | #include "base/CbcPointer.h" |
2e4a5466 AR |
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 | ||
26ac0430 AJ |
25 | namespace Adaptation |
26 | { | |
2e4a5466 AR |
27 | |
28 | class Initiator: virtual public AsyncJob | |
29 | { | |
30 | public: | |
31 | Initiator(): AsyncJob("Initiator") {} | |
32 | virtual ~Initiator() {} | |
33 | ||
79628299 CT |
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); | |
3af10ac0 AR |
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; | |
2e4a5466 AR |
40 | |
41 | protected: | |
4299f876 AR |
42 | ///< starts freshly created initiate and returns a safe pointer to it |
43 | CbcPointer<Initiate> initiateAdaptation(Initiate *x); | |
2e4a5466 | 44 | |
4299f876 AR |
45 | /// clears the pointer (does not call announceInitiatorAbort) |
46 | void clearAdaptation(CbcPointer<Initiate> &x); | |
2e4a5466 | 47 | |
4299f876 AR |
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(); } | |
2e4a5466 AR |
53 | }; |
54 | ||
55 | } // namespace Adaptation | |
56 | ||
57 | #endif /* SQUID_ADAPTATION__INITIATOR_H */ | |
f53969cc | 58 |