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

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

Issue 266243004: Clang format slam. Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 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
OLDNEW
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 13 matching lines...) Expand all
24 class SSLInfo; 24 class SSLInfo;
25 class WebSocketHandshakeRequestHandler; 25 class WebSocketHandshakeRequestHandler;
26 class WebSocketHandshakeResponseHandler; 26 class WebSocketHandshakeResponseHandler;
27 27
28 // WebSocket protocol specific job on SocketStream. 28 // WebSocket protocol specific job on SocketStream.
29 // It captures WebSocket handshake message and handles cookie operations. 29 // It captures WebSocket handshake message and handles cookie operations.
30 // Chrome security policy doesn't allow renderer process (except dev tools) 30 // Chrome security policy doesn't allow renderer process (except dev tools)
31 // see HttpOnly cookies, so it injects cookie header in handshake request and 31 // see HttpOnly cookies, so it injects cookie header in handshake request and
32 // strips set-cookie headers in handshake response. 32 // strips set-cookie headers in handshake response.
33 // TODO(ukai): refactor websocket.cc to use this. 33 // TODO(ukai): refactor websocket.cc to use this.
34 class NET_EXPORT WebSocketJob 34 class NET_EXPORT WebSocketJob : public SocketStreamJob,
35 : public SocketStreamJob, 35 public SocketStream::Delegate,
36 public SocketStream::Delegate, 36 public SpdyWebSocketStream::Delegate {
37 public SpdyWebSocketStream::Delegate {
38 public: 37 public:
39 // This is state of WebSocket, not SocketStream. 38 // This is state of WebSocket, not SocketStream.
40 enum State { 39 enum State {
41 INITIALIZED = -1, 40 INITIALIZED = -1,
42 CONNECTING = 0, 41 CONNECTING = 0,
43 OPEN = 1, 42 OPEN = 1,
44 CLOSING = 2, 43 CLOSING = 2,
45 CLOSED = 3, 44 CLOSED = 3,
46 }; 45 };
47 46
48 explicit WebSocketJob(SocketStream::Delegate* delegate); 47 explicit WebSocketJob(SocketStream::Delegate* delegate);
49 48
50 static void EnsureInit(); 49 static void EnsureInit();
51 50
52 // Enable or Disable WebSocket over SPDY feature. 51 // Enable or Disable WebSocket over SPDY feature.
53 // This function is intended to be called before I/O thread starts. 52 // This function is intended to be called before I/O thread starts.
54 static void set_websocket_over_spdy_enabled(bool enabled); 53 static void set_websocket_over_spdy_enabled(bool enabled);
55 54
56 State state() const { return state_; } 55 State state() const { return state_; }
57 virtual void Connect() OVERRIDE; 56 virtual void Connect() OVERRIDE;
58 virtual bool SendData(const char* data, int len) OVERRIDE; 57 virtual bool SendData(const char* data, int len) OVERRIDE;
59 virtual void Close() OVERRIDE; 58 virtual void Close() OVERRIDE;
60 virtual void RestartWithAuth(const AuthCredentials& credentials) OVERRIDE; 59 virtual void RestartWithAuth(const AuthCredentials& credentials) OVERRIDE;
61 virtual void DetachDelegate() OVERRIDE; 60 virtual void DetachDelegate() OVERRIDE;
62 61
63 // SocketStream::Delegate methods. 62 // SocketStream::Delegate methods.
64 virtual int OnStartOpenConnection( 63 virtual int OnStartOpenConnection(
65 SocketStream* socket, const CompletionCallback& callback) OVERRIDE; 64 SocketStream* socket,
65 const CompletionCallback& callback) OVERRIDE;
66 virtual void OnConnected(SocketStream* socket, 66 virtual void OnConnected(SocketStream* socket,
67 int max_pending_send_allowed) OVERRIDE; 67 int max_pending_send_allowed) OVERRIDE;
68 virtual void OnSentData(SocketStream* socket, int amount_sent) OVERRIDE; 68 virtual void OnSentData(SocketStream* socket, int amount_sent) OVERRIDE;
69 virtual void OnReceivedData(SocketStream* socket, 69 virtual void OnReceivedData(SocketStream* socket,
70 const char* data, 70 const char* data,
71 int len) OVERRIDE; 71 int len) OVERRIDE;
72 virtual void OnClose(SocketStream* socket) OVERRIDE; 72 virtual void OnClose(SocketStream* socket) OVERRIDE;
73 virtual void OnAuthRequired( 73 virtual void OnAuthRequired(SocketStream* socket,
74 SocketStream* socket, AuthChallengeInfo* auth_info) OVERRIDE; 74 AuthChallengeInfo* auth_info) OVERRIDE;
75 virtual void OnSSLCertificateError(SocketStream* socket, 75 virtual void OnSSLCertificateError(SocketStream* socket,
76 const SSLInfo& ssl_info, 76 const SSLInfo& ssl_info,
77 bool fatal) OVERRIDE; 77 bool fatal) OVERRIDE;
78 virtual void OnError(const SocketStream* socket, int error) OVERRIDE; 78 virtual void OnError(const SocketStream* socket, int error) OVERRIDE;
79 79
80 // SpdyWebSocketStream::Delegate methods. 80 // SpdyWebSocketStream::Delegate methods.
81 virtual void OnCreatedSpdyStream(int status) OVERRIDE; 81 virtual void OnCreatedSpdyStream(int status) OVERRIDE;
82 virtual void OnSentSpdyHeaders() OVERRIDE; 82 virtual void OnSentSpdyHeaders() OVERRIDE;
83 virtual void OnSpdyResponseHeadersUpdated( 83 virtual void OnSpdyResponseHeadersUpdated(
84 const SpdyHeaderBlock& response_headers) OVERRIDE; 84 const SpdyHeaderBlock& response_headers) OVERRIDE;
85 virtual void OnSentSpdyData(size_t bytes_sent) OVERRIDE; 85 virtual void OnSentSpdyData(size_t bytes_sent) OVERRIDE;
86 virtual void OnReceivedSpdyData(scoped_ptr<SpdyBuffer> buffer) OVERRIDE; 86 virtual void OnReceivedSpdyData(scoped_ptr<SpdyBuffer> buffer) OVERRIDE;
87 virtual void OnCloseSpdyStream() OVERRIDE; 87 virtual void OnCloseSpdyStream() OVERRIDE;
88 88
89 private: 89 private:
90 friend class WebSocketThrottle; 90 friend class WebSocketThrottle;
91 friend class WebSocketJobTest; 91 friend class WebSocketJobTest;
92 virtual ~WebSocketJob(); 92 virtual ~WebSocketJob();
93 93
94 bool SendHandshakeRequest(const char* data, int len); 94 bool SendHandshakeRequest(const char* data, int len);
95 void AddCookieHeaderAndSend(); 95 void AddCookieHeaderAndSend();
96 void LoadCookieCallback(const std::string& cookie); 96 void LoadCookieCallback(const std::string& cookie);
97 97
98 void OnSentHandshakeRequest(SocketStream* socket, int amount_sent); 98 void OnSentHandshakeRequest(SocketStream* socket, int amount_sent);
99 // Parses received data into handshake_response_. When finished receiving the 99 // Parses received data into handshake_response_. When finished receiving the
100 // response, calls SaveCookiesAndNotifyHeadersComplete(). 100 // response, calls SaveCookiesAndNotifyHeadersComplete().
101 void OnReceivedHandshakeResponse( 101 void OnReceivedHandshakeResponse(SocketStream* socket,
102 SocketStream* socket, const char* data, int len); 102 const char* data,
103 int len);
103 // Saves received cookies to the cookie store, and then notifies the 104 // Saves received cookies to the cookie store, and then notifies the
104 // delegate_ of completion of handshake. 105 // delegate_ of completion of handshake.
105 void SaveCookiesAndNotifyHeadersComplete(); 106 void SaveCookiesAndNotifyHeadersComplete();
106 void SaveNextCookie(); 107 void SaveNextCookie();
107 void OnCookieSaved(bool cookie_status); 108 void OnCookieSaved(bool cookie_status);
108 // Clears variables for handling cookies, rebuilds handshake string excluding 109 // Clears variables for handling cookies, rebuilds handshake string excluding
109 // cookies, and then pass the handshake string to delegate_. 110 // cookies, and then pass the handshake string to delegate_.
110 void NotifyHeadersComplete(); 111 void NotifyHeadersComplete();
111 void DoSendData(); 112 void DoSendData();
112 113
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 155
155 base::WeakPtrFactory<WebSocketJob> weak_ptr_factory_; 156 base::WeakPtrFactory<WebSocketJob> weak_ptr_factory_;
156 base::WeakPtrFactory<WebSocketJob> weak_ptr_factory_for_send_pending_; 157 base::WeakPtrFactory<WebSocketJob> weak_ptr_factory_for_send_pending_;
157 158
158 DISALLOW_COPY_AND_ASSIGN(WebSocketJob); 159 DISALLOW_COPY_AND_ASSIGN(WebSocketJob);
159 }; 160 };
160 161
161 } // namespace 162 } // namespace
162 163
163 #endif // NET_WEBSOCKETS_WEBSOCKET_JOB_H_ 164 #endif // NET_WEBSOCKETS_WEBSOCKET_JOB_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698