source: squid-ssl/trunk/fuentes/src/adaptation/Initiator.h @ 5495

Last change on this file since 5495 was 5495, checked in by Juanma, 2 years ago

Initial release

File size: 2.0 KB
Line 
1/*
2 * Copyright (C) 1996-2015 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
25namespace Adaptation
26{
27
28class Initiator: virtual public AsyncJob
29{
30public:
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
41protected:
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
Note: See TracBrowser for help on using the repository browser.