Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(323)

Side by Side Diff: net/websockets/websocket_job.h

Issue 6961007: WebSocket over SPDY. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: rebased Created 9 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/about_flags.cc ('k') | net/websockets/websocket_job.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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>
11 11
12 #include "base/string16.h" 12 #include "base/string16.h"
13 #include "net/base/address_list.h" 13 #include "net/base/address_list.h"
14 #include "net/base/completion_callback.h" 14 #include "net/base/completion_callback.h"
15 #include "net/socket_stream/socket_stream_job.h" 15 #include "net/socket_stream/socket_stream_job.h"
16 #include "net/spdy/spdy_websocket_stream.h"
16 17
17 class GURL; 18 class GURL;
18 19
19 namespace net { 20 namespace net {
20 21
21 class DrainableIOBuffer; 22 class DrainableIOBuffer;
22 class WebSocketFrameHandler; 23 class WebSocketFrameHandler;
23 class WebSocketHandshakeRequestHandler; 24 class WebSocketHandshakeRequestHandler;
24 class WebSocketHandshakeResponseHandler; 25 class WebSocketHandshakeResponseHandler;
25 26
26 // WebSocket protocol specific job on SocketStream. 27 // WebSocket protocol specific job on SocketStream.
27 // It captures WebSocket handshake message and handles cookie operations. 28 // It captures WebSocket handshake message and handles cookie operations.
28 // Chrome security policy doesn't allow renderer process (except dev tools) 29 // Chrome security policy doesn't allow renderer process (except dev tools)
29 // see HttpOnly cookies, so it injects cookie header in handshake request and 30 // see HttpOnly cookies, so it injects cookie header in handshake request and
30 // strips set-cookie headers in handshake response. 31 // strips set-cookie headers in handshake response.
31 // TODO(ukai): refactor websocket.cc to use this. 32 // TODO(ukai): refactor websocket.cc to use this.
32 class NET_API WebSocketJob 33 class NET_API WebSocketJob
33 : public SocketStreamJob, 34 : public SocketStreamJob,
34 public SocketStream::Delegate { 35 public SocketStream::Delegate,
36 public SpdyWebSocketStream::Delegate {
35 public: 37 public:
36 // This is state of WebSocket, not SocketStream. 38 // This is state of WebSocket, not SocketStream.
37 enum State { 39 enum State {
38 INITIALIZED = -1, 40 INITIALIZED = -1,
39 CONNECTING = 0, 41 CONNECTING = 0,
40 OPEN = 1, 42 OPEN = 1,
41 CLOSING = 2, 43 CLOSING = 2,
42 CLOSED = 3, 44 CLOSED = 3,
43 }; 45 };
44 46
(...skipping 18 matching lines...) Expand all
63 virtual int OnStartOpenConnection( 65 virtual int OnStartOpenConnection(
64 SocketStream* socket, CompletionCallback* callback); 66 SocketStream* socket, CompletionCallback* callback);
65 virtual void OnConnected(SocketStream* socket, int max_pending_send_allowed); 67 virtual void OnConnected(SocketStream* socket, int max_pending_send_allowed);
66 virtual void OnSentData(SocketStream* socket, int amount_sent); 68 virtual void OnSentData(SocketStream* socket, int amount_sent);
67 virtual void OnReceivedData(SocketStream* socket, const char* data, int len); 69 virtual void OnReceivedData(SocketStream* socket, const char* data, int len);
68 virtual void OnClose(SocketStream* socket); 70 virtual void OnClose(SocketStream* socket);
69 virtual void OnAuthRequired( 71 virtual void OnAuthRequired(
70 SocketStream* socket, AuthChallengeInfo* auth_info); 72 SocketStream* socket, AuthChallengeInfo* auth_info);
71 virtual void OnError(const SocketStream* socket, int error); 73 virtual void OnError(const SocketStream* socket, int error);
72 74
75 // SpdyWebSocketStream::Delegate methods.
76 virtual void OnCreatedSpdyStream(int status);
77 virtual void OnSentSpdyHeaders(int status);
78 virtual int OnReceivedSpdyResponseHeader(
79 const spdy::SpdyHeaderBlock& headers, int status);
80 virtual void OnSentSpdyData(int amount_sent);
81 virtual void OnReceivedSpdyData(const char* data, int length);
82 virtual void OnCloseSpdyStream();
83
73 private: 84 private:
74 friend class WebSocketThrottle; 85 friend class WebSocketThrottle;
75 friend class WebSocketJobTest; 86 friend class WebSocketJobTest;
76 virtual ~WebSocketJob(); 87 virtual ~WebSocketJob();
77 88
78 bool SendHandshakeRequest(const char* data, int len); 89 bool SendHandshakeRequest(const char* data, int len);
79 void AddCookieHeaderAndSend(); 90 void AddCookieHeaderAndSend();
80 91
81 void OnSentHandshakeRequest(SocketStream* socket, int amount_sent); 92 void OnSentHandshakeRequest(SocketStream* socket, int amount_sent);
82 void OnReceivedHandshakeResponse( 93 void OnReceivedHandshakeResponse(
(...skipping 28 matching lines...) Expand all
111 bool started_to_send_handshake_request_; 122 bool started_to_send_handshake_request_;
112 size_t handshake_request_sent_; 123 size_t handshake_request_sent_;
113 124
114 std::vector<std::string> response_cookies_; 125 std::vector<std::string> response_cookies_;
115 size_t response_cookies_save_index_; 126 size_t response_cookies_save_index_;
116 127
117 scoped_ptr<WebSocketFrameHandler> send_frame_handler_; 128 scoped_ptr<WebSocketFrameHandler> send_frame_handler_;
118 scoped_refptr<DrainableIOBuffer> current_buffer_; 129 scoped_refptr<DrainableIOBuffer> current_buffer_;
119 scoped_ptr<WebSocketFrameHandler> receive_frame_handler_; 130 scoped_ptr<WebSocketFrameHandler> receive_frame_handler_;
120 131
132 scoped_ptr<SpdyWebSocketStream> spdy_websocket_stream_;
133 std::string challenge_;
134
121 DISALLOW_COPY_AND_ASSIGN(WebSocketJob); 135 DISALLOW_COPY_AND_ASSIGN(WebSocketJob);
122 }; 136 };
123 137
124 } // namespace 138 } // namespace
125 139
126 #endif // NET_WEBSOCKETS_WEBSOCKET_JOB_H_ 140 #endif // NET_WEBSOCKETS_WEBSOCKET_JOB_H_
OLDNEW
« no previous file with comments | « chrome/browser/about_flags.cc ('k') | net/websockets/websocket_job.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698