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

Side by Side Diff: net/dns/address_sorter_posix_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/address_sorter_posix.h ('k') | net/dns/dns_client.cc » ('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/address_sorter_posix.h" 5 #include "net/dns/address_sorter_posix.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "net/base/net_errors.h" 9 #include "net/base/net_errors.h"
10 #include "net/base/net_util.h" 10 #include "net/base/net_util.h"
(...skipping 15 matching lines...) Expand all
26 CHECK(ParseIPLiteralToNumber(str, &addr)); 26 CHECK(ParseIPLiteralToNumber(str, &addr));
27 return addr; 27 return addr;
28 } 28 }
29 29
30 // A mock socket which binds to source address according to AddressMapping. 30 // A mock socket which binds to source address according to AddressMapping.
31 class TestUDPClientSocket : public DatagramClientSocket { 31 class TestUDPClientSocket : public DatagramClientSocket {
32 public: 32 public:
33 explicit TestUDPClientSocket(const AddressMapping* mapping) 33 explicit TestUDPClientSocket(const AddressMapping* mapping)
34 : mapping_(mapping), connected_(false) {} 34 : mapping_(mapping), connected_(false) {}
35 35
36 virtual ~TestUDPClientSocket() {} 36 ~TestUDPClientSocket() override {}
37 37
38 virtual int Read(IOBuffer*, int, const CompletionCallback&) override { 38 int Read(IOBuffer*, int, const CompletionCallback&) override {
39 NOTIMPLEMENTED(); 39 NOTIMPLEMENTED();
40 return OK; 40 return OK;
41 } 41 }
42 virtual int Write(IOBuffer*, int, const CompletionCallback&) override { 42 int Write(IOBuffer*, int, const CompletionCallback&) override {
43 NOTIMPLEMENTED(); 43 NOTIMPLEMENTED();
44 return OK; 44 return OK;
45 } 45 }
46 virtual int SetReceiveBufferSize(int32) override { 46 int SetReceiveBufferSize(int32) override { return OK; }
47 return OK; 47 int SetSendBufferSize(int32) override { return OK; }
48 }
49 virtual int SetSendBufferSize(int32) override {
50 return OK;
51 }
52 48
53 virtual void Close() override {} 49 void Close() override {}
54 virtual int GetPeerAddress(IPEndPoint* address) const override { 50 int GetPeerAddress(IPEndPoint* address) const override {
55 NOTIMPLEMENTED(); 51 NOTIMPLEMENTED();
56 return OK; 52 return OK;
57 } 53 }
58 virtual int GetLocalAddress(IPEndPoint* address) const override { 54 int GetLocalAddress(IPEndPoint* address) const override {
59 if (!connected_) 55 if (!connected_)
60 return ERR_UNEXPECTED; 56 return ERR_UNEXPECTED;
61 *address = local_endpoint_; 57 *address = local_endpoint_;
62 return OK; 58 return OK;
63 } 59 }
64 60
65 virtual int Connect(const IPEndPoint& remote) override { 61 int Connect(const IPEndPoint& remote) override {
66 if (connected_) 62 if (connected_)
67 return ERR_UNEXPECTED; 63 return ERR_UNEXPECTED;
68 AddressMapping::const_iterator it = mapping_->find(remote.address()); 64 AddressMapping::const_iterator it = mapping_->find(remote.address());
69 if (it == mapping_->end()) 65 if (it == mapping_->end())
70 return ERR_FAILED; 66 return ERR_FAILED;
71 connected_ = true; 67 connected_ = true;
72 local_endpoint_ = IPEndPoint(it->second, 39874 /* arbitrary port */); 68 local_endpoint_ = IPEndPoint(it->second, 39874 /* arbitrary port */);
73 return OK; 69 return OK;
74 } 70 }
75 71
76 virtual const BoundNetLog& NetLog() const override { 72 const BoundNetLog& NetLog() const override { return net_log_; }
77 return net_log_;
78 }
79 73
80 private: 74 private:
81 BoundNetLog net_log_; 75 BoundNetLog net_log_;
82 const AddressMapping* mapping_; 76 const AddressMapping* mapping_;
83 bool connected_; 77 bool connected_;
84 IPEndPoint local_endpoint_; 78 IPEndPoint local_endpoint_;
85 79
86 DISALLOW_COPY_AND_ASSIGN(TestUDPClientSocket); 80 DISALLOW_COPY_AND_ASSIGN(TestUDPClientSocket);
87 }; 81 };
88 82
89 // Creates TestUDPClientSockets and maintains an AddressMapping. 83 // Creates TestUDPClientSockets and maintains an AddressMapping.
90 class TestSocketFactory : public ClientSocketFactory { 84 class TestSocketFactory : public ClientSocketFactory {
91 public: 85 public:
92 TestSocketFactory() {} 86 TestSocketFactory() {}
93 virtual ~TestSocketFactory() {} 87 ~TestSocketFactory() override {}
94 88
95 virtual scoped_ptr<DatagramClientSocket> CreateDatagramClientSocket( 89 scoped_ptr<DatagramClientSocket> CreateDatagramClientSocket(
96 DatagramSocket::BindType, 90 DatagramSocket::BindType,
97 const RandIntCallback&, 91 const RandIntCallback&,
98 NetLog*, 92 NetLog*,
99 const NetLog::Source&) override { 93 const NetLog::Source&) override {
100 return scoped_ptr<DatagramClientSocket>(new TestUDPClientSocket(&mapping_)); 94 return scoped_ptr<DatagramClientSocket>(new TestUDPClientSocket(&mapping_));
101 } 95 }
102 virtual scoped_ptr<StreamSocket> CreateTransportClientSocket( 96 scoped_ptr<StreamSocket> CreateTransportClientSocket(
103 const AddressList&, 97 const AddressList&,
104 NetLog*, 98 NetLog*,
105 const NetLog::Source&) override { 99 const NetLog::Source&) override {
106 NOTIMPLEMENTED(); 100 NOTIMPLEMENTED();
107 return scoped_ptr<StreamSocket>(); 101 return scoped_ptr<StreamSocket>();
108 } 102 }
109 virtual scoped_ptr<SSLClientSocket> CreateSSLClientSocket( 103 scoped_ptr<SSLClientSocket> CreateSSLClientSocket(
110 scoped_ptr<ClientSocketHandle>, 104 scoped_ptr<ClientSocketHandle>,
111 const HostPortPair&, 105 const HostPortPair&,
112 const SSLConfig&, 106 const SSLConfig&,
113 const SSLClientSocketContext&) override { 107 const SSLClientSocketContext&) override {
114 NOTIMPLEMENTED(); 108 NOTIMPLEMENTED();
115 return scoped_ptr<SSLClientSocket>(); 109 return scoped_ptr<SSLClientSocket>();
116 } 110 }
117 virtual void ClearSSLSessionCache() override { 111 void ClearSSLSessionCache() override { NOTIMPLEMENTED(); }
118 NOTIMPLEMENTED();
119 }
120 112
121 void AddMapping(const IPAddressNumber& dst, const IPAddressNumber& src) { 113 void AddMapping(const IPAddressNumber& dst, const IPAddressNumber& src) {
122 mapping_[dst] = src; 114 mapping_[dst] = src;
123 } 115 }
124 116
125 private: 117 private:
126 AddressMapping mapping_; 118 AddressMapping mapping_;
127 119
128 DISALLOW_COPY_AND_ASSIGN(TestSocketFactory); 120 DISALLOW_COPY_AND_ASSIGN(TestSocketFactory);
129 }; 121 };
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
318 AddMapping("4000::1", "4000::10"); // global unicast 310 AddMapping("4000::1", "4000::10"); // global unicast
319 AddMapping("ff32::2", "fe81::20"); // deprecated link-local multicast 311 AddMapping("ff32::2", "fe81::20"); // deprecated link-local multicast
320 GetSourceInfo("fe81::20")->deprecated = true; 312 GetSourceInfo("fe81::20")->deprecated = true;
321 const char* addresses[] = { "ff3e::1", "ff32::2", "4000::1", "ff32::1", "::1", 313 const char* addresses[] = { "ff3e::1", "ff32::2", "4000::1", "ff32::1", "::1",
322 "8.0.0.1", NULL }; 314 "8.0.0.1", NULL };
323 const int order[] = { 4, 3, 0, 2, 1, -1 }; 315 const int order[] = { 4, 3, 0, 2, 1, -1 };
324 Verify(addresses, order); 316 Verify(addresses, order);
325 } 317 }
326 318
327 } // namespace net 319 } // namespace net
OLDNEW
« no previous file with comments | « net/dns/address_sorter_posix.h ('k') | net/dns/dns_client.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698