Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(254)

Side by Side Diff: content/browser/renderer_host/p2p/socket_host_tcp_server_unittest.cc

Issue 667943003: Standardize usage of virtual/override/final in content/browser/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "content/browser/renderer_host/p2p/socket_host_tcp_server.h" 5 #include "content/browser/renderer_host/p2p/socket_host_tcp_server.h"
6 6
7 #include <list> 7 #include <list>
8 8
9 #include "content/browser/renderer_host/p2p/socket_host_tcp.h" 9 #include "content/browser/renderer_host/p2p/socket_host_tcp.h"
10 #include "content/browser/renderer_host/p2p/socket_host_test_utils.h" 10 #include "content/browser/renderer_host/p2p/socket_host_test_utils.h"
11 #include "net/base/completion_callback.h" 11 #include "net/base/completion_callback.h"
12 #include "testing/gmock/include/gmock/gmock.h" 12 #include "testing/gmock/include/gmock/gmock.h"
13 #include "testing/gtest/include/gtest/gtest.h" 13 #include "testing/gtest/include/gtest/gtest.h"
14 14
15 using ::testing::_; 15 using ::testing::_;
16 using ::testing::DeleteArg; 16 using ::testing::DeleteArg;
17 using ::testing::DoAll; 17 using ::testing::DoAll;
18 using ::testing::Return; 18 using ::testing::Return;
19 19
20 namespace { 20 namespace {
21 21
22 class FakeServerSocket : public net::ServerSocket { 22 class FakeServerSocket : public net::ServerSocket {
23 public: 23 public:
24 FakeServerSocket() 24 FakeServerSocket()
25 : listening_(false), 25 : listening_(false),
26 accept_socket_(NULL) { 26 accept_socket_(NULL) {
27 } 27 }
28 28
29 virtual ~FakeServerSocket() {} 29 ~FakeServerSocket() override {}
30 30
31 bool listening() { return listening_; } 31 bool listening() { return listening_; }
32 32
33 void AddIncoming(net::StreamSocket* socket) { 33 void AddIncoming(net::StreamSocket* socket) {
34 if (!accept_callback_.is_null()) { 34 if (!accept_callback_.is_null()) {
35 DCHECK(incoming_sockets_.empty()); 35 DCHECK(incoming_sockets_.empty());
36 accept_socket_->reset(socket); 36 accept_socket_->reset(socket);
37 accept_socket_ = NULL; 37 accept_socket_ = NULL;
38 38
39 // This copy is necessary because this implementation of ServerSocket 39 // This copy is necessary because this implementation of ServerSocket
40 // bases logic on the null-ness of |accept_callback_| in the bound 40 // bases logic on the null-ness of |accept_callback_| in the bound
41 // callback. 41 // callback.
42 net::CompletionCallback cb = accept_callback_; 42 net::CompletionCallback cb = accept_callback_;
43 accept_callback_.Reset(); 43 accept_callback_.Reset();
44 cb.Run(net::OK); 44 cb.Run(net::OK);
45 } else { 45 } else {
46 incoming_sockets_.push_back(socket); 46 incoming_sockets_.push_back(socket);
47 } 47 }
48 } 48 }
49 49
50 virtual int Listen(const net::IPEndPoint& address, int backlog) override { 50 int Listen(const net::IPEndPoint& address, int backlog) override {
51 local_address_ = address; 51 local_address_ = address;
52 listening_ = true; 52 listening_ = true;
53 return net::OK; 53 return net::OK;
54 } 54 }
55 55
56 virtual int GetLocalAddress(net::IPEndPoint* address) const override { 56 int GetLocalAddress(net::IPEndPoint* address) const override {
57 *address = local_address_; 57 *address = local_address_;
58 return net::OK; 58 return net::OK;
59 } 59 }
60 60
61 virtual int Accept(scoped_ptr<net::StreamSocket>* socket, 61 int Accept(scoped_ptr<net::StreamSocket>* socket,
62 const net::CompletionCallback& callback) override { 62 const net::CompletionCallback& callback) override {
63 DCHECK(socket); 63 DCHECK(socket);
64 if (!incoming_sockets_.empty()) { 64 if (!incoming_sockets_.empty()) {
65 socket->reset(incoming_sockets_.front()); 65 socket->reset(incoming_sockets_.front());
66 incoming_sockets_.pop_front(); 66 incoming_sockets_.pop_front();
67 return net::OK; 67 return net::OK;
68 } else { 68 } else {
69 accept_socket_ = socket; 69 accept_socket_ = socket;
70 accept_callback_ = callback; 70 accept_callback_ = callback;
71 return net::ERR_IO_PENDING; 71 return net::ERR_IO_PENDING;
72 } 72 }
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 EXPECT_EQ(incoming1, GetSocketFormTcpSocketHost( 165 EXPECT_EQ(incoming1, GetSocketFormTcpSocketHost(
166 reinterpret_cast<P2PSocketHostTcp*>(new_host1.get()))); 166 reinterpret_cast<P2PSocketHostTcp*>(new_host1.get())));
167 scoped_ptr<P2PSocketHost> new_host2( 167 scoped_ptr<P2PSocketHost> new_host2(
168 socket_host_->AcceptIncomingTcpConnection(addr2, kAcceptedSocketId2)); 168 socket_host_->AcceptIncomingTcpConnection(addr2, kAcceptedSocketId2));
169 ASSERT_TRUE(new_host2.get() != NULL); 169 ASSERT_TRUE(new_host2.get() != NULL);
170 EXPECT_EQ(incoming2, GetSocketFormTcpSocketHost( 170 EXPECT_EQ(incoming2, GetSocketFormTcpSocketHost(
171 reinterpret_cast<P2PSocketHostTcp*>(new_host2.get()))); 171 reinterpret_cast<P2PSocketHostTcp*>(new_host2.get())));
172 } 172 }
173 173
174 } // namespace content 174 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/p2p/socket_host_tcp_server.h ('k') | content/browser/renderer_host/p2p/socket_host_test_utils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698