| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "net/socket/websocket_endpoint_lock_manager.h" | 5 #include "net/socket/websocket_endpoint_lock_manager.h" |
| 6 | 6 |
| 7 #include "net/base/net_errors.h" | 7 #include "net/base/net_errors.h" |
| 8 #include "net/socket/next_proto.h" | 8 #include "net/socket/next_proto.h" |
| 9 #include "net/socket/socket_test_util.h" | 9 #include "net/socket/socket_test_util.h" |
| 10 #include "net/socket/stream_socket.h" | 10 #include "net/socket/stream_socket.h" |
| 11 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
| 12 | 12 |
| 13 namespace net { | 13 namespace net { |
| 14 | 14 |
| 15 namespace { | 15 namespace { |
| 16 | 16 |
| 17 // A StreamSocket implementation with no functionality at all. | 17 // A StreamSocket implementation with no functionality at all. |
| 18 // TODO(ricea): If you need to use this in another file, please move it to | 18 // TODO(ricea): If you need to use this in another file, please move it to |
| 19 // socket_test_util.h. | 19 // socket_test_util.h. |
| 20 class FakeStreamSocket : public StreamSocket { | 20 class FakeStreamSocket : public StreamSocket { |
| 21 public: | 21 public: |
| 22 FakeStreamSocket() {} | 22 FakeStreamSocket() {} |
| 23 | 23 |
| 24 // StreamSocket implementation | 24 // StreamSocket implementation |
| 25 virtual int Connect(const CompletionCallback& callback) override { | 25 int Connect(const CompletionCallback& callback) override { |
| 26 return ERR_FAILED; | 26 return ERR_FAILED; |
| 27 } | 27 } |
| 28 | 28 |
| 29 virtual void Disconnect() override { return; } | 29 void Disconnect() override { return; } |
| 30 | 30 |
| 31 virtual bool IsConnected() const override { return false; } | 31 bool IsConnected() const override { return false; } |
| 32 | 32 |
| 33 virtual bool IsConnectedAndIdle() const override { return false; } | 33 bool IsConnectedAndIdle() const override { return false; } |
| 34 | 34 |
| 35 virtual int GetPeerAddress(IPEndPoint* address) const override { | 35 int GetPeerAddress(IPEndPoint* address) const override { return ERR_FAILED; } |
| 36 |
| 37 int GetLocalAddress(IPEndPoint* address) const override { return ERR_FAILED; } |
| 38 |
| 39 const BoundNetLog& NetLog() const override { return bound_net_log_; } |
| 40 |
| 41 void SetSubresourceSpeculation() override { return; } |
| 42 void SetOmniboxSpeculation() override { return; } |
| 43 |
| 44 bool WasEverUsed() const override { return false; } |
| 45 |
| 46 bool UsingTCPFastOpen() const override { return false; } |
| 47 |
| 48 bool WasNpnNegotiated() const override { return false; } |
| 49 |
| 50 NextProto GetNegotiatedProtocol() const override { return kProtoUnknown; } |
| 51 |
| 52 bool GetSSLInfo(SSLInfo* ssl_info) override { return false; } |
| 53 |
| 54 // Socket implementation |
| 55 int Read(IOBuffer* buf, |
| 56 int buf_len, |
| 57 const CompletionCallback& callback) override { |
| 36 return ERR_FAILED; | 58 return ERR_FAILED; |
| 37 } | 59 } |
| 38 | 60 |
| 39 virtual int GetLocalAddress(IPEndPoint* address) const override { | 61 int Write(IOBuffer* buf, |
| 62 int buf_len, |
| 63 const CompletionCallback& callback) override { |
| 40 return ERR_FAILED; | 64 return ERR_FAILED; |
| 41 } | 65 } |
| 42 | 66 |
| 43 virtual const BoundNetLog& NetLog() const override { return bound_net_log_; } | 67 int SetReceiveBufferSize(int32 size) override { return ERR_FAILED; } |
| 44 | 68 |
| 45 virtual void SetSubresourceSpeculation() override { return; } | 69 int SetSendBufferSize(int32 size) override { return ERR_FAILED; } |
| 46 virtual void SetOmniboxSpeculation() override { return; } | |
| 47 | |
| 48 virtual bool WasEverUsed() const override { return false; } | |
| 49 | |
| 50 virtual bool UsingTCPFastOpen() const override { return false; } | |
| 51 | |
| 52 virtual bool WasNpnNegotiated() const override { return false; } | |
| 53 | |
| 54 virtual NextProto GetNegotiatedProtocol() const override { | |
| 55 return kProtoUnknown; | |
| 56 } | |
| 57 | |
| 58 virtual bool GetSSLInfo(SSLInfo* ssl_info) override { return false; } | |
| 59 | |
| 60 // Socket implementation | |
| 61 virtual int Read(IOBuffer* buf, | |
| 62 int buf_len, | |
| 63 const CompletionCallback& callback) override { | |
| 64 return ERR_FAILED; | |
| 65 } | |
| 66 | |
| 67 virtual int Write(IOBuffer* buf, | |
| 68 int buf_len, | |
| 69 const CompletionCallback& callback) override { | |
| 70 return ERR_FAILED; | |
| 71 } | |
| 72 | |
| 73 virtual int SetReceiveBufferSize(int32 size) override { return ERR_FAILED; } | |
| 74 | |
| 75 virtual int SetSendBufferSize(int32 size) override { return ERR_FAILED; } | |
| 76 | 70 |
| 77 private: | 71 private: |
| 78 BoundNetLog bound_net_log_; | 72 BoundNetLog bound_net_log_; |
| 79 | 73 |
| 80 DISALLOW_COPY_AND_ASSIGN(FakeStreamSocket); | 74 DISALLOW_COPY_AND_ASSIGN(FakeStreamSocket); |
| 81 }; | 75 }; |
| 82 | 76 |
| 83 class FakeWaiter : public WebSocketEndpointLockManager::Waiter { | 77 class FakeWaiter : public WebSocketEndpointLockManager::Waiter { |
| 84 public: | 78 public: |
| 85 FakeWaiter() : called_(false) {} | 79 FakeWaiter() : called_(false) {} |
| 86 | 80 |
| 87 virtual void GotEndpointLock() override { | 81 void GotEndpointLock() override { |
| 88 CHECK(!called_); | 82 CHECK(!called_); |
| 89 called_ = true; | 83 called_ = true; |
| 90 } | 84 } |
| 91 | 85 |
| 92 bool called() const { return called_; } | 86 bool called() const { return called_; } |
| 93 | 87 |
| 94 private: | 88 private: |
| 95 bool called_; | 89 bool called_; |
| 96 }; | 90 }; |
| 97 | 91 |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 221 instance()->UnlockEndpoint(DummyEndpoint()); | 215 instance()->UnlockEndpoint(DummyEndpoint()); |
| 222 EXPECT_TRUE(waiters[1].called()); | 216 EXPECT_TRUE(waiters[1].called()); |
| 223 instance()->RememberSocket(&dummy_sockets[1], DummyEndpoint()); | 217 instance()->RememberSocket(&dummy_sockets[1], DummyEndpoint()); |
| 224 | 218 |
| 225 UnlockDummyEndpoint(1); | 219 UnlockDummyEndpoint(1); |
| 226 } | 220 } |
| 227 | 221 |
| 228 } // namespace | 222 } // namespace |
| 229 | 223 |
| 230 } // namespace net | 224 } // namespace net |
| OLD | NEW |