diff options
author | ukai@chromium.org <ukai@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-17 05:09:22 +0000 |
---|---|---|
committer | ukai@chromium.org <ukai@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-17 05:09:22 +0000 |
commit | af63c908603f8a2f58f69167129f819d5d30820c (patch) | |
tree | dcc8658fe7baa5f4ab5f3038595a0ca4747e8ac9 /net/websockets/websocket.h | |
parent | 24d3500b4139d481adb2b4bde98433f0dd8a56b0 (diff) | |
download | chromium_src-af63c908603f8a2f58f69167129f819d5d30820c.zip chromium_src-af63c908603f8a2f58f69167129f819d5d30820c.tar.gz chromium_src-af63c908603f8a2f58f69167129f819d5d30820c.tar.bz2 |
Refactor WebSocketHandshake out of WebSocket.
Make similar code structure with WebKit.
Add unittest for WebSocketHandshake.
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/783005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@41810 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/websockets/websocket.h')
-rw-r--r-- | net/websockets/websocket.h | 35 |
1 files changed, 3 insertions, 32 deletions
diff --git a/net/websockets/websocket.h b/net/websockets/websocket.h index 0cf95db..5e58391 100644 --- a/net/websockets/websocket.h +++ b/net/websockets/websocket.h @@ -15,6 +15,7 @@ #include <string> #include "base/ref_counted.h" +#include "base/scoped_ptr.h" #include "googleurl/src/gurl.h" #include "net/base/io_buffer.h" #include "net/socket_stream/socket_stream.h" @@ -26,9 +27,9 @@ namespace net { class ClientSocketFactory; class HostResolver; -class HttpResponseHeaders; class WebSocket; +class WebSocketHandshake; // Delegate methods will be called on the same message loop as // WebSocket is constructed. @@ -74,7 +75,6 @@ class WebSocket : public base::RefCountedThreadSafe<WebSocket>, ~Request() {} const GURL& url() const { return url_; } - bool is_secure() const; const std::string& protocol() const { return protocol_; } const std::string& origin() const { return origin_; } const std::string& location() const { return location_; } @@ -95,9 +95,6 @@ class WebSocket : public base::RefCountedThreadSafe<WebSocket>, return client_socket_factory_; } - // Creates the client handshake message from |this|. - std::string CreateClientHandshakeMessage() const; - private: GURL url_; std::string protocol_; @@ -147,9 +144,6 @@ class WebSocket : public base::RefCountedThreadSafe<WebSocket>, virtual void OnError(const SocketStream* socket, int error); private: - enum Mode { - MODE_INCOMPLETE, MODE_NORMAL, MODE_AUTHENTICATE, - }; typedef std::deque< scoped_refptr<IOBufferWithSize> > PendingDataQueue; friend class WebSocketTest; @@ -157,24 +151,6 @@ class WebSocket : public base::RefCountedThreadSafe<WebSocket>, friend class base::RefCountedThreadSafe<WebSocket>; virtual ~WebSocket(); - // Checks handshake. - // Prerequisite: Server handshake message is received in |current_read_buf_|. - // Returns number of bytes for server handshake message, - // or negative if server handshake message is not received fully yet. - int CheckHandshake(); - - // Processes server handshake message, parsed as |headers|, and updates - // |ws_origin_|, |ws_location_| and |ws_protocol_|. - // Returns true if it's ok. - // Returns false otherwise (e.g. duplicate WebSocket-Origin: header, etc.) - bool ProcessHeaders(const HttpResponseHeaders& headers); - - // Checks |ws_origin_|, |ws_location_| and |ws_protocol_| are valid - // against |request_|. - // Returns true if it's ok. - // Returns false otherwise (e.g. origin mismatch, etc.) - bool CheckResponseHeaders() const; - // Sends pending data in |current_write_buf_| and/or |pending_write_bufs_|. void SendPending(); @@ -197,16 +173,11 @@ class WebSocket : public base::RefCountedThreadSafe<WebSocket>, void DoError(int error); State ready_state_; - Mode mode_; scoped_ptr<Request> request_; + scoped_ptr<WebSocketHandshake> handshake_; WebSocketDelegate* delegate_; MessageLoop* origin_loop_; - // Handshake messages that server sent. - std::string ws_origin_; - std::string ws_location_; - std::string ws_protocol_; - scoped_refptr<SocketStream> socket_stream_; int max_pending_send_allowed_; |