6 #ifndef SQUID_ECAP_XACTION_REP_H
7 #define SQUID_ECAP_XACTION_REP_H
10 #include "adaptation/Initiate.h"
11 #include "adaptation/Message.h"
12 #include "adaptation/ecap/MessageRep.h"
13 #include "adaptation/ecap/ServiceRep.h"
14 #include <libecap/common/forward.h>
15 #include <libecap/common/memory.h>
16 #include <libecap/host/xaction.h>
17 #include <libecap/adapter/xaction.h>
23 /* The eCAP xaction representative maintains information about a single eCAP
24 xaction that Squid communicates with. One eCAP module may register many
26 class XactionRep
: public Adaptation::Initiate
, public libecap::host::Xaction
,
27 public BodyConsumer
, public BodyProducer
30 XactionRep(Adaptation::Initiator
*anInitiator
, HttpMsg
*virginHeader
, HttpRequest
*virginCause
, const Adaptation::ServicePointer
&service
);
31 virtual ~XactionRep();
33 typedef libecap::shared_ptr
<libecap::adapter::Xaction
> AdapterXaction
;
34 void master(const AdapterXaction
&aMaster
); // establish a link
36 // libecap::host::Xaction API
37 virtual libecap::Message
&virgin();
38 virtual const libecap::Message
&cause();
39 virtual libecap::Message
&adapted();
40 virtual void useVirgin();
41 virtual void useAdapted(const libecap::shared_ptr
<libecap::Message
> &msg
);
42 virtual void adaptationDelayed(const libecap::Delay
&);
43 virtual void adaptationAborted();
44 virtual void vbDiscard();
45 virtual void vbMake();
46 virtual void vbStopMaking();
47 virtual void vbMakeMore();
48 virtual libecap::Area
vbContent(libecap::size_type offset
, libecap::size_type size
);
49 virtual void vbContentShift(libecap::size_type size
);
50 virtual void noteAbContentDone(bool atEnd
);
51 virtual void noteAbContentAvailable();
53 // libecap::Callable API, via libecap::host::Xaction
54 virtual bool callable() const;
57 virtual void noteMoreBodySpaceAvailable(RefCount
<BodyPipe
> bp
);
58 virtual void noteBodyConsumerAborted(RefCount
<BodyPipe
> bp
);
61 virtual void noteMoreBodyDataAvailable(RefCount
<BodyPipe
> bp
);
62 virtual void noteBodyProductionEnded(RefCount
<BodyPipe
> bp
);
63 virtual void noteBodyProducerAborted(RefCount
<BodyPipe
> bp
);
66 virtual void noteInitiatorAborted();
68 // AsyncJob API (via Initiate)
70 virtual bool doneAll() const;
71 virtual void swanSong();
72 virtual const char *status() const;
77 Adaptation::Message
&answer();
79 void dropVirgin(const char *reason
);
82 void terminateMaster();
83 void scheduleStop(const char *reason
);
86 AdapterXaction theMaster
; // the actual adaptation xaction we represent
87 Adaptation::ServicePointer theService
; ///< xaction's adaptation service
89 MessageRep theVirginRep
;
90 MessageRep
*theCauseRep
;
92 typedef libecap::shared_ptr
<libecap::Message
> MessagePtr
;
93 MessagePtr theAnswerRep
;
95 typedef enum { opUndecided
, opOn
, opComplete
, opNever
} OperationState
;
96 OperationState proxyingVb
; // delivering virgin body from core to adapter
97 OperationState proxyingAb
; // delivering adapted body from adapter to core
98 int adaptHistoryId
; ///< adaptation history slot reservation
99 bool canAccessVb
; // virgin BodyPipe content is accessible
100 bool abProductionFinished
; // whether adapter has finished producing ab
101 bool abProductionAtEnd
; // whether adapter produced a complete ab
103 CBDATA_CLASS2(XactionRep
);
107 } // namespace Adaptation
109 #endif /* SQUID_ECAP_XACTION_REP_H */