]> git.ipfire.org Git - thirdparty/squid.git/blame - src/adaptation/ecap/XactionRep.h
Code cleanup: Implement proper copy-constructor for HttpHeader. Polished.
[thirdparty/squid.git] / src / adaptation / ecap / XactionRep.h
CommitLineData
fdc96a39
AR
1/*
2 * $Id$
b510f3a1 3 * DEBUG: section 93 eCAP Interface
fdc96a39
AR
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:
4299f876 31 XactionRep(HttpMsg *virginHeader, HttpRequest *virginCause, const Adaptation::ServicePointer &service);
fdc96a39
AR
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
22fff3bf
AR
38 virtual const libecap::Area option(const libecap::Name &name) const;
39 virtual void visitEachOption(libecap::NamedValueVisitor &visitor) const;
4d0854d4
AR
40 virtual libecap::Message &virgin();
41 virtual const libecap::Message &cause();
42 virtual libecap::Message &adapted();
43 virtual void useVirgin();
44 virtual void useAdapted(const libecap::shared_ptr<libecap::Message> &msg);
3af10ac0 45 virtual void blockVirgin();
4d0854d4
AR
46 virtual void adaptationDelayed(const libecap::Delay &);
47 virtual void adaptationAborted();
a96661a8 48 virtual void vbDiscard();
8679e6c2
AR
49 virtual void vbMake();
50 virtual void vbStopMaking();
51 virtual void vbMakeMore();
a96661a8 52 virtual libecap::Area vbContent(libecap::size_type offset, libecap::size_type size);
8679e6c2
AR
53 virtual void vbContentShift(libecap::size_type size);
54 virtual void noteAbContentDone(bool atEnd);
55 virtual void noteAbContentAvailable();
4d0854d4 56
f1a768b2
AR
57 // libecap::Callable API, via libecap::host::Xaction
58 virtual bool callable() const;
fdc96a39
AR
59
60 // BodyProducer API
61 virtual void noteMoreBodySpaceAvailable(RefCount<BodyPipe> bp);
62 virtual void noteBodyConsumerAborted(RefCount<BodyPipe> bp);
63
64 // BodyConsumer API
65 virtual void noteMoreBodyDataAvailable(RefCount<BodyPipe> bp);
66 virtual void noteBodyProductionEnded(RefCount<BodyPipe> bp);
67 virtual void noteBodyProducerAborted(RefCount<BodyPipe> bp);
68
69 // Initiate API
70 virtual void noteInitiatorAborted();
71
72 // AsyncJob API (via Initiate)
73 virtual void start();
4d0854d4
AR
74 virtual bool doneAll() const;
75 virtual void swanSong();
fdc96a39
AR
76 virtual const char *status() const;
77
78protected:
a22e6cd3
AR
79 Service &service();
80
4d0854d4
AR
81 Adaptation::Message &answer();
82
e1e90d26
AR
83 void sinkVb(const char *reason);
84 void preserveVb(const char *reason);
85 void forgetVb(const char *reason);
86
8679e6c2
AR
87 void moveAbContent();
88
fdc96a39 89 void terminateMaster();
4d0854d4 90 void scheduleStop(const char *reason);
fdc96a39 91
22fff3bf
AR
92 const libecap::Area clientIpValue() const;
93 const libecap::Area usernameValue() const;
94
fdc96a39 95private:
f1a768b2 96 AdapterXaction theMaster; // the actual adaptation xaction we represent
a22e6cd3 97 Adaptation::ServicePointer theService; ///< xaction's adaptation service
fdc96a39 98
f1a768b2
AR
99 MessageRep theVirginRep;
100 MessageRep *theCauseRep;
4d0854d4 101
f1a768b2
AR
102 typedef libecap::shared_ptr<libecap::Message> MessagePtr;
103 MessagePtr theAnswerRep;
fdc96a39 104
ea76d91e 105 typedef enum { opUndecided, opOn, opComplete, opNever } OperationState;
e1e90d26 106 OperationState makingVb; //< delivering virgin body from pipe to adapter
f1a768b2 107 OperationState proxyingAb; // delivering adapted body from adapter to core
3ff65596 108 int adaptHistoryId; ///< adaptation history slot reservation
e1e90d26 109 bool vbProductionFinished; // whether there can be no more vb bytes
7477a343
AR
110 bool abProductionFinished; // whether adapter has finished producing ab
111 bool abProductionAtEnd; // whether adapter produced a complete ab
ea76d91e 112
f1a768b2 113 CBDATA_CLASS2(XactionRep);
fdc96a39
AR
114};
115
116} // namespace Ecap
574b508c 117} // namespace Adaptation
fdc96a39
AR
118
119#endif /* SQUID_ECAP_XACTION_REP_H */