| OLD | NEW | 
|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be | 
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. | 
| 4 | 4 | 
| 5 #ifndef NET_TOOLS_FLIP_SERVER_STREAMER_INTERFACE_ | 5 #ifndef NET_TOOLS_FLIP_SERVER_STREAMER_INTERFACE_H_ | 
| 6 #define NET_TOOLS_FLIP_SERVER_STREAMER_INTERFACE_ | 6 #define NET_TOOLS_FLIP_SERVER_STREAMER_INTERFACE_H_ | 
| 7 | 7 | 
| 8 #include <string> | 8 #include <string> | 
| 9 | 9 | 
| 10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" | 
| 11 #include "net/tools/balsa/balsa_headers.h" | 11 #include "net/tools/balsa/balsa_headers.h" | 
| 12 #include "net/tools/balsa/balsa_visitor_interface.h" | 12 #include "net/tools/balsa/balsa_visitor_interface.h" | 
| 13 #include "net/tools/flip_server/sm_interface.h" | 13 #include "net/tools/flip_server/sm_interface.h" | 
| 14 | 14 | 
| 15 namespace net { | 15 namespace net { | 
| 16 | 16 | 
| 17 class BalsaFrame; | 17 class BalsaFrame; | 
| 18 class FlipAcceptor; | 18 class FlipAcceptor; | 
| 19 class MemCacheIter; | 19 class MemCacheIter; | 
| 20 class SMConnection; | 20 class SMConnection; | 
| 21 class EpollServer; | 21 class EpollServer; | 
| 22 | 22 | 
| 23 class StreamerSM : public BalsaVisitorInterface, | 23 class StreamerSM : public BalsaVisitorInterface, public SMInterface { | 
| 24                    public SMInterface  { |  | 
| 25  public: | 24  public: | 
| 26   StreamerSM(SMConnection* connection, | 25   StreamerSM(SMConnection* connection, | 
| 27              SMInterface* sm_other_interface, | 26              SMInterface* sm_other_interface, | 
| 28              EpollServer* epoll_server, | 27              EpollServer* epoll_server, | 
| 29              FlipAcceptor* acceptor); | 28              FlipAcceptor* acceptor); | 
| 30   virtual ~StreamerSM(); | 29   virtual ~StreamerSM(); | 
| 31 | 30 | 
| 32   void AddToOutputOrder(const MemCacheIter& mci) {} | 31   void AddToOutputOrder(const MemCacheIter& mci) {} | 
| 33 | 32 | 
| 34   virtual void InitSMInterface(SMInterface* sm_other_interface, | 33   virtual void InitSMInterface(SMInterface* sm_other_interface, | 
| (...skipping 11 matching lines...) Expand all  Loading... | 
| 46   virtual size_t ProcessWriteInput(const char* data, size_t len) OVERRIDE; | 45   virtual size_t ProcessWriteInput(const char* data, size_t len) OVERRIDE; | 
| 47   virtual bool MessageFullyRead() const OVERRIDE; | 46   virtual bool MessageFullyRead() const OVERRIDE; | 
| 48   virtual void SetStreamID(uint32 stream_id) OVERRIDE {} | 47   virtual void SetStreamID(uint32 stream_id) OVERRIDE {} | 
| 49   virtual bool Error() const OVERRIDE; | 48   virtual bool Error() const OVERRIDE; | 
| 50   virtual const char* ErrorAsString() const OVERRIDE; | 49   virtual const char* ErrorAsString() const OVERRIDE; | 
| 51   virtual void Reset() OVERRIDE; | 50   virtual void Reset() OVERRIDE; | 
| 52   virtual void ResetForNewInterface(int32 server_idx) OVERRIDE {} | 51   virtual void ResetForNewInterface(int32 server_idx) OVERRIDE {} | 
| 53   virtual void ResetForNewConnection() OVERRIDE; | 52   virtual void ResetForNewConnection() OVERRIDE; | 
| 54   virtual void Cleanup() OVERRIDE; | 53   virtual void Cleanup() OVERRIDE; | 
| 55   virtual int PostAcceptHook() OVERRIDE; | 54   virtual int PostAcceptHook() OVERRIDE; | 
| 56   virtual void NewStream(uint32 stream_id, uint32 priority, | 55   virtual void NewStream(uint32 stream_id, | 
|  | 56                          uint32 priority, | 
| 57                          const std::string& filename) OVERRIDE {} | 57                          const std::string& filename) OVERRIDE {} | 
| 58   virtual void SendEOF(uint32 stream_id) OVERRIDE {} | 58   virtual void SendEOF(uint32 stream_id) OVERRIDE {} | 
| 59   virtual void SendErrorNotFound(uint32 stream_id) OVERRIDE {} | 59   virtual void SendErrorNotFound(uint32 stream_id) OVERRIDE {} | 
| 60   virtual void SendOKResponse(uint32 stream_id, std::string output) {} | 60   virtual void SendOKResponse(uint32 stream_id, std::string output) {} | 
| 61   virtual size_t SendSynStream(uint32 stream_id, | 61   virtual size_t SendSynStream(uint32 stream_id, | 
| 62                                const BalsaHeaders& headers) OVERRIDE; | 62                                const BalsaHeaders& headers) OVERRIDE; | 
| 63   virtual size_t SendSynReply(uint32 stream_id, | 63   virtual size_t SendSynReply(uint32 stream_id, | 
| 64                               const BalsaHeaders& headers) OVERRIDE; | 64                               const BalsaHeaders& headers) OVERRIDE; | 
| 65   virtual void SendDataFrame(uint32 stream_id, const char* data, int64 len, | 65   virtual void SendDataFrame(uint32 stream_id, | 
| 66                              uint32 flags, bool compress) OVERRIDE {} | 66                              const char* data, | 
|  | 67                              int64 len, | 
|  | 68                              uint32 flags, | 
|  | 69                              bool compress) OVERRIDE {} | 
| 67   virtual void set_is_request() OVERRIDE; | 70   virtual void set_is_request() OVERRIDE; | 
| 68   static std::string forward_ip_header() { return forward_ip_header_; } | 71   static std::string forward_ip_header() { return forward_ip_header_; } | 
| 69   static void set_forward_ip_header(std::string value) { | 72   static void set_forward_ip_header(std::string value) { | 
| 70     forward_ip_header_ = value; | 73     forward_ip_header_ = value; | 
| 71   } | 74   } | 
| 72 | 75 | 
| 73  private: | 76  private: | 
| 74   void SendEOFImpl(uint32 stream_id) {} | 77   void SendEOFImpl(uint32 stream_id) {} | 
| 75   void SendErrorNotFoundImpl(uint32 stream_id) {} | 78   void SendErrorNotFoundImpl(uint32 stream_id) {} | 
| 76   void SendOKResponseImpl(uint32 stream_id, std::string* output) {} | 79   void SendOKResponseImpl(uint32 stream_id, std::string* output) {} | 
| 77   size_t SendSynReplyImpl(uint32 stream_id, const BalsaHeaders& headers) { | 80   size_t SendSynReplyImpl(uint32 stream_id, const BalsaHeaders& headers) { | 
| 78     return 0; | 81     return 0; | 
| 79   } | 82   } | 
| 80   size_t SendSynStreamImpl(uint32 stream_id, const BalsaHeaders& headers) { | 83   size_t SendSynStreamImpl(uint32 stream_id, const BalsaHeaders& headers) { | 
| 81     return 0; | 84     return 0; | 
| 82   } | 85   } | 
| 83   void SendDataFrameImpl(uint32 stream_id, const char* data, int64 len, | 86   void SendDataFrameImpl(uint32 stream_id, | 
| 84                          uint32 flags, bool compress) {} | 87                          const char* data, | 
|  | 88                          int64 len, | 
|  | 89                          uint32 flags, | 
|  | 90                          bool compress) {} | 
| 85   virtual void GetOutput() OVERRIDE {} | 91   virtual void GetOutput() OVERRIDE {} | 
| 86 | 92 | 
| 87   virtual void ProcessBodyInput(const char *input, size_t size) OVERRIDE; | 93   virtual void ProcessBodyInput(const char* input, size_t size) OVERRIDE; | 
| 88   virtual void MessageDone() OVERRIDE; | 94   virtual void MessageDone() OVERRIDE; | 
| 89   virtual void ProcessHeaders(const BalsaHeaders& headers) OVERRIDE; | 95   virtual void ProcessHeaders(const BalsaHeaders& headers) OVERRIDE; | 
| 90   virtual void ProcessBodyData(const char *input, size_t size) OVERRIDE {} | 96   virtual void ProcessBodyData(const char* input, size_t size) OVERRIDE {} | 
| 91   virtual void ProcessHeaderInput(const char *input, size_t size) OVERRIDE {} | 97   virtual void ProcessHeaderInput(const char* input, size_t size) OVERRIDE {} | 
| 92   virtual void ProcessTrailerInput(const char *input, size_t size) OVERRIDE {} | 98   virtual void ProcessTrailerInput(const char* input, size_t size) OVERRIDE {} | 
| 93   virtual void ProcessRequestFirstLine(const char* line_input, | 99   virtual void ProcessRequestFirstLine(const char* line_input, | 
| 94                                        size_t line_length, | 100                                        size_t line_length, | 
| 95                                        const char* method_input, | 101                                        const char* method_input, | 
| 96                                        size_t method_length, | 102                                        size_t method_length, | 
| 97                                        const char* request_uri_input, | 103                                        const char* request_uri_input, | 
| 98                                        size_t request_uri_length, | 104                                        size_t request_uri_length, | 
| 99                                        const char* version_input, | 105                                        const char* version_input, | 
| 100                                        size_t version_length) OVERRIDE {} | 106                                        size_t version_length) OVERRIDE {} | 
| 101   virtual void ProcessResponseFirstLine(const char *line_input, | 107   virtual void ProcessResponseFirstLine(const char* line_input, | 
| 102                                         size_t line_length, | 108                                         size_t line_length, | 
| 103                                         const char *version_input, | 109                                         const char* version_input, | 
| 104                                         size_t version_length, | 110                                         size_t version_length, | 
| 105                                         const char *status_input, | 111                                         const char* status_input, | 
| 106                                         size_t status_length, | 112                                         size_t status_length, | 
| 107                                         const char *reason_input, | 113                                         const char* reason_input, | 
| 108                                         size_t reason_length) OVERRIDE {} | 114                                         size_t reason_length) OVERRIDE {} | 
| 109   virtual void ProcessChunkLength(size_t chunk_length) OVERRIDE {} | 115   virtual void ProcessChunkLength(size_t chunk_length) OVERRIDE {} | 
| 110   virtual void ProcessChunkExtensions(const char *input, | 116   virtual void ProcessChunkExtensions(const char* input, size_t size) OVERRIDE { | 
| 111                                       size_t size) OVERRIDE {} | 117   } | 
| 112   virtual void HeaderDone() OVERRIDE {} | 118   virtual void HeaderDone() OVERRIDE {} | 
| 113   virtual void HandleHeaderError(BalsaFrame* framer) OVERRIDE; | 119   virtual void HandleHeaderError(BalsaFrame* framer) OVERRIDE; | 
| 114   virtual void HandleHeaderWarning(BalsaFrame* framer) OVERRIDE {} | 120   virtual void HandleHeaderWarning(BalsaFrame* framer) OVERRIDE {} | 
| 115   virtual void HandleChunkingError(BalsaFrame* framer) OVERRIDE; | 121   virtual void HandleChunkingError(BalsaFrame* framer) OVERRIDE; | 
| 116   virtual void HandleBodyError(BalsaFrame* framer) OVERRIDE; | 122   virtual void HandleBodyError(BalsaFrame* framer) OVERRIDE; | 
| 117   void HandleError(); | 123   void HandleError(); | 
| 118 | 124 | 
| 119   SMConnection* connection_; | 125   SMConnection* connection_; | 
| 120   SMInterface* sm_other_interface_; | 126   SMInterface* sm_other_interface_; | 
| 121   EpollServer* epoll_server_; | 127   EpollServer* epoll_server_; | 
| 122   FlipAcceptor* acceptor_; | 128   FlipAcceptor* acceptor_; | 
| 123   bool is_request_; | 129   bool is_request_; | 
| 124   BalsaFrame* http_framer_; | 130   BalsaFrame* http_framer_; | 
| 125   BalsaHeaders headers_; | 131   BalsaHeaders headers_; | 
| 126   static std::string forward_ip_header_; | 132   static std::string forward_ip_header_; | 
| 127 }; | 133 }; | 
| 128 | 134 | 
| 129 }  // namespace net | 135 }  // namespace net | 
| 130 | 136 | 
| 131 #endif  // NET_TOOLS_FLIP_SERVER_STREAMER_INTERFACE_ | 137 #endif  // NET_TOOLS_FLIP_SERVER_STREAMER_INTERFACE_H_ | 
| 132 |  | 
| OLD | NEW | 
|---|