]> git.ipfire.org Git - thirdparty/squid.git/blame - src/adaptation/ecap/XactionRep.h
SourceFormat: enforcement
[thirdparty/squid.git] / src / adaptation / ecap / XactionRep.h
CommitLineData
fdc96a39
AR
1
2/*
3 * $Id$
4 */
5
6#ifndef SQUID_ECAP_XACTION_REP_H
7#define SQUID_ECAP_XACTION_REP_H
8
9#include "BodyPipe.h"
10#include "adaptation/Initiate.h"
fdc96a39 11#include "adaptation/Message.h"
1f3c65fc 12#include "adaptation/ecap/MessageRep.h"
a22e6cd3 13#include "adaptation/ecap/ServiceRep.h"
fdc96a39
AR
14#include <libecap/common/forward.h>
15#include <libecap/common/memory.h>
16#include <libecap/host/xaction.h>
17#include <libecap/adapter/xaction.h>
18
af6a12ee
AJ
19namespace Adaptation
20{
e1381638
AJ
21namespace Ecap
22{
fdc96a39
AR
23
24/* The eCAP xaction representative maintains information about a single eCAP
26ac0430 25 xaction that Squid communicates with. One eCAP module may register many
fdc96a39
AR
26 eCAP xactions. */
27class XactionRep : public Adaptation::Initiate, public libecap::host::Xaction,
e1381638 28 public BodyConsumer, public BodyProducer
fdc96a39
AR
29{
30public:
31 XactionRep(Adaptation::Initiator *anInitiator, HttpMsg *virginHeader, HttpRequest *virginCause, const Adaptation::ServicePointer &service);
32 virtual ~XactionRep();
33
f1a768b2
AR
34 typedef libecap::shared_ptr<libecap::adapter::Xaction> AdapterXaction;
35 void master(const AdapterXaction &aMaster); // establish a link
fdc96a39
AR
36
37 // libecap::host::Xaction API
4d0854d4
AR
38 virtual libecap::Message &virgin();
39 virtual const libecap::Message &cause();
40 virtual libecap::Message &adapted();
41 virtual void useVirgin();
42 virtual void useAdapted(const libecap::shared_ptr<libecap::Message> &msg);
43 virtual void adaptationDelayed(const libecap::Delay &);
44 virtual void adaptationAborted();
a96661a8 45 virtual void vbDiscard();
8679e6c2
AR
46 virtual void vbMake();
47 virtual void vbStopMaking();
48 virtual void vbMakeMore();
a96661a8 49 virtual libecap::Area vbContent(libecap::size_type offset, libecap::size_type size);
8679e6c2
AR
50 virtual void vbContentShift(libecap::size_type size);
51 virtual void noteAbContentDone(bool atEnd);
52 virtual void noteAbContentAvailable();
4d0854d4 53
f1a768b2
AR
54 // libecap::Callable API, via libecap::host::Xaction
55 virtual bool callable() const;
fdc96a39
AR
56
57 // BodyProducer API
58 virtual void noteMoreBodySpaceAvailable(RefCount<BodyPipe> bp);
59 virtual void noteBodyConsumerAborted(RefCount<BodyPipe> bp);
60
61 // BodyConsumer API
62 virtual void noteMoreBodyDataAvailable(RefCount<BodyPipe> bp);
63 virtual void noteBodyProductionEnded(RefCount<BodyPipe> bp);
64 virtual void noteBodyProducerAborted(RefCount<BodyPipe> bp);
65
66 // Initiate API
67 virtual void noteInitiatorAborted();
68
69 // AsyncJob API (via Initiate)
70 virtual void start();
4d0854d4
AR
71 virtual bool doneAll() const;
72 virtual void swanSong();
fdc96a39
AR
73 virtual const char *status() const;
74
75protected:
a22e6cd3
AR
76 Service &service();
77
4d0854d4
AR
78 Adaptation::Message &answer();
79
4d0854d4 80 void dropVirgin(const char *reason);
8679e6c2
AR
81 void moveAbContent();
82
fdc96a39 83 void terminateMaster();
4d0854d4 84 void scheduleStop(const char *reason);
fdc96a39
AR
85
86private:
f1a768b2 87 AdapterXaction theMaster; // the actual adaptation xaction we represent
a22e6cd3 88 Adaptation::ServicePointer theService; ///< xaction's adaptation service
fdc96a39 89
f1a768b2
AR
90 MessageRep theVirginRep;
91 MessageRep *theCauseRep;
4d0854d4 92
f1a768b2
AR
93 typedef libecap::shared_ptr<libecap::Message> MessagePtr;
94 MessagePtr theAnswerRep;
fdc96a39 95
ea76d91e 96 typedef enum { opUndecided, opOn, opComplete, opNever } OperationState;
f1a768b2
AR
97 OperationState proxyingVb; // delivering virgin body from core to adapter
98 OperationState proxyingAb; // delivering adapted body from adapter to core
3ff65596 99 int adaptHistoryId; ///< adaptation history slot reservation
f1a768b2 100 bool canAccessVb; // virgin BodyPipe content is accessible
7477a343
AR
101 bool abProductionFinished; // whether adapter has finished producing ab
102 bool abProductionAtEnd; // whether adapter produced a complete ab
ea76d91e 103
f1a768b2 104 CBDATA_CLASS2(XactionRep);
fdc96a39
AR
105};
106
107} // namespace Ecap
574b508c 108} // namespace Adaptation
fdc96a39
AR
109
110#endif /* SQUID_ECAP_XACTION_REP_H */