Fix "#if defined(DEBUG)" statements
[chromium-blink-merge.git] / net / tools / flip_server / http_interface.h
blob08a595e3a81f5023134b6c4195b2a6b555d7a6cc
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
3 // found in the LICENSE file.
5 #ifndef NET_TOOLS_FLIP_SERVER_HTTP_INTERFACE_H_
6 #define NET_TOOLS_FLIP_SERVER_HTTP_INTERFACE_H_
8 #include <string>
10 #include "base/compiler_specific.h"
11 #include "net/tools/balsa/balsa_headers.h"
12 #include "net/tools/balsa/balsa_visitor_interface.h"
13 #include "net/tools/flip_server/output_ordering.h"
14 #include "net/tools/flip_server/sm_connection.h"
15 #include "net/tools/flip_server/sm_interface.h"
17 namespace net {
19 class BalsaFrame;
20 class DataFrame;
21 class EpollServer;
22 class FlipAcceptor;
23 class MemoryCache;
25 class HttpSM : public BalsaVisitorInterface, public SMInterface {
26 public:
27 HttpSM(SMConnection* connection,
28 SMInterface* sm_spdy_interface,
29 MemoryCache* memory_cache,
30 FlipAcceptor* acceptor);
31 virtual ~HttpSM();
33 private:
34 // BalsaVisitorInterface:
35 virtual void ProcessBodyInput(const char* input, size_t size) override {}
36 virtual void ProcessBodyData(const char* input, size_t size) override;
37 virtual void ProcessHeaderInput(const char* input, size_t size) override {}
38 virtual void ProcessTrailerInput(const char* input, size_t size) override {}
39 virtual void ProcessHeaders(const BalsaHeaders& headers) override;
40 virtual void ProcessRequestFirstLine(const char* line_input,
41 size_t line_length,
42 const char* method_input,
43 size_t method_length,
44 const char* request_uri_input,
45 size_t request_uri_length,
46 const char* version_input,
47 size_t version_length) override {}
48 virtual void ProcessResponseFirstLine(const char* line_input,
49 size_t line_length,
50 const char* version_input,
51 size_t version_length,
52 const char* status_input,
53 size_t status_length,
54 const char* reason_input,
55 size_t reason_length) override {}
56 virtual void ProcessChunkLength(size_t chunk_length) override {}
57 virtual void ProcessChunkExtensions(const char* input, size_t size) override {
59 virtual void HeaderDone() override {}
60 virtual void MessageDone() override;
61 virtual void HandleHeaderError(BalsaFrame* framer) override;
62 virtual void HandleHeaderWarning(BalsaFrame* framer) override {}
63 virtual void HandleChunkingError(BalsaFrame* framer) override;
64 virtual void HandleBodyError(BalsaFrame* framer) override;
66 void HandleError();
68 public:
69 void AddToOutputOrder(const MemCacheIter& mci);
70 BalsaFrame* spdy_framer() { return http_framer_; }
71 virtual void set_is_request() override {}
72 const OutputOrdering& output_ordering() const { return output_ordering_; }
74 // SMInterface:
75 virtual void InitSMInterface(SMInterface* sm_spdy_interface,
76 int32 server_idx) override;
77 virtual void InitSMConnection(SMConnectionPoolInterface* connection_pool,
78 SMInterface* sm_interface,
79 EpollServer* epoll_server,
80 int fd,
81 std::string server_ip,
82 std::string server_port,
83 std::string remote_ip,
84 bool use_ssl) override;
85 virtual size_t ProcessReadInput(const char* data, size_t len) override;
86 virtual size_t ProcessWriteInput(const char* data, size_t len) override;
87 virtual bool MessageFullyRead() const override;
88 virtual void SetStreamID(uint32 stream_id) override;
89 virtual bool Error() const override;
90 virtual const char* ErrorAsString() const override;
91 virtual void Reset() override;
92 virtual void ResetForNewInterface(int32 server_idx) override {}
93 virtual void ResetForNewConnection() override;
94 virtual void Cleanup() override;
95 virtual int PostAcceptHook() override;
97 virtual void NewStream(uint32 stream_id,
98 uint32 priority,
99 const std::string& filename) override;
100 virtual void SendEOF(uint32 stream_id) override;
101 virtual void SendErrorNotFound(uint32 stream_id) override;
102 virtual size_t SendSynStream(uint32 stream_id,
103 const BalsaHeaders& headers) override;
104 virtual size_t SendSynReply(uint32 stream_id,
105 const BalsaHeaders& headers) override;
106 virtual void SendDataFrame(uint32 stream_id,
107 const char* data,
108 int64 len,
109 uint32 flags,
110 bool compress) override;
112 private:
113 void SendEOFImpl(uint32 stream_id);
114 void SendErrorNotFoundImpl(uint32 stream_id);
115 void SendOKResponseImpl(uint32 stream_id, const std::string& output);
116 size_t SendSynReplyImpl(uint32 stream_id, const BalsaHeaders& headers);
117 size_t SendSynStreamImpl(uint32 stream_id, const BalsaHeaders& headers);
118 void SendDataFrameImpl(uint32 stream_id,
119 const char* data,
120 int64 len,
121 uint32 flags,
122 bool compress);
123 void EnqueueDataFrame(DataFrame* df);
124 virtual void GetOutput() override;
126 private:
127 BalsaFrame* http_framer_;
128 BalsaHeaders headers_;
129 uint32 stream_id_;
130 int32 server_idx_;
132 SMConnection* connection_;
133 SMInterface* sm_spdy_interface_;
134 OutputList* output_list_;
135 OutputOrdering output_ordering_;
136 MemoryCache* memory_cache_;
137 FlipAcceptor* acceptor_;
140 } // namespace net
142 #endif // NET_TOOLS_FLIP_SERVER_HTTP_INTERFACE_H_