OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_WEBSOCKETS_WEBSOCKET_JOB_H_ | 5 #ifndef NET_WEBSOCKETS_WEBSOCKET_JOB_H_ |
6 #define NET_WEBSOCKETS_WEBSOCKET_JOB_H_ | 6 #define NET_WEBSOCKETS_WEBSOCKET_JOB_H_ |
7 | 7 |
8 #include <deque> | 8 #include <deque> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 CONNECTING = 0, | 42 CONNECTING = 0, |
43 OPEN = 1, | 43 OPEN = 1, |
44 CLOSING = 2, | 44 CLOSING = 2, |
45 CLOSED = 3, | 45 CLOSED = 3, |
46 }; | 46 }; |
47 | 47 |
48 explicit WebSocketJob(SocketStream::Delegate* delegate); | 48 explicit WebSocketJob(SocketStream::Delegate* delegate); |
49 | 49 |
50 static void EnsureInit(); | 50 static void EnsureInit(); |
51 | 51 |
52 // Enable or Disable WebSocket over SPDY feature. | |
53 // This function is intended to be called before I/O thread starts. | |
54 static void set_websocket_over_spdy_enabled(bool enabled); | |
55 | |
56 State state() const { return state_; } | 52 State state() const { return state_; } |
57 virtual void Connect() OVERRIDE; | 53 virtual void Connect() OVERRIDE; |
58 virtual bool SendData(const char* data, int len) OVERRIDE; | 54 virtual bool SendData(const char* data, int len) OVERRIDE; |
59 virtual void Close() OVERRIDE; | 55 virtual void Close() OVERRIDE; |
60 virtual void RestartWithAuth(const AuthCredentials& credentials) OVERRIDE; | 56 virtual void RestartWithAuth(const AuthCredentials& credentials) OVERRIDE; |
61 virtual void DetachDelegate() OVERRIDE; | 57 virtual void DetachDelegate() OVERRIDE; |
62 | 58 |
63 // SocketStream::Delegate methods. | 59 // SocketStream::Delegate methods. |
64 virtual int OnStartOpenConnection( | 60 virtual int OnStartOpenConnection( |
65 SocketStream* socket, const CompletionCallback& callback) OVERRIDE; | 61 SocketStream* socket, const CompletionCallback& callback) OVERRIDE; |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 void SetWaiting(); | 113 void SetWaiting(); |
118 bool IsWaiting() const; | 114 bool IsWaiting() const; |
119 void Wakeup(); | 115 void Wakeup(); |
120 void RetryPendingIO(); | 116 void RetryPendingIO(); |
121 void CompleteIO(int result); | 117 void CompleteIO(int result); |
122 | 118 |
123 bool SendDataInternal(const char* data, int length); | 119 bool SendDataInternal(const char* data, int length); |
124 void CloseInternal(); | 120 void CloseInternal(); |
125 void SendPending(); | 121 void SendPending(); |
126 | 122 |
127 static bool websocket_over_spdy_enabled_; | |
128 | |
129 SocketStream::Delegate* delegate_; | 123 SocketStream::Delegate* delegate_; |
130 State state_; | 124 State state_; |
131 bool waiting_; | 125 bool waiting_; |
132 AddressList addresses_; | 126 AddressList addresses_; |
133 CompletionCallback callback_; // for throttling. | 127 CompletionCallback callback_; // for throttling. |
134 | 128 |
135 scoped_ptr<WebSocketHandshakeRequestHandler> handshake_request_; | 129 scoped_ptr<WebSocketHandshakeRequestHandler> handshake_request_; |
136 scoped_ptr<WebSocketHandshakeResponseHandler> handshake_response_; | 130 scoped_ptr<WebSocketHandshakeResponseHandler> handshake_response_; |
137 | 131 |
138 bool started_to_send_handshake_request_; | 132 bool started_to_send_handshake_request_; |
(...skipping 15 matching lines...) Expand all Loading... |
154 | 148 |
155 base::WeakPtrFactory<WebSocketJob> weak_ptr_factory_; | 149 base::WeakPtrFactory<WebSocketJob> weak_ptr_factory_; |
156 base::WeakPtrFactory<WebSocketJob> weak_ptr_factory_for_send_pending_; | 150 base::WeakPtrFactory<WebSocketJob> weak_ptr_factory_for_send_pending_; |
157 | 151 |
158 DISALLOW_COPY_AND_ASSIGN(WebSocketJob); | 152 DISALLOW_COPY_AND_ASSIGN(WebSocketJob); |
159 }; | 153 }; |
160 | 154 |
161 } // namespace | 155 } // namespace |
162 | 156 |
163 #endif // NET_WEBSOCKETS_WEBSOCKET_JOB_H_ | 157 #endif // NET_WEBSOCKETS_WEBSOCKET_JOB_H_ |
OLD | NEW |