| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 #include <string> | 5 #include <string> |
| 6 | 6 |
| 7 #include "base/message_loop.h" | 7 #include "base/message_loop.h" |
| 8 #include "googleurl/src/gurl.h" | 8 #include "googleurl/src/gurl.h" |
| 9 #include "net/base/address_list.h" | 9 #include "net/base/address_list.h" |
| 10 #include "net/base/sys_addrinfo.h" | 10 #include "net/base/sys_addrinfo.h" |
| 11 #include "net/base/test_completion_callback.h" | 11 #include "net/base/test_completion_callback.h" |
| 12 #include "net/socket_stream/socket_stream.h" | 12 #include "net/socket_stream/socket_stream.h" |
| 13 #include "net/websockets/websocket_job.h" | 13 #include "net/websockets/websocket_job.h" |
| 14 #include "net/websockets/websocket_throttle.h" | 14 #include "net/websockets/websocket_throttle.h" |
| 15 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
| 16 #include "testing/platform_test.h" | 16 #include "testing/platform_test.h" |
| 17 | 17 |
| 18 class DummySocketStreamDelegate : public net::SocketStream::Delegate { | 18 class DummySocketStreamDelegate : public net::SocketStream::Delegate { |
| 19 public: | 19 public: |
| 20 DummySocketStreamDelegate() {} | 20 DummySocketStreamDelegate() {} |
| 21 virtual ~DummySocketStreamDelegate() {} | 21 virtual ~DummySocketStreamDelegate() {} |
| 22 virtual void OnConnected( | 22 virtual void OnConnected( |
| 23 net::SocketStream* socket, int max_pending_send_allowed) {} | 23 net::SocketStream* socket, int max_pending_send_allowed) {} |
| 24 virtual void OnSentData(net::SocketStream* socket, int amount_sent) {} | 24 virtual void OnSentData(net::SocketStream* socket, int amount_sent) {} |
| 25 virtual void OnReceivedData(net::SocketStream* socket, | 25 virtual void OnReceivedData(net::SocketStream* socket, |
| 26 const char* data, int len) {} | 26 const char* data, int len) {} |
| 27 virtual void OnClose(net::SocketStream* socket) {} | 27 virtual void OnClose(net::SocketStream* socket) {} |
| 28 virtual void OnError(const net::SocketStream* socket, int error) {} |
| 28 }; | 29 }; |
| 29 | 30 |
| 30 namespace net { | 31 namespace net { |
| 31 | 32 |
| 32 class WebSocketThrottleTest : public PlatformTest { | 33 class WebSocketThrottleTest : public PlatformTest { |
| 33 protected: | 34 protected: |
| 34 struct addrinfo *AddAddr(int a1, int a2, int a3, int a4, | 35 struct addrinfo *AddAddr(int a1, int a2, int a3, int a4, |
| 35 struct addrinfo* next) { | 36 struct addrinfo* next) { |
| 36 struct addrinfo* addrinfo = new struct addrinfo; | 37 struct addrinfo* addrinfo = new struct addrinfo; |
| 37 memset(addrinfo, 0, sizeof(struct addrinfo)); | 38 memset(addrinfo, 0, sizeof(struct addrinfo)); |
| (...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 299 EXPECT_EQ(OK, w1->OnStartOpenConnection(s1, &callback_s1)); | 300 EXPECT_EQ(OK, w1->OnStartOpenConnection(s1, &callback_s1)); |
| 300 | 301 |
| 301 DVLOG(1) << "socket1 close"; | 302 DVLOG(1) << "socket1 close"; |
| 302 w1->OnClose(s1.get()); | 303 w1->OnClose(s1.get()); |
| 303 s1->DetachDelegate(); | 304 s1->DetachDelegate(); |
| 304 DVLOG(1) << "Done"; | 305 DVLOG(1) << "Done"; |
| 305 MessageLoopForIO::current()->RunAllPending(); | 306 MessageLoopForIO::current()->RunAllPending(); |
| 306 } | 307 } |
| 307 | 308 |
| 308 } | 309 } |
| OLD | NEW |