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_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 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 28 matching lines...) Expand all Loading... |
39 CONNECTING = 0, | 39 CONNECTING = 0, |
40 OPEN = 1, | 40 OPEN = 1, |
41 CLOSING = 2, | 41 CLOSING = 2, |
42 CLOSED = 3, | 42 CLOSED = 3, |
43 }; | 43 }; |
44 | 44 |
45 explicit WebSocketJob(SocketStream::Delegate* delegate); | 45 explicit WebSocketJob(SocketStream::Delegate* delegate); |
46 | 46 |
47 static void EnsureInit(); | 47 static void EnsureInit(); |
48 | 48 |
| 49 // Enable or Disable WebSocket over SPDY feature. |
| 50 // This function is intended to be called before I/O thread starts. |
| 51 static void set_websocket_over_spdy_enabled(bool enabled); |
| 52 |
49 State state() const { return state_; } | 53 State state() const { return state_; } |
50 virtual void Connect(); | 54 virtual void Connect(); |
51 virtual bool SendData(const char* data, int len); | 55 virtual bool SendData(const char* data, int len); |
52 virtual void Close(); | 56 virtual void Close(); |
53 virtual void RestartWithAuth( | 57 virtual void RestartWithAuth( |
54 const string16& username, | 58 const string16& username, |
55 const string16& password); | 59 const string16& password); |
56 virtual void DetachDelegate(); | 60 virtual void DetachDelegate(); |
57 | 61 |
58 // SocketStream::Delegate methods. | 62 // SocketStream::Delegate methods. |
(...skipping 28 matching lines...) Expand all Loading... |
87 GURL GetURLForCookies() const; | 91 GURL GetURLForCookies() const; |
88 | 92 |
89 const AddressList& address_list() const; | 93 const AddressList& address_list() const; |
90 void SetWaiting(); | 94 void SetWaiting(); |
91 bool IsWaiting() const; | 95 bool IsWaiting() const; |
92 void Wakeup(); | 96 void Wakeup(); |
93 void DoCallback(); | 97 void DoCallback(); |
94 | 98 |
95 void SendPending(); | 99 void SendPending(); |
96 | 100 |
| 101 static bool websocket_over_spdy_enabled_; |
| 102 |
97 SocketStream::Delegate* delegate_; | 103 SocketStream::Delegate* delegate_; |
98 State state_; | 104 State state_; |
99 bool waiting_; | 105 bool waiting_; |
100 AddressList addresses_; | 106 AddressList addresses_; |
101 CompletionCallback* callback_; // for throttling. | 107 CompletionCallback* callback_; // for throttling. |
102 | 108 |
103 scoped_ptr<WebSocketHandshakeRequestHandler> handshake_request_; | 109 scoped_ptr<WebSocketHandshakeRequestHandler> handshake_request_; |
104 scoped_ptr<WebSocketHandshakeResponseHandler> handshake_response_; | 110 scoped_ptr<WebSocketHandshakeResponseHandler> handshake_response_; |
105 | 111 |
106 size_t handshake_request_sent_; | 112 size_t handshake_request_sent_; |
107 | 113 |
108 std::vector<std::string> response_cookies_; | 114 std::vector<std::string> response_cookies_; |
109 size_t response_cookies_save_index_; | 115 size_t response_cookies_save_index_; |
110 | 116 |
111 scoped_ptr<WebSocketFrameHandler> send_frame_handler_; | 117 scoped_ptr<WebSocketFrameHandler> send_frame_handler_; |
112 scoped_refptr<DrainableIOBuffer> current_buffer_; | 118 scoped_refptr<DrainableIOBuffer> current_buffer_; |
113 scoped_ptr<WebSocketFrameHandler> receive_frame_handler_; | 119 scoped_ptr<WebSocketFrameHandler> receive_frame_handler_; |
114 | 120 |
115 DISALLOW_COPY_AND_ASSIGN(WebSocketJob); | 121 DISALLOW_COPY_AND_ASSIGN(WebSocketJob); |
116 }; | 122 }; |
117 | 123 |
118 } // namespace | 124 } // namespace |
119 | 125 |
120 #endif // NET_WEBSOCKETS_WEBSOCKET_JOB_H_ | 126 #endif // NET_WEBSOCKETS_WEBSOCKET_JOB_H_ |
OLD | NEW |