OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 21 matching lines...) Expand all Loading... |
32 class WebSocketJob : public SocketStreamJob, public SocketStream::Delegate { | 32 class WebSocketJob : public SocketStreamJob, public SocketStream::Delegate { |
33 public: | 33 public: |
34 // This is state of WebSocket, not SocketStream. | 34 // This is state of WebSocket, not SocketStream. |
35 enum State { | 35 enum State { |
36 INITIALIZED = -1, | 36 INITIALIZED = -1, |
37 CONNECTING = 0, | 37 CONNECTING = 0, |
38 OPEN = 1, | 38 OPEN = 1, |
39 CLOSING = 2, | 39 CLOSING = 2, |
40 CLOSED = 3, | 40 CLOSED = 3, |
41 }; | 41 }; |
42 static void EnsureInit(); | |
43 | 42 |
44 explicit WebSocketJob(SocketStream::Delegate* delegate); | 43 explicit WebSocketJob(SocketStream::Delegate* delegate); |
45 | 44 |
| 45 static void EnsureInit(); |
| 46 |
46 State state() const { return state_; } | 47 State state() const { return state_; } |
47 virtual void Connect(); | 48 virtual void Connect(); |
48 virtual bool SendData(const char* data, int len); | 49 virtual bool SendData(const char* data, int len); |
49 virtual void Close(); | 50 virtual void Close(); |
50 virtual void RestartWithAuth( | 51 virtual void RestartWithAuth( |
51 const string16& username, | 52 const string16& username, |
52 const string16& password); | 53 const string16& password); |
53 virtual void DetachDelegate(); | 54 virtual void DetachDelegate(); |
54 | 55 |
55 // SocketStream::Delegate methods. | 56 // SocketStream::Delegate methods. |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 scoped_ptr<WebSocketFrameHandler> send_frame_handler_; | 114 scoped_ptr<WebSocketFrameHandler> send_frame_handler_; |
114 scoped_refptr<DrainableIOBuffer> current_buffer_; | 115 scoped_refptr<DrainableIOBuffer> current_buffer_; |
115 scoped_ptr<WebSocketFrameHandler> receive_frame_handler_; | 116 scoped_ptr<WebSocketFrameHandler> receive_frame_handler_; |
116 | 117 |
117 DISALLOW_COPY_AND_ASSIGN(WebSocketJob); | 118 DISALLOW_COPY_AND_ASSIGN(WebSocketJob); |
118 }; | 119 }; |
119 | 120 |
120 } // namespace | 121 } // namespace |
121 | 122 |
122 #endif // NET_WEBSOCKETS_WEBSOCKET_JOB_H_ | 123 #endif // NET_WEBSOCKETS_WEBSOCKET_JOB_H_ |
OLD | NEW |