summaryrefslogtreecommitdiffstats
path: root/net/websockets/websocket_channel.cc
diff options
context:
space:
mode:
authorricea@chromium.org <ricea@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-10-08 02:27:51 +0000
committerricea@chromium.org <ricea@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-10-08 02:27:51 +0000
commitdab33ebca0faeda44104cd87e9cd6e631194b0b2 (patch)
tree40c0b926ae9b2c0bf89d611b4fb67f34bc72fe86 /net/websockets/websocket_channel.cc
parent72643a5fc7badce86d7763267196e51d8e744573 (diff)
downloadchromium_src-dab33ebca0faeda44104cd87e9cd6e631194b0b2.zip
chromium_src-dab33ebca0faeda44104cd87e9cd6e631194b0b2.tar.gz
chromium_src-dab33ebca0faeda44104cd87e9cd6e631194b0b2.tar.bz2
Create WebSocketDispatcherHost and WebSocketHost classes. WebSocketDispatcherHost creates, destroys and routes messages to WebSocketHost objects. WebSocketHost objects own and communicate with net::WebSocketChannel.
Input validation is delegated to net::WebSocketChannel. Unit tests seem to be unfashionable for these sorts of glue classes, so I haven't created any. The code to insert WebSocketDispatcherHost as a message filter is not included in this CL, so WebSocket IPCs are still unhandled and this CL changes no behaviour. There is a known bug in this CL that the WebSocketChannel can be deleted while it is looping through incoming messages, causing a use-after-free error. This will be fixed in a followup CL. See design for fix at https://docs.google.com/document/d/1fMxcEFiVj-H5vmuxhPqsxJAl98GS6_yZ-wqB6j9Wmy0/pub BUG=301353 Review URL: https://codereview.chromium.org/12637007 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@227435 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/websockets/websocket_channel.cc')
-rw-r--r--net/websockets/websocket_channel.cc27
1 files changed, 15 insertions, 12 deletions
diff --git a/net/websockets/websocket_channel.cc b/net/websockets/websocket_channel.cc
index d2150d4..c370bd7 100644
--- a/net/websockets/websocket_channel.cc
+++ b/net/websockets/websocket_channel.cc
@@ -82,10 +82,10 @@ class WebSocketChannel::ConnectDelegate
};
WebSocketChannel::WebSocketChannel(
- const GURL& socket_url,
- scoped_ptr<WebSocketEventInterface> event_interface)
- : socket_url_(socket_url),
- event_interface_(event_interface.Pass()),
+ scoped_ptr<WebSocketEventInterface> event_interface,
+ URLRequestContext* url_request_context)
+ : event_interface_(event_interface.Pass()),
+ url_request_context_(url_request_context),
send_quota_low_water_mark_(kDefaultSendQuotaLowWaterMark),
send_quota_high_water_mark_(kDefaultSendQuotaHighWaterMark),
current_send_quota_(0),
@@ -99,14 +99,14 @@ WebSocketChannel::~WebSocketChannel() {
}
void WebSocketChannel::SendAddChannelRequest(
+ const GURL& socket_url,
const std::vector<std::string>& requested_subprotocols,
- const GURL& origin,
- URLRequestContext* url_request_context) {
+ const GURL& origin) {
// Delegate to the tested version.
SendAddChannelRequestWithFactory(
+ socket_url,
requested_subprotocols,
origin,
- url_request_context,
base::Bind(&WebSocketStream::CreateAndConnectStream));
}
@@ -186,26 +186,29 @@ void WebSocketChannel::StartClosingHandshake(uint16 code,
}
void WebSocketChannel::SendAddChannelRequestForTesting(
+ const GURL& socket_url,
const std::vector<std::string>& requested_subprotocols,
const GURL& origin,
- URLRequestContext* url_request_context,
const WebSocketStreamFactory& factory) {
- SendAddChannelRequestWithFactory(
- requested_subprotocols, origin, url_request_context, factory);
+ SendAddChannelRequestWithFactory(socket_url,
+ requested_subprotocols,
+ origin,
+ factory);
}
void WebSocketChannel::SendAddChannelRequestWithFactory(
+ const GURL& socket_url,
const std::vector<std::string>& requested_subprotocols,
const GURL& origin,
- URLRequestContext* url_request_context,
const WebSocketStreamFactory& factory) {
DCHECK_EQ(FRESHLY_CONSTRUCTED, state_);
+ socket_url_ = socket_url;
scoped_ptr<WebSocketStream::ConnectDelegate> connect_delegate(
new ConnectDelegate(this));
stream_request_ = factory.Run(socket_url_,
requested_subprotocols,
origin,
- url_request_context,
+ url_request_context_,
BoundNetLog(),
connect_delegate.Pass());
state_ = CONNECTING;