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 virtual 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 virtual void Disconnect() override { return; } |
30 | 30 |
31 virtual bool IsConnected() const OVERRIDE { return false; } | 31 virtual bool IsConnected() const override { return false; } |
32 | 32 |
33 virtual bool IsConnectedAndIdle() const OVERRIDE { return false; } | 33 virtual bool IsConnectedAndIdle() const override { return false; } |
34 | 34 |
35 virtual int GetPeerAddress(IPEndPoint* address) const OVERRIDE { | 35 virtual int GetPeerAddress(IPEndPoint* address) const override { |
36 return ERR_FAILED; | 36 return ERR_FAILED; |
37 } | 37 } |
38 | 38 |
39 virtual int GetLocalAddress(IPEndPoint* address) const OVERRIDE { | 39 virtual int GetLocalAddress(IPEndPoint* address) const override { |
40 return ERR_FAILED; | 40 return ERR_FAILED; |
41 } | 41 } |
42 | 42 |
43 virtual const BoundNetLog& NetLog() const OVERRIDE { return bound_net_log_; } | 43 virtual const BoundNetLog& NetLog() const override { return bound_net_log_; } |
44 | 44 |
45 virtual void SetSubresourceSpeculation() OVERRIDE { return; } | 45 virtual void SetSubresourceSpeculation() override { return; } |
46 virtual void SetOmniboxSpeculation() OVERRIDE { return; } | 46 virtual void SetOmniboxSpeculation() override { return; } |
47 | 47 |
48 virtual bool WasEverUsed() const OVERRIDE { return false; } | 48 virtual bool WasEverUsed() const override { return false; } |
49 | 49 |
50 virtual bool UsingTCPFastOpen() const OVERRIDE { return false; } | 50 virtual bool UsingTCPFastOpen() const override { return false; } |
51 | 51 |
52 virtual bool WasNpnNegotiated() const OVERRIDE { return false; } | 52 virtual bool WasNpnNegotiated() const override { return false; } |
53 | 53 |
54 virtual NextProto GetNegotiatedProtocol() const OVERRIDE { | 54 virtual NextProto GetNegotiatedProtocol() const override { |
55 return kProtoUnknown; | 55 return kProtoUnknown; |
56 } | 56 } |
57 | 57 |
58 virtual bool GetSSLInfo(SSLInfo* ssl_info) OVERRIDE { return false; } | 58 virtual bool GetSSLInfo(SSLInfo* ssl_info) override { return false; } |
59 | 59 |
60 // Socket implementation | 60 // Socket implementation |
61 virtual int Read(IOBuffer* buf, | 61 virtual int Read(IOBuffer* buf, |
62 int buf_len, | 62 int buf_len, |
63 const CompletionCallback& callback) OVERRIDE { | 63 const CompletionCallback& callback) override { |
64 return ERR_FAILED; | 64 return ERR_FAILED; |
65 } | 65 } |
66 | 66 |
67 virtual int Write(IOBuffer* buf, | 67 virtual int Write(IOBuffer* buf, |
68 int buf_len, | 68 int buf_len, |
69 const CompletionCallback& callback) OVERRIDE { | 69 const CompletionCallback& callback) override { |
70 return ERR_FAILED; | 70 return ERR_FAILED; |
71 } | 71 } |
72 | 72 |
73 virtual int SetReceiveBufferSize(int32 size) OVERRIDE { return ERR_FAILED; } | 73 virtual int SetReceiveBufferSize(int32 size) override { return ERR_FAILED; } |
74 | 74 |
75 virtual int SetSendBufferSize(int32 size) OVERRIDE { return ERR_FAILED; } | 75 virtual int SetSendBufferSize(int32 size) override { return ERR_FAILED; } |
76 | 76 |
77 private: | 77 private: |
78 BoundNetLog bound_net_log_; | 78 BoundNetLog bound_net_log_; |
79 | 79 |
80 DISALLOW_COPY_AND_ASSIGN(FakeStreamSocket); | 80 DISALLOW_COPY_AND_ASSIGN(FakeStreamSocket); |
81 }; | 81 }; |
82 | 82 |
83 class FakeWaiter : public WebSocketEndpointLockManager::Waiter { | 83 class FakeWaiter : public WebSocketEndpointLockManager::Waiter { |
84 public: | 84 public: |
85 FakeWaiter() : called_(false) {} | 85 FakeWaiter() : called_(false) {} |
86 | 86 |
87 virtual void GotEndpointLock() OVERRIDE { | 87 virtual void GotEndpointLock() override { |
88 CHECK(!called_); | 88 CHECK(!called_); |
89 called_ = true; | 89 called_ = true; |
90 } | 90 } |
91 | 91 |
92 bool called() const { return called_; } | 92 bool called() const { return called_; } |
93 | 93 |
94 private: | 94 private: |
95 bool called_; | 95 bool called_; |
96 }; | 96 }; |
97 | 97 |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
221 instance()->UnlockEndpoint(DummyEndpoint()); | 221 instance()->UnlockEndpoint(DummyEndpoint()); |
222 EXPECT_TRUE(waiters[1].called()); | 222 EXPECT_TRUE(waiters[1].called()); |
223 instance()->RememberSocket(&dummy_sockets[1], DummyEndpoint()); | 223 instance()->RememberSocket(&dummy_sockets[1], DummyEndpoint()); |
224 | 224 |
225 UnlockDummyEndpoint(1); | 225 UnlockDummyEndpoint(1); |
226 } | 226 } |
227 | 227 |
228 } // namespace | 228 } // namespace |
229 | 229 |
230 } // namespace net | 230 } // namespace net |
OLD | NEW |