summaryrefslogtreecommitdiffstats
path: root/net/websockets
diff options
context:
space:
mode:
authorBen Murdoch <benm@google.com>2010-11-18 18:32:45 +0000
committerBen Murdoch <benm@google.com>2010-11-18 18:38:07 +0000
commit513209b27ff55e2841eac0e4120199c23acce758 (patch)
treeaeba30bb08c5f47c57003544e378a377c297eee6 /net/websockets
parent164f7496de0fbee436b385a79ead9e3cb81a50c1 (diff)
downloadexternal_chromium-513209b27ff55e2841eac0e4120199c23acce758.zip
external_chromium-513209b27ff55e2841eac0e4120199c23acce758.tar.gz
external_chromium-513209b27ff55e2841eac0e4120199c23acce758.tar.bz2
Merge Chromium at r65505: Initial merge by git.
Change-Id: I31d8f1d8cd33caaf7f47ffa7350aef42d5fbdb45
Diffstat (limited to 'net/websockets')
-rw-r--r--net/websockets/websocket.cc6
-rw-r--r--net/websockets/websocket_job.cc7
-rw-r--r--net/websockets/websocket_throttle_unittest.cc42
3 files changed, 28 insertions, 27 deletions
diff --git a/net/websockets/websocket.cc b/net/websockets/websocket.cc
index 3bf1da8..f8d9eb9 100644
--- a/net/websockets/websocket.cc
+++ b/net/websockets/websocket.cc
@@ -80,7 +80,7 @@ void WebSocket::Send(const std::string& msg) {
*p = '\0';
memcpy(p + 1, msg.data(), msg.size());
*(p + 1 + msg.size()) = '\xff';
- pending_write_bufs_.push_back(buf);
+ pending_write_bufs_.push_back(make_scoped_refptr(buf));
SendPending();
}
@@ -172,7 +172,7 @@ void WebSocket::OnConnected(SocketStream* socket_stream,
const std::string msg = handshake_->CreateClientHandshakeMessage();
IOBufferWithSize* buf = new IOBufferWithSize(msg.size());
memcpy(buf->data(), msg.data(), msg.size());
- pending_write_bufs_.push_back(buf);
+ pending_write_bufs_.push_back(make_scoped_refptr(buf));
origin_loop_->PostTask(FROM_HERE,
NewRunnableMethod(this, &WebSocket::SendPending));
}
@@ -430,7 +430,7 @@ void WebSocket::StartClosingHandshake() {
client_closing_handshake_ = true;
IOBufferWithSize* buf = new IOBufferWithSize(2);
memcpy(buf->data(), kClosingFrame, 2);
- pending_write_bufs_.push_back(buf);
+ pending_write_bufs_.push_back(make_scoped_refptr(buf));
SendPending();
}
diff --git a/net/websockets/websocket_job.cc b/net/websockets/websocket_job.cc
index 64af45b..a1e2dde 100644
--- a/net/websockets/websocket_job.cc
+++ b/net/websockets/websocket_job.cc
@@ -313,7 +313,8 @@ void WebSocketJob::OnCanGetCookiesCompleted(int policy) {
handshake_request_sent_ = 0;
socket_->net_log()->AddEvent(
NetLog::TYPE_WEB_SOCKET_SEND_REQUEST_HEADERS,
- new NetLogWebSocketHandshakeParameter(handshake_request));
+ make_scoped_refptr(
+ new NetLogWebSocketHandshakeParameter(handshake_request)));
socket_->SendData(handshake_request.data(),
handshake_request.size());
}
@@ -354,8 +355,8 @@ void WebSocketJob::OnReceivedHandshakeResponse(
// handshake message is completed.
socket_->net_log()->AddEvent(
NetLog::TYPE_WEB_SOCKET_READ_RESPONSE_HEADERS,
- new NetLogWebSocketHandshakeParameter(
- handshake_response_->GetRawResponse()));
+ make_scoped_refptr(new NetLogWebSocketHandshakeParameter(
+ handshake_response_->GetRawResponse())));
if (len - response_length > 0) {
// If we received extra data, it should be frame data.
receive_frame_handler_->AppendData(data + response_length,
diff --git a/net/websockets/websocket_throttle_unittest.cc b/net/websockets/websocket_throttle_unittest.cc
index c4bf59f..7eb18fa 100644
--- a/net/websockets/websocket_throttle_unittest.cc
+++ b/net/websockets/websocket_throttle_unittest.cc
@@ -83,9 +83,9 @@ TEST_F(WebSocketThrottleTest, Throttle) {
struct addrinfo* addr = AddAddr(1, 2, 3, 4, NULL);
addr = AddAddr(1, 2, 3, 5, addr);
addr = AddAddr(1, 2, 3, 6, addr);
- scoped_refptr<WebSocketJob> w1 = new WebSocketJob(&delegate);
- scoped_refptr<SocketStream> s1 =
- new SocketStream(GURL("ws://host1/"), w1.get());
+ scoped_refptr<WebSocketJob> w1(new WebSocketJob(&delegate));
+ scoped_refptr<SocketStream> s1(
+ new SocketStream(GURL("ws://host1/"), w1.get()));
w1->InitSocketStream(s1.get());
WebSocketThrottleTest::MockSocketStreamConnect(s1, addr);
DeleteAddrInfo(addr);
@@ -103,9 +103,9 @@ TEST_F(WebSocketThrottleTest, Throttle) {
// For host2: 1.2.3.4
addr = AddAddr(1, 2, 3, 4, NULL);
- scoped_refptr<WebSocketJob> w2 = new WebSocketJob(&delegate);
- scoped_refptr<SocketStream> s2 =
- new SocketStream(GURL("ws://host2/"), w2.get());
+ scoped_refptr<WebSocketJob> w2(new WebSocketJob(&delegate));
+ scoped_refptr<SocketStream> s2(
+ new SocketStream(GURL("ws://host2/"), w2.get()));
w2->InitSocketStream(s2.get());
WebSocketThrottleTest::MockSocketStreamConnect(s2, addr);
DeleteAddrInfo(addr);
@@ -122,9 +122,9 @@ TEST_F(WebSocketThrottleTest, Throttle) {
// For host3: 1.2.3.5
addr = AddAddr(1, 2, 3, 5, NULL);
- scoped_refptr<WebSocketJob> w3 = new WebSocketJob(&delegate);
- scoped_refptr<SocketStream> s3 =
- new SocketStream(GURL("ws://host3/"), w3.get());
+ scoped_refptr<WebSocketJob> w3(new WebSocketJob(&delegate));
+ scoped_refptr<SocketStream> s3(
+ new SocketStream(GURL("ws://host3/"), w3.get()));
w3->InitSocketStream(s3.get());
WebSocketThrottleTest::MockSocketStreamConnect(s3, addr);
DeleteAddrInfo(addr);
@@ -141,9 +141,9 @@ TEST_F(WebSocketThrottleTest, Throttle) {
// For host4: 1.2.3.4, 1.2.3.6
addr = AddAddr(1, 2, 3, 4, NULL);
addr = AddAddr(1, 2, 3, 6, addr);
- scoped_refptr<WebSocketJob> w4 = new WebSocketJob(&delegate);
- scoped_refptr<SocketStream> s4 =
- new SocketStream(GURL("ws://host4/"), w4.get());
+ scoped_refptr<WebSocketJob> w4(new WebSocketJob(&delegate));
+ scoped_refptr<SocketStream> s4(
+ new SocketStream(GURL("ws://host4/"), w4.get()));
w4->InitSocketStream(s4.get());
WebSocketThrottleTest::MockSocketStreamConnect(s4, addr);
DeleteAddrInfo(addr);
@@ -159,9 +159,9 @@ TEST_F(WebSocketThrottleTest, Throttle) {
// For host5: 1.2.3.6
addr = AddAddr(1, 2, 3, 6, NULL);
- scoped_refptr<WebSocketJob> w5 = new WebSocketJob(&delegate);
- scoped_refptr<SocketStream> s5 =
- new SocketStream(GURL("ws://host5/"), w5.get());
+ scoped_refptr<WebSocketJob> w5(new WebSocketJob(&delegate));
+ scoped_refptr<SocketStream> s5(
+ new SocketStream(GURL("ws://host5/"), w5.get()));
w5->InitSocketStream(s5.get());
WebSocketThrottleTest::MockSocketStreamConnect(s5, addr);
DeleteAddrInfo(addr);
@@ -177,9 +177,9 @@ TEST_F(WebSocketThrottleTest, Throttle) {
// For host6: 1.2.3.6
addr = AddAddr(1, 2, 3, 6, NULL);
- scoped_refptr<WebSocketJob> w6 = new WebSocketJob(&delegate);
- scoped_refptr<SocketStream> s6 =
- new SocketStream(GURL("ws://host6/"), w6.get());
+ scoped_refptr<WebSocketJob> w6(new WebSocketJob(&delegate));
+ scoped_refptr<SocketStream> s6(
+ new SocketStream(GURL("ws://host6/"), w6.get()));
w6->InitSocketStream(s6.get());
WebSocketThrottleTest::MockSocketStreamConnect(s6, addr);
DeleteAddrInfo(addr);
@@ -286,9 +286,9 @@ TEST_F(WebSocketThrottleTest, NoThrottleForDuplicateAddress) {
// For localhost: 127.0.0.1, 127.0.0.1
struct addrinfo* addr = AddAddr(127, 0, 0, 1, NULL);
addr = AddAddr(127, 0, 0, 1, addr);
- scoped_refptr<WebSocketJob> w1 = new WebSocketJob(&delegate);
- scoped_refptr<SocketStream> s1 =
- new SocketStream(GURL("ws://localhost/"), w1.get());
+ scoped_refptr<WebSocketJob> w1(new WebSocketJob(&delegate));
+ scoped_refptr<SocketStream> s1(
+ new SocketStream(GURL("ws://localhost/"), w1.get()));
w1->InitSocketStream(s1.get());
WebSocketThrottleTest::MockSocketStreamConnect(s1, addr);
DeleteAddrInfo(addr);