Windows should animate when they are about to get docked at screen edges.
[chromium-blink-merge.git] / net / tools / flip_server / http_interface.h
blobe311881e3422bafbfd2abd01ad5c946fe64d4714
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_
6 #define NET_TOOLS_FLIP_SERVER_HTTP_INTERFACE_
8 #include <string>
10 #include "base/compiler_specific.h"
11 #include "net/tools/flip_server/balsa_headers.h"
12 #include "net/tools/flip_server/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,
26 public SMInterface {
27 public:
28 HttpSM(SMConnection* connection,
29 SMInterface* sm_spdy_interface,
30 EpollServer* epoll_server,
31 MemoryCache* memory_cache,
32 FlipAcceptor* acceptor);
33 virtual ~HttpSM();
35 private:
36 // BalsaVisitorInterface:
37 virtual void ProcessBodyInput(const char *input, size_t size) OVERRIDE {}
38 virtual void ProcessBodyData(const char *input, size_t size) OVERRIDE;
39 virtual void ProcessHeaderInput(const char *input, size_t size) OVERRIDE {}
40 virtual void ProcessTrailerInput(const char *input, size_t size) OVERRIDE {}
41 virtual void ProcessHeaders(const BalsaHeaders& headers) OVERRIDE;
42 virtual void ProcessRequestFirstLine(const char* line_input,
43 size_t line_length,
44 const char* method_input,
45 size_t method_length,
46 const char* request_uri_input,
47 size_t request_uri_length,
48 const char* version_input,
49 size_t version_length) OVERRIDE {}
50 virtual void ProcessResponseFirstLine(const char *line_input,
51 size_t line_length,
52 const char *version_input,
53 size_t version_length,
54 const char *status_input,
55 size_t status_length,
56 const char *reason_input,
57 size_t reason_length) OVERRIDE {}
58 virtual void ProcessChunkLength(size_t chunk_length) OVERRIDE {}
59 virtual void ProcessChunkExtensions(const char *input,
60 size_t size) OVERRIDE {}
61 virtual void HeaderDone() OVERRIDE {}
62 virtual void MessageDone() OVERRIDE;
63 virtual void HandleHeaderError(BalsaFrame* framer) OVERRIDE;
64 virtual void HandleHeaderWarning(BalsaFrame* framer) OVERRIDE {}
65 virtual void HandleChunkingError(BalsaFrame* framer) OVERRIDE;
66 virtual void HandleBodyError(BalsaFrame* framer) OVERRIDE;
68 void HandleError();
70 public:
71 void AddToOutputOrder(const MemCacheIter& mci);
72 void SendOKResponse(uint32 stream_id, std::string* output);
73 BalsaFrame* spdy_framer() { return http_framer_; }
74 virtual void set_is_request() OVERRIDE {}
76 // SMInterface:
77 virtual void InitSMInterface(SMInterface* sm_spdy_interface,
78 int32 server_idx) OVERRIDE;
79 virtual void InitSMConnection(SMConnectionPoolInterface* connection_pool,
80 SMInterface* sm_interface,
81 EpollServer* epoll_server,
82 int fd,
83 std::string server_ip,
84 std::string server_port,
85 std::string remote_ip,
86 bool use_ssl) OVERRIDE;
87 virtual size_t ProcessReadInput(const char* data, size_t len) OVERRIDE;
88 virtual size_t ProcessWriteInput(const char* data, size_t len) OVERRIDE;
89 virtual bool MessageFullyRead() const OVERRIDE;
90 virtual void SetStreamID(uint32 stream_id) OVERRIDE;
91 virtual bool Error() const OVERRIDE;
92 virtual const char* ErrorAsString() const OVERRIDE;
93 virtual void Reset() OVERRIDE;
94 virtual void ResetForNewInterface(int32 server_idx) OVERRIDE {}
95 virtual void ResetForNewConnection() OVERRIDE;
96 virtual void Cleanup() OVERRIDE;
97 virtual int PostAcceptHook() OVERRIDE;
99 virtual void NewStream(uint32 stream_id, uint32 priority,
100 const std::string& filename) OVERRIDE;
101 virtual void SendEOF(uint32 stream_id) OVERRIDE;
102 virtual void SendErrorNotFound(uint32 stream_id) OVERRIDE;
103 virtual size_t SendSynStream(uint32 stream_id,
104 const BalsaHeaders& headers) OVERRIDE;
105 virtual size_t SendSynReply(uint32 stream_id,
106 const BalsaHeaders& headers) OVERRIDE;
107 virtual void SendDataFrame(uint32 stream_id, const char* data, int64 len,
108 uint32 flags, bool compress) OVERRIDE;
110 private:
111 void SendEOFImpl(uint32 stream_id);
112 void SendErrorNotFoundImpl(uint32 stream_id);
113 void SendOKResponseImpl(uint32 stream_id, std::string* output);
114 size_t SendSynReplyImpl(uint32 stream_id, const BalsaHeaders& headers);
115 size_t SendSynStreamImpl(uint32 stream_id, const BalsaHeaders& headers);
116 void SendDataFrameImpl(uint32 stream_id, const char* data, int64 len,
117 uint32 flags, bool compress);
118 void EnqueueDataFrame(DataFrame* df);
119 virtual void GetOutput() OVERRIDE;
121 private:
122 uint64 seq_num_;
123 BalsaFrame* http_framer_;
124 BalsaHeaders headers_;
125 uint32 stream_id_;
126 int32 server_idx_;
128 SMConnection* connection_;
129 SMInterface* sm_spdy_interface_;
130 OutputList* output_list_;
131 OutputOrdering output_ordering_;
132 MemoryCache* memory_cache_;
133 FlipAcceptor* acceptor_;
136 } // namespace
138 #endif // NET_TOOLS_FLIP_SERVER_HTTP_INTERFACE_