]>
Commit | Line | Data |
---|---|---|
fdc96a39 | 1 | /* |
b510f3a1 | 2 | * DEBUG: section 93 eCAP Interface |
fdc96a39 AR |
3 | */ |
4 | ||
5 | #ifndef SQUID_ECAP_XACTION_REP_H | |
6 | #define SQUID_ECAP_XACTION_REP_H | |
7 | ||
1f3c65fc | 8 | #include "adaptation/ecap/MessageRep.h" |
a22e6cd3 | 9 | #include "adaptation/ecap/ServiceRep.h" |
602d9612 A |
10 | #include "adaptation/Initiate.h" |
11 | #include "adaptation/Message.h" | |
12 | #include "BodyPipe.h" | |
fdc96a39 AR |
13 | #include <libecap/common/forward.h> |
14 | #include <libecap/common/memory.h> | |
15 | #include <libecap/host/xaction.h> | |
16 | #include <libecap/adapter/xaction.h> | |
17 | ||
af6a12ee AJ |
18 | namespace Adaptation |
19 | { | |
e1381638 AJ |
20 | namespace Ecap |
21 | { | |
fdc96a39 AR |
22 | |
23 | /* The eCAP xaction representative maintains information about a single eCAP | |
26ac0430 | 24 | xaction that Squid communicates with. One eCAP module may register many |
fdc96a39 AR |
25 | eCAP xactions. */ |
26 | class XactionRep : public Adaptation::Initiate, public libecap::host::Xaction, | |
e1381638 | 27 | public BodyConsumer, public BodyProducer |
fdc96a39 AR |
28 | { |
29 | public: | |
af0ded40 | 30 | XactionRep(HttpMsg *virginHeader, HttpRequest *virginCause, AccessLogEntry::Pointer &alp, const Adaptation::ServicePointer &service); |
fdc96a39 AR |
31 | virtual ~XactionRep(); |
32 | ||
f1a768b2 AR |
33 | typedef libecap::shared_ptr<libecap::adapter::Xaction> AdapterXaction; |
34 | void master(const AdapterXaction &aMaster); // establish a link | |
fdc96a39 AR |
35 | |
36 | // libecap::host::Xaction API | |
22fff3bf AR |
37 | virtual const libecap::Area option(const libecap::Name &name) const; |
38 | virtual void visitEachOption(libecap::NamedValueVisitor &visitor) const; | |
4d0854d4 AR |
39 | virtual libecap::Message &virgin(); |
40 | virtual const libecap::Message &cause(); | |
41 | virtual libecap::Message &adapted(); | |
42 | virtual void useVirgin(); | |
43 | virtual void useAdapted(const libecap::shared_ptr<libecap::Message> &msg); | |
3af10ac0 | 44 | virtual void blockVirgin(); |
4d0854d4 AR |
45 | virtual void adaptationDelayed(const libecap::Delay &); |
46 | virtual void adaptationAborted(); | |
0a720258 | 47 | virtual void resume(); |
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 | |
fdc96a39 AR |
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 | ||
75 | protected: | |
a22e6cd3 AR |
76 | Service &service(); |
77 | ||
4d0854d4 AR |
78 | Adaptation::Message &answer(); |
79 | ||
e1e90d26 AR |
80 | void sinkVb(const char *reason); |
81 | void preserveVb(const char *reason); | |
82 | void forgetVb(const char *reason); | |
83 | ||
8679e6c2 AR |
84 | void moveAbContent(); |
85 | ||
aaf0559d | 86 | void updateHistory(HttpMsg *adapted); |
fdc96a39 | 87 | void terminateMaster(); |
4d0854d4 | 88 | void scheduleStop(const char *reason); |
fdc96a39 | 89 | |
22fff3bf AR |
90 | const libecap::Area clientIpValue() const; |
91 | const libecap::Area usernameValue() const; | |
5038f9d8 | 92 | const libecap::Area masterxSharedValue(const libecap::Name &name) const; |
71be37e0 CT |
93 | /// Return the adaptation meta header value for the given header "name" |
94 | const libecap::Area metaValue(const libecap::Name &name) const; | |
95 | /// Return the adaptation meta headers and their values | |
96 | void visitEachMetaHeader(libecap::NamedValueVisitor &visitor) const; | |
22fff3bf | 97 | |
0a720258 AR |
98 | void doResume(); |
99 | ||
fdc96a39 | 100 | private: |
f1a768b2 | 101 | AdapterXaction theMaster; // the actual adaptation xaction we represent |
a22e6cd3 | 102 | Adaptation::ServicePointer theService; ///< xaction's adaptation service |
fdc96a39 | 103 | |
f1a768b2 AR |
104 | MessageRep theVirginRep; |
105 | MessageRep *theCauseRep; | |
4d0854d4 | 106 | |
f1a768b2 AR |
107 | typedef libecap::shared_ptr<libecap::Message> MessagePtr; |
108 | MessagePtr theAnswerRep; | |
fdc96a39 | 109 | |
ea76d91e | 110 | typedef enum { opUndecided, opOn, opComplete, opNever } OperationState; |
e1e90d26 | 111 | OperationState makingVb; //< delivering virgin body from pipe to adapter |
f1a768b2 | 112 | OperationState proxyingAb; // delivering adapted body from adapter to core |
3ff65596 | 113 | int adaptHistoryId; ///< adaptation history slot reservation |
e1e90d26 | 114 | bool vbProductionFinished; // whether there can be no more vb bytes |
7477a343 AR |
115 | bool abProductionFinished; // whether adapter has finished producing ab |
116 | bool abProductionAtEnd; // whether adapter produced a complete ab | |
af0ded40 | 117 | AccessLogEntry::Pointer al; ///< Master transaction AccessLogEntry |
ea76d91e | 118 | |
f1a768b2 | 119 | CBDATA_CLASS2(XactionRep); |
fdc96a39 AR |
120 | }; |
121 | ||
122 | } // namespace Ecap | |
574b508c | 123 | } // namespace Adaptation |
fdc96a39 AR |
124 | |
125 | #endif /* SQUID_ECAP_XACTION_REP_H */ |