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

Side by Side Diff: net/dns/dns_transaction_unittest.cc

Issue 667923003: Standardize usage of virtual/override/final in net/ (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
« no previous file with comments | « net/dns/dns_transaction.cc ('k') | net/dns/host_resolver_impl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/dns/dns_transaction.h" 5 #include "net/dns/dns_transaction.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/memory/scoped_vector.h" 9 #include "base/memory/scoped_vector.h"
10 #include "base/rand_util.h" 10 #include "base/rand_util.h"
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 145
146 class TestSocketFactory; 146 class TestSocketFactory;
147 147
148 // A variant of MockUDPClientSocket which always fails to Connect. 148 // A variant of MockUDPClientSocket which always fails to Connect.
149 class FailingUDPClientSocket : public MockUDPClientSocket { 149 class FailingUDPClientSocket : public MockUDPClientSocket {
150 public: 150 public:
151 FailingUDPClientSocket(SocketDataProvider* data, 151 FailingUDPClientSocket(SocketDataProvider* data,
152 net::NetLog* net_log) 152 net::NetLog* net_log)
153 : MockUDPClientSocket(data, net_log) { 153 : MockUDPClientSocket(data, net_log) {
154 } 154 }
155 virtual ~FailingUDPClientSocket() {} 155 ~FailingUDPClientSocket() override {}
156 virtual int Connect(const IPEndPoint& endpoint) override { 156 int Connect(const IPEndPoint& endpoint) override {
157 return ERR_CONNECTION_REFUSED; 157 return ERR_CONNECTION_REFUSED;
158 } 158 }
159 159
160 private: 160 private:
161 DISALLOW_COPY_AND_ASSIGN(FailingUDPClientSocket); 161 DISALLOW_COPY_AND_ASSIGN(FailingUDPClientSocket);
162 }; 162 };
163 163
164 // A variant of MockUDPClientSocket which notifies the factory OnConnect. 164 // A variant of MockUDPClientSocket which notifies the factory OnConnect.
165 class TestUDPClientSocket : public MockUDPClientSocket { 165 class TestUDPClientSocket : public MockUDPClientSocket {
166 public: 166 public:
167 TestUDPClientSocket(TestSocketFactory* factory, 167 TestUDPClientSocket(TestSocketFactory* factory,
168 SocketDataProvider* data, 168 SocketDataProvider* data,
169 net::NetLog* net_log) 169 net::NetLog* net_log)
170 : MockUDPClientSocket(data, net_log), factory_(factory) { 170 : MockUDPClientSocket(data, net_log), factory_(factory) {
171 } 171 }
172 virtual ~TestUDPClientSocket() {} 172 ~TestUDPClientSocket() override {}
173 virtual int Connect(const IPEndPoint& endpoint) override; 173 int Connect(const IPEndPoint& endpoint) override;
174 174
175 private: 175 private:
176 TestSocketFactory* factory_; 176 TestSocketFactory* factory_;
177 177
178 DISALLOW_COPY_AND_ASSIGN(TestUDPClientSocket); 178 DISALLOW_COPY_AND_ASSIGN(TestUDPClientSocket);
179 }; 179 };
180 180
181 // Creates TestUDPClientSockets and keeps endpoints reported via OnConnect. 181 // Creates TestUDPClientSockets and keeps endpoints reported via OnConnect.
182 class TestSocketFactory : public MockClientSocketFactory { 182 class TestSocketFactory : public MockClientSocketFactory {
183 public: 183 public:
184 TestSocketFactory() : fail_next_socket_(false) {} 184 TestSocketFactory() : fail_next_socket_(false) {}
185 virtual ~TestSocketFactory() {} 185 ~TestSocketFactory() override {}
186 186
187 virtual scoped_ptr<DatagramClientSocket> CreateDatagramClientSocket( 187 scoped_ptr<DatagramClientSocket> CreateDatagramClientSocket(
188 DatagramSocket::BindType bind_type, 188 DatagramSocket::BindType bind_type,
189 const RandIntCallback& rand_int_cb, 189 const RandIntCallback& rand_int_cb,
190 net::NetLog* net_log, 190 net::NetLog* net_log,
191 const net::NetLog::Source& source) override { 191 const net::NetLog::Source& source) override {
192 if (fail_next_socket_) { 192 if (fail_next_socket_) {
193 fail_next_socket_ = false; 193 fail_next_socket_ = false;
194 return scoped_ptr<DatagramClientSocket>( 194 return scoped_ptr<DatagramClientSocket>(
195 new FailingUDPClientSocket(&empty_data_, net_log)); 195 new FailingUDPClientSocket(&empty_data_, net_log));
196 } 196 }
197 SocketDataProvider* data_provider = mock_data().GetNext(); 197 SocketDataProvider* data_provider = mock_data().GetNext();
(...skipping 804 matching lines...) Expand 10 before | Expand all | Expand 10 after
1002 config_.timeout = TestTimeouts::tiny_timeout(); 1002 config_.timeout = TestTimeouts::tiny_timeout();
1003 ConfigureFactory(); 1003 ConfigureFactory();
1004 1004
1005 TransactionHelper helper0(".", dns_protocol::kTypeA, ERR_INVALID_ARGUMENT); 1005 TransactionHelper helper0(".", dns_protocol::kTypeA, ERR_INVALID_ARGUMENT);
1006 EXPECT_TRUE(helper0.Run(transaction_factory_.get())); 1006 EXPECT_TRUE(helper0.Run(transaction_factory_.get()));
1007 } 1007 }
1008 1008
1009 } // namespace 1009 } // namespace
1010 1010
1011 } // namespace net 1011 } // namespace net
OLDNEW
« no previous file with comments | « net/dns/dns_transaction.cc ('k') | net/dns/host_resolver_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698