Make Ctrl + T from apps focus the new tab's omnibox on Linux and ChromeOS.
[chromium-blink-merge.git] / net / tools / flip_server / http_interface.h
blobc6dc978b0867d5373bce0d538c7ee9e81da76354
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 ~HttpSM() override;
33 private:
34 // BalsaVisitorInterface:
35 void ProcessBodyInput(const char* input, size_t size) override {}
36 void ProcessBodyData(const char* input, size_t size) override;
37 void ProcessHeaderInput(const char* input, size_t size) override {}
38 void ProcessTrailerInput(const char* input, size_t size) override {}
39 void ProcessHeaders(const BalsaHeaders& headers) override;
40 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 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 void ProcessChunkLength(size_t chunk_length) override {}
57 void ProcessChunkExtensions(const char* input, size_t size) override {}
58 void HeaderDone() override {}
59 void MessageDone() override;
60 void HandleHeaderError(BalsaFrame* framer) override;
61 void HandleHeaderWarning(BalsaFrame* framer) override {}
62 void HandleChunkingError(BalsaFrame* framer) override;
63 void HandleBodyError(BalsaFrame* framer) override;
65 void HandleError();
67 public:
68 void AddToOutputOrder(const MemCacheIter& mci);
69 BalsaFrame* spdy_framer() { return http_framer_; }
70 void set_is_request() override {}
71 const OutputOrdering& output_ordering() const { return output_ordering_; }
73 // SMInterface:
74 void InitSMInterface(SMInterface* sm_spdy_interface,
75 int32 server_idx) override;
76 void InitSMConnection(SMConnectionPoolInterface* connection_pool,
77 SMInterface* sm_interface,
78 EpollServer* epoll_server,
79 int fd,
80 std::string server_ip,
81 std::string server_port,
82 std::string remote_ip,
83 bool use_ssl) override;
84 size_t ProcessReadInput(const char* data, size_t len) override;
85 size_t ProcessWriteInput(const char* data, size_t len) override;
86 bool MessageFullyRead() const override;
87 void SetStreamID(uint32 stream_id) override;
88 bool Error() const override;
89 const char* ErrorAsString() const override;
90 void Reset() override;
91 void ResetForNewInterface(int32 server_idx) override {}
92 void ResetForNewConnection() override;
93 void Cleanup() override;
94 int PostAcceptHook() override;
96 void NewStream(uint32 stream_id,
97 uint32 priority,
98 const std::string& filename) override;
99 void SendEOF(uint32 stream_id) override;
100 void SendErrorNotFound(uint32 stream_id) override;
101 size_t SendSynStream(uint32 stream_id, const BalsaHeaders& headers) override;
102 size_t SendSynReply(uint32 stream_id, const BalsaHeaders& headers) override;
103 void SendDataFrame(uint32 stream_id,
104 const char* data,
105 int64 len,
106 uint32 flags,
107 bool compress) override;
109 private:
110 void SendEOFImpl(uint32 stream_id);
111 void SendErrorNotFoundImpl(uint32 stream_id);
112 void SendOKResponseImpl(uint32 stream_id, const std::string& output);
113 size_t SendSynReplyImpl(uint32 stream_id, const BalsaHeaders& headers);
114 size_t SendSynStreamImpl(uint32 stream_id, const BalsaHeaders& headers);
115 void SendDataFrameImpl(uint32 stream_id,
116 const char* data,
117 int64 len,
118 uint32 flags,
119 bool compress);
120 void EnqueueDataFrame(DataFrame* df);
121 void GetOutput() override;
123 private:
124 BalsaFrame* http_framer_;
125 BalsaHeaders headers_;
126 uint32 stream_id_;
127 int32 server_idx_;
129 SMConnection* connection_;
130 SMInterface* sm_spdy_interface_;
131 OutputList* output_list_;
132 OutputOrdering output_ordering_;
133 MemoryCache* memory_cache_;
134 FlipAcceptor* acceptor_;
137 } // namespace net
139 #endif // NET_TOOLS_FLIP_SERVER_HTTP_INTERFACE_H_