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

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

Issue 2102993002: Fix WebSocket to set first party for cookies (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Update testRunner calls to setBlockThirdPartyCookies() Created 4 years, 5 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
« no previous file with comments | « content/common/websocket_messages.h ('k') | net/websockets/websocket_channel.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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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_CHANNEL_H_ 5 #ifndef NET_WEBSOCKETS_WEBSOCKET_CHANNEL_H_
6 #define NET_WEBSOCKETS_WEBSOCKET_CHANNEL_H_ 6 #define NET_WEBSOCKETS_WEBSOCKET_CHANNEL_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <memory> 10 #include <memory>
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 // definition; please see the RFC at http://tools.ietf.org/html/rfc6455 for 43 // definition; please see the RFC at http://tools.ietf.org/html/rfc6455 for
44 // clarification. 44 // clarification.
45 class NET_EXPORT WebSocketChannel { 45 class NET_EXPORT WebSocketChannel {
46 public: 46 public:
47 // The type of a WebSocketStream creator callback. Must match the signature of 47 // The type of a WebSocketStream creator callback. Must match the signature of
48 // WebSocketStream::CreateAndConnectStream(). 48 // WebSocketStream::CreateAndConnectStream().
49 typedef base::Callback<std::unique_ptr<WebSocketStreamRequest>( 49 typedef base::Callback<std::unique_ptr<WebSocketStreamRequest>(
50 const GURL&, 50 const GURL&,
51 const std::vector<std::string>&, 51 const std::vector<std::string>&,
52 const url::Origin&, 52 const url::Origin&,
53 const GURL&,
53 const std::string&, 54 const std::string&,
54 URLRequestContext*, 55 URLRequestContext*,
55 const BoundNetLog&, 56 const BoundNetLog&,
56 std::unique_ptr<WebSocketStream::ConnectDelegate>)> 57 std::unique_ptr<WebSocketStream::ConnectDelegate>)>
57 WebSocketStreamCreator; 58 WebSocketStreamCreator;
58 59
59 // Methods which return a value of type ChannelState may delete |this|. If the 60 // Methods which return a value of type ChannelState may delete |this|. If the
60 // return value is CHANNEL_DELETED, then the caller must return without making 61 // return value is CHANNEL_DELETED, then the caller must return without making
61 // any further access to member variables or methods. 62 // any further access to member variables or methods.
62 using ChannelState = WebSocketEventInterface::ChannelState; 63 using ChannelState = WebSocketEventInterface::ChannelState;
63 64
64 // Creates a new WebSocketChannel in an idle state. 65 // Creates a new WebSocketChannel in an idle state.
65 // SendAddChannelRequest() must be called immediately afterwards to start the 66 // SendAddChannelRequest() must be called immediately afterwards to start the
66 // connection process. 67 // connection process.
67 WebSocketChannel(std::unique_ptr<WebSocketEventInterface> event_interface, 68 WebSocketChannel(std::unique_ptr<WebSocketEventInterface> event_interface,
68 URLRequestContext* url_request_context); 69 URLRequestContext* url_request_context);
69 virtual ~WebSocketChannel(); 70 virtual ~WebSocketChannel();
70 71
71 // Starts the connection process. 72 // Starts the connection process.
72 void SendAddChannelRequest( 73 void SendAddChannelRequest(
73 const GURL& socket_url, 74 const GURL& socket_url,
74 const std::vector<std::string>& requested_protocols, 75 const std::vector<std::string>& requested_protocols,
75 const url::Origin& origin, 76 const url::Origin& origin,
77 const GURL& first_party_for_cookies,
76 const std::string& additional_headers); 78 const std::string& additional_headers);
77 79
78 // Sends a data frame to the remote side. It is the responsibility of the 80 // Sends a data frame to the remote side. It is the responsibility of the
79 // caller to ensure that they have sufficient send quota to send this data, 81 // caller to ensure that they have sufficient send quota to send this data,
80 // otherwise the connection will be closed without sending. |fin| indicates 82 // otherwise the connection will be closed without sending. |fin| indicates
81 // the last frame in a message, equivalent to "FIN" as specified in section 83 // the last frame in a message, equivalent to "FIN" as specified in section
82 // 5.2 of RFC6455. |data| is the "Payload Data". If |op_code| is kOpCodeText, 84 // 5.2 of RFC6455. |data| is the "Payload Data". If |op_code| is kOpCodeText,
83 // or it is kOpCodeContinuation and the type the message is Text, then |data| 85 // or it is kOpCodeContinuation and the type the message is Text, then |data|
84 // must be a chunk of a valid UTF-8 message, however there is no requirement 86 // must be a chunk of a valid UTF-8 message, however there is no requirement
85 // for |data| to be split on character boundaries. Calling SendFrame may 87 // for |data| to be split on character boundaries. Calling SendFrame may
(...skipping 30 matching lines...) Expand all
116 // valid for the execution of the current Task or until SendFrame() is called, 118 // valid for the execution of the current Task or until SendFrame() is called,
117 // whichever happens sooner. 119 // whichever happens sooner.
118 int current_send_quota() const { return current_send_quota_; } 120 int current_send_quota() const { return current_send_quota_; }
119 121
120 // Starts the connection process, using a specified creator callback rather 122 // Starts the connection process, using a specified creator callback rather
121 // than the default. This is exposed for testing. 123 // than the default. This is exposed for testing.
122 void SendAddChannelRequestForTesting( 124 void SendAddChannelRequestForTesting(
123 const GURL& socket_url, 125 const GURL& socket_url,
124 const std::vector<std::string>& requested_protocols, 126 const std::vector<std::string>& requested_protocols,
125 const url::Origin& origin, 127 const url::Origin& origin,
128 const GURL& first_party_for_cookies,
126 const std::string& additional_headers, 129 const std::string& additional_headers,
127 const WebSocketStreamCreator& creator); 130 const WebSocketStreamCreator& creator);
128 131
129 // The default timout for the closing handshake is a sensible value (see 132 // The default timout for the closing handshake is a sensible value (see
130 // kClosingHandshakeTimeoutSeconds in websocket_channel.cc). However, we can 133 // kClosingHandshakeTimeoutSeconds in websocket_channel.cc). However, we can
131 // set it to a very small value for testing purposes. 134 // set it to a very small value for testing purposes.
132 void SetClosingHandshakeTimeoutForTesting(base::TimeDelta delay); 135 void SetClosingHandshakeTimeoutForTesting(base::TimeDelta delay);
133 136
134 // The default timout for the underlying connection close is a sensible value 137 // The default timout for the underlying connection close is a sensible value
135 // (see kUnderlyingConnectionCloseTimeoutSeconds in websocket_channel.cc). 138 // (see kUnderlyingConnectionCloseTimeoutSeconds in websocket_channel.cc).
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 // interface with the implementation of those methods, and because the 212 // interface with the implementation of those methods, and because the
210 // lifetime of a WebSocketChannel is longer than the lifetime of the 213 // lifetime of a WebSocketChannel is longer than the lifetime of the
211 // connection process. 214 // connection process.
212 class ConnectDelegate; 215 class ConnectDelegate;
213 216
214 // Starts the connection process, using the supplied creator callback. 217 // Starts the connection process, using the supplied creator callback.
215 void SendAddChannelRequestWithSuppliedCreator( 218 void SendAddChannelRequestWithSuppliedCreator(
216 const GURL& socket_url, 219 const GURL& socket_url,
217 const std::vector<std::string>& requested_protocols, 220 const std::vector<std::string>& requested_protocols,
218 const url::Origin& origin, 221 const url::Origin& origin,
222 const GURL& first_party_for_cookies,
219 const std::string& additional_headers, 223 const std::string& additional_headers,
220 const WebSocketStreamCreator& creator); 224 const WebSocketStreamCreator& creator);
221 225
222 // Success callback from WebSocketStream::CreateAndConnectStream(). Reports 226 // Success callback from WebSocketStream::CreateAndConnectStream(). Reports
223 // success to the event interface. May delete |this|. 227 // success to the event interface. May delete |this|.
224 void OnConnectSuccess(std::unique_ptr<WebSocketStream> stream); 228 void OnConnectSuccess(std::unique_ptr<WebSocketStream> stream);
225 229
226 // Failure callback from WebSocketStream::CreateAndConnectStream(). Reports 230 // Failure callback from WebSocketStream::CreateAndConnectStream(). Reports
227 // failure to the event interface. May delete |this|. 231 // failure to the event interface. May delete |this|.
228 void OnConnectFailure(const std::string& message); 232 void OnConnectFailure(const std::string& message);
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
441 // For UMA. The time when OnConnectSuccess() method was called and |stream_| 445 // For UMA. The time when OnConnectSuccess() method was called and |stream_|
442 // was set. 446 // was set.
443 base::TimeTicks established_on_; 447 base::TimeTicks established_on_;
444 448
445 DISALLOW_COPY_AND_ASSIGN(WebSocketChannel); 449 DISALLOW_COPY_AND_ASSIGN(WebSocketChannel);
446 }; 450 };
447 451
448 } // namespace net 452 } // namespace net
449 453
450 #endif // NET_WEBSOCKETS_WEBSOCKET_CHANNEL_H_ 454 #endif // NET_WEBSOCKETS_WEBSOCKET_CHANNEL_H_
OLDNEW
« no previous file with comments | « content/common/websocket_messages.h ('k') | net/websockets/websocket_channel.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698