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_SM_CONNECTION_H_ | 5 #ifndef NET_TOOLS_FLIP_SERVER_SM_CONNECTION_H_ |
6 #define NET_TOOLS_FLIP_SERVER_SM_CONNECTION_H_ | 6 #define NET_TOOLS_FLIP_SERVER_SM_CONNECTION_H_ |
7 | 7 |
8 #include <arpa/inet.h> // in_addr_t | 8 #include <arpa/inet.h> // in_addr_t |
9 #include <time.h> | 9 #include <time.h> |
10 | 10 |
(...skipping 26 matching lines...) Expand all Loading... |
37 DataFrame() : data(NULL), size(0), delete_when_done(false), index(0) {} | 37 DataFrame() : data(NULL), size(0), delete_when_done(false), index(0) {} |
38 virtual ~DataFrame(); | 38 virtual ~DataFrame(); |
39 }; | 39 }; |
40 | 40 |
41 typedef std::list<DataFrame*> OutputList; | 41 typedef std::list<DataFrame*> OutputList; |
42 | 42 |
43 class SMConnection : public SMConnectionInterface, | 43 class SMConnection : public SMConnectionInterface, |
44 public EpollCallbackInterface, | 44 public EpollCallbackInterface, |
45 public NotifierInterface { | 45 public NotifierInterface { |
46 public: | 46 public: |
47 virtual ~SMConnection(); | 47 ~SMConnection() override; |
48 | 48 |
49 static SMConnection* NewSMConnection(EpollServer* epoll_server, | 49 static SMConnection* NewSMConnection(EpollServer* epoll_server, |
50 SSLState* ssl_state, | 50 SSLState* ssl_state, |
51 MemoryCache* memory_cache, | 51 MemoryCache* memory_cache, |
52 FlipAcceptor* acceptor, | 52 FlipAcceptor* acceptor, |
53 std::string log_prefix); | 53 std::string log_prefix); |
54 | 54 |
55 // TODO(mbelshe): Make these private. | 55 // TODO(mbelshe): Make these private. |
56 time_t last_read_time_; | 56 time_t last_read_time_; |
57 std::string server_ip_; | 57 std::string server_ip_; |
58 std::string server_port_; | 58 std::string server_port_; |
59 | 59 |
60 virtual EpollServer* epoll_server() override; | 60 EpollServer* epoll_server() override; |
61 OutputList* output_list() { return &output_list_; } | 61 OutputList* output_list() { return &output_list_; } |
62 MemoryCache* memory_cache() { return memory_cache_; } | 62 MemoryCache* memory_cache() { return memory_cache_; } |
63 virtual void ReadyToSend() override; | 63 void ReadyToSend() override; |
64 void EnqueueDataFrame(DataFrame* df); | 64 void EnqueueDataFrame(DataFrame* df); |
65 | 65 |
66 int fd() const { return fd_; } | 66 int fd() const { return fd_; } |
67 bool initialized() const { return initialized_; } | 67 bool initialized() const { return initialized_; } |
68 std::string client_ip() const { return client_ip_; } | 68 std::string client_ip() const { return client_ip_; } |
69 | 69 |
70 virtual void InitSMConnection(SMConnectionPoolInterface* connection_pool, | 70 virtual void InitSMConnection(SMConnectionPoolInterface* connection_pool, |
71 SMInterface* sm_interface, | 71 SMInterface* sm_interface, |
72 EpollServer* epoll_server, | 72 EpollServer* epoll_server, |
73 int fd, | 73 int fd, |
74 std::string server_ip, | 74 std::string server_ip, |
75 std::string server_port, | 75 std::string server_port, |
76 std::string remote_ip, | 76 std::string remote_ip, |
77 bool use_ssl); | 77 bool use_ssl); |
78 | 78 |
79 void CorkSocket(); | 79 void CorkSocket(); |
80 void UncorkSocket(); | 80 void UncorkSocket(); |
81 | 81 |
82 int Send(const char* data, int len, int flags); | 82 int Send(const char* data, int len, int flags); |
83 | 83 |
84 // EpollCallbackInterface interface. | 84 // EpollCallbackInterface interface. |
85 virtual void OnRegistration(EpollServer* eps, | 85 void OnRegistration(EpollServer* eps, int fd, int event_mask) override; |
86 int fd, | 86 void OnModification(int fd, int event_mask) override {} |
87 int event_mask) override; | 87 void OnEvent(int fd, EpollEvent* event) override; |
88 virtual void OnModification(int fd, int event_mask) override {} | 88 void OnUnregistration(int fd, bool replaced) override; |
89 virtual void OnEvent(int fd, EpollEvent* event) override; | 89 void OnShutdown(EpollServer* eps, int fd) override; |
90 virtual void OnUnregistration(int fd, bool replaced) override; | |
91 virtual void OnShutdown(EpollServer* eps, int fd) override; | |
92 | 90 |
93 // NotifierInterface interface. | 91 // NotifierInterface interface. |
94 virtual void Notify() override {} | 92 void Notify() override {} |
95 | 93 |
96 void Cleanup(const char* cleanup); | 94 void Cleanup(const char* cleanup); |
97 | 95 |
98 // Flag indicating if we should force spdy on all connections. | 96 // Flag indicating if we should force spdy on all connections. |
99 static bool force_spdy() { return force_spdy_; } | 97 static bool force_spdy() { return force_spdy_; } |
100 static void set_force_spdy(bool value) { force_spdy_ = value; } | 98 static void set_force_spdy(bool value) { force_spdy_ = value; } |
101 | 99 |
102 private: | 100 private: |
103 // Decide if SPDY was negotiated. | 101 // Decide if SPDY was negotiated. |
104 bool WasSpdyNegotiated(SpdyMajorVersion* version_negotiated); | 102 bool WasSpdyNegotiated(SpdyMajorVersion* version_negotiated); |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 size_t max_bytes_sent_per_dowrite_; | 154 size_t max_bytes_sent_per_dowrite_; |
157 | 155 |
158 SSL* ssl_; | 156 SSL* ssl_; |
159 | 157 |
160 static bool force_spdy_; | 158 static bool force_spdy_; |
161 }; | 159 }; |
162 | 160 |
163 } // namespace net | 161 } // namespace net |
164 | 162 |
165 #endif // NET_TOOLS_FLIP_SERVER_SM_CONNECTION_H_ | 163 #endif // NET_TOOLS_FLIP_SERVER_SM_CONNECTION_H_ |
OLD | NEW |