| 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_SPDY_INTERFACE_ | 5 #ifndef NET_TOOLS_FLIP_SERVER_SPDY_INTERFACE_H_ |
| 6 #define NET_TOOLS_FLIP_SERVER_SPDY_INTERFACE_ | 6 #define NET_TOOLS_FLIP_SERVER_SPDY_INTERFACE_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "net/spdy/spdy_framer.h" | 12 #include "net/spdy/spdy_framer.h" |
| 13 #include "net/spdy/spdy_protocol.h" | 13 #include "net/spdy/spdy_protocol.h" |
| 14 #include "net/tools/flip_server/balsa_headers.h" | 14 #include "net/tools/flip_server/balsa_headers.h" |
| 15 #include "net/tools/flip_server/balsa_visitor_interface.h" | 15 #include "net/tools/flip_server/balsa_visitor_interface.h" |
| 16 #include "net/tools/flip_server/output_ordering.h" | 16 #include "net/tools/flip_server/output_ordering.h" |
| 17 #include "net/tools/flip_server/sm_connection.h" | 17 #include "net/tools/flip_server/sm_connection.h" |
| 18 #include "net/tools/flip_server/sm_interface.h" | 18 #include "net/tools/flip_server/sm_interface.h" |
| 19 | 19 |
| 20 namespace net { | 20 namespace net { |
| 21 | 21 |
| 22 class BalsaFrame; | |
| 23 class FlipAcceptor; | 22 class FlipAcceptor; |
| 24 class MemoryCache; | 23 class MemoryCache; |
| 25 | 24 |
| 26 class SpdySM : public spdy::SpdyFramerVisitorInterface, | 25 class SpdySM : public spdy::SpdyFramerVisitorInterface, |
| 27 public SMInterface { | 26 public SMInterface { |
| 28 public: | 27 public: |
| 29 SpdySM(SMConnection* connection, | 28 SpdySM(SMConnection* connection, |
| 30 SMInterface* sm_http_interface, | 29 SMInterface* sm_http_interface, |
| 31 EpollServer* epoll_server, | 30 EpollServer* epoll_server, |
| 32 MemoryCache* memory_cache, | 31 MemoryCache* memory_cache, |
| (...skipping 17 matching lines...) Expand all Loading... |
| 50 disable_data_compression_ = value; | 49 disable_data_compression_ = value; |
| 51 } | 50 } |
| 52 | 51 |
| 53 private: | 52 private: |
| 54 virtual void set_is_request() {} | 53 virtual void set_is_request() {} |
| 55 virtual void OnError(spdy::SpdyFramer* framer) {} | 54 virtual void OnError(spdy::SpdyFramer* framer) {} |
| 56 SMInterface* NewConnectionInterface(); | 55 SMInterface* NewConnectionInterface(); |
| 57 SMInterface* FindOrMakeNewSMConnectionInterface(std::string server_ip, | 56 SMInterface* FindOrMakeNewSMConnectionInterface(std::string server_ip, |
| 58 std::string server_port); | 57 std::string server_port); |
| 59 int SpdyHandleNewStream(const spdy::SpdyControlFrame* frame, | 58 int SpdyHandleNewStream(const spdy::SpdyControlFrame* frame, |
| 60 std::string &http_data, | 59 std::string& http_data, |
| 61 bool *is_https_scheme); | 60 bool* is_https_scheme); |
| 62 | 61 |
| 63 // SpdyFramerVisitor interface. | 62 // SpdyFramerVisitor interface. |
| 64 virtual void OnControl(const spdy::SpdyControlFrame* frame); | 63 virtual void OnControl(const spdy::SpdyControlFrame* frame); |
| 65 virtual bool OnControlFrameHeaderData(spdy::SpdyStreamId stream_id, | 64 virtual bool OnControlFrameHeaderData(spdy::SpdyStreamId stream_id, |
| 66 const char* header_data, | 65 const char* header_data, |
| 67 size_t len); | 66 size_t len); |
| 68 virtual void OnDataFrameHeader(const spdy::SpdyDataFrame* frame); | 67 virtual void OnDataFrameHeader(const spdy::SpdyDataFrame* frame); |
| 69 virtual void OnStreamFrameData(spdy::SpdyStreamId stream_id, | 68 virtual void OnStreamFrameData(spdy::SpdyStreamId stream_id, |
| 70 const char* data, size_t len); | 69 const char* data, size_t len); |
| 71 | 70 |
| 72 public: | 71 public: |
| 73 virtual size_t ProcessReadInput(const char* data, size_t len); | 72 virtual size_t ProcessReadInput(const char* data, size_t len); |
| 74 virtual size_t ProcessWriteInput(const char* data, size_t len); | 73 virtual size_t ProcessWriteInput(const char* data, size_t len); |
| 75 virtual bool MessageFullyRead() const; | 74 virtual bool MessageFullyRead() const; |
| 76 virtual void SetStreamID(uint32 stream_id) {} | 75 virtual void SetStreamID(uint32 stream_id) {} |
| 77 virtual bool Error() const; | 76 virtual bool Error() const; |
| 78 virtual const char* ErrorAsString() const; | 77 virtual const char* ErrorAsString() const; |
| 79 virtual void Reset() {} | 78 virtual void Reset() {} |
| 80 virtual void ResetForNewInterface(int32 server_idx); | 79 virtual void ResetForNewInterface(int32 server_idx); |
| 81 virtual void ResetForNewConnection(); | 80 virtual void ResetForNewConnection(); |
| 82 // SMInterface's Cleanup is currently only called by SMConnection after a | 81 // SMInterface's Cleanup is currently only called by SMConnection after a |
| 83 // protocol message as been fully read. Spdy's SMInterface does not need | 82 // protocol message as been fully read. Spdy's SMInterface does not need |
| 84 // to do any cleanup at this time. | 83 // to do any cleanup at this time. |
| 85 // TODO (klindsay) This method is probably not being used properly and | 84 // TODO(klindsay) This method is probably not being used properly and |
| 86 // some logic review and method renaming is probably in order. | 85 // some logic review and method renaming is probably in order. |
| 87 virtual void Cleanup() {} | 86 virtual void Cleanup() {} |
| 88 // Send a settings frame | 87 // Send a settings frame |
| 89 virtual int PostAcceptHook(); | 88 virtual int PostAcceptHook(); |
| 90 virtual void NewStream(uint32 stream_id, | 89 virtual void NewStream(uint32 stream_id, |
| 91 uint32 priority, | 90 uint32 priority, |
| 92 const std::string& filename); | 91 const std::string& filename); |
| 93 void AddToOutputOrder(const MemCacheIter& mci); | 92 void AddToOutputOrder(const MemCacheIter& mci); |
| 94 virtual void SendEOF(uint32 stream_id); | 93 virtual void SendEOF(uint32 stream_id); |
| 95 virtual void SendErrorNotFound(uint32 stream_id); | 94 virtual void SendErrorNotFound(uint32 stream_id); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 typedef std::map<uint32, SMInterface*> StreamToSmif; | 135 typedef std::map<uint32, SMInterface*> StreamToSmif; |
| 137 StreamToSmif stream_to_smif_; | 136 StreamToSmif stream_to_smif_; |
| 138 bool close_on_error_; | 137 bool close_on_error_; |
| 139 | 138 |
| 140 static bool disable_data_compression_; | 139 static bool disable_data_compression_; |
| 141 static std::string forward_ip_header_; | 140 static std::string forward_ip_header_; |
| 142 }; | 141 }; |
| 143 | 142 |
| 144 } // namespace net | 143 } // namespace net |
| 145 | 144 |
| 146 #endif // NET_TOOLS_FLIP_SERVER_SPDY_INTERFACE_ | 145 #endif // NET_TOOLS_FLIP_SERVER_SPDY_INTERFACE_H_ |
| 147 | |
| OLD | NEW |