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>
24 /* The eCAP xaction representative maintains information about a single eCAP
25 xaction that Squid communicates with. One eCAP module may register many
27 class XactionRep
: public Adaptation::Initiate
, public libecap::host::Xaction
,
28 public BodyConsumer
, public BodyProducer
31 XactionRep(Adaptation::Initiator
*anInitiator
, HttpMsg
*virginHeader
, HttpRequest
*virginCause
, const Adaptation::ServicePointer
&service
);
32 virtual ~XactionRep();
34 typedef libecap::shared_ptr
<libecap::adapter::Xaction
> AdapterXaction
;
35 void master(const AdapterXaction
&aMaster
); // establish a link
37 // libecap::host::Xaction API
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();
45 virtual void vbDiscard();
46 virtual void vbMake();
47 virtual void vbStopMaking();
48 virtual void vbMakeMore();
49 virtual libecap::Area
vbContent(libecap::size_type offset
, libecap::size_type size
);
50 virtual void vbContentShift(libecap::size_type size
);
51 virtual void noteAbContentDone(bool atEnd
);
52 virtual void noteAbContentAvailable();
54 // libecap::Callable API, via libecap::host::Xaction
55 virtual bool callable() const;
58 virtual void noteMoreBodySpaceAvailable(RefCount
<BodyPipe
> bp
);
59 virtual void noteBodyConsumerAborted(RefCount
<BodyPipe
> bp
);
62 virtual void noteMoreBodyDataAvailable(RefCount
<BodyPipe
> bp
);
63 virtual void noteBodyProductionEnded(RefCount
<BodyPipe
> bp
);
64 virtual void noteBodyProducerAborted(RefCount
<BodyPipe
> bp
);
67 virtual void noteInitiatorAborted();
69 // AsyncJob API (via Initiate)
71 virtual bool doneAll() const;
72 virtual void swanSong();
73 virtual const char *status() const;
78 Adaptation::Message
&answer();
80 void dropVirgin(const char *reason
);
83 void terminateMaster();
84 void scheduleStop(const char *reason
);
87 AdapterXaction theMaster
; // the actual adaptation xaction we represent
88 Adaptation::ServicePointer theService
; ///< xaction's adaptation service
90 MessageRep theVirginRep
;
91 MessageRep
*theCauseRep
;
93 typedef libecap::shared_ptr
<libecap::Message
> MessagePtr
;
94 MessagePtr theAnswerRep
;
96 typedef enum { opUndecided
, opOn
, opComplete
, opNever
} OperationState
;
97 OperationState proxyingVb
; // delivering virgin body from core to adapter
98 OperationState proxyingAb
; // delivering adapted body from adapter to core
99 int adaptHistoryId
; ///< adaptation history slot reservation
100 bool canAccessVb
; // virgin BodyPipe content is accessible
101 bool abProductionFinished
; // whether adapter has finished producing ab
102 bool abProductionAtEnd
; // whether adapter produced a complete ab
104 CBDATA_CLASS2(XactionRep
);
108 } // namespace Adaptation
110 #endif /* SQUID_ECAP_XACTION_REP_H */