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

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

Issue 623213004: replace OVERRIDE and FINAL with override and final in net/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: undo unwanted change in comment 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_test_util.h ('k') | net/dns/dns_transaction.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/dns_test_util.h" 5 #include "net/dns/dns_test_util.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/big_endian.h" 9 #include "base/big_endian.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "base/memory/weak_ptr.h" 11 #include "base/memory/weak_ptr.h"
12 #include "base/message_loop/message_loop.h" 12 #include "base/message_loop/message_loop.h"
13 #include "base/sys_byteorder.h" 13 #include "base/sys_byteorder.h"
14 #include "net/base/dns_util.h" 14 #include "net/base/dns_util.h"
15 #include "net/base/io_buffer.h" 15 #include "net/base/io_buffer.h"
16 #include "net/base/net_errors.h" 16 #include "net/base/net_errors.h"
17 #include "net/dns/address_sorter.h" 17 #include "net/dns/address_sorter.h"
18 #include "net/dns/dns_query.h" 18 #include "net/dns/dns_query.h"
19 #include "net/dns/dns_response.h" 19 #include "net/dns/dns_response.h"
20 #include "net/dns/dns_transaction.h" 20 #include "net/dns/dns_transaction.h"
21 #include "testing/gtest/include/gtest/gtest.h" 21 #include "testing/gtest/include/gtest/gtest.h"
22 22
23 namespace net { 23 namespace net {
24 namespace { 24 namespace {
25 25
26 class MockAddressSorter : public AddressSorter { 26 class MockAddressSorter : public AddressSorter {
27 public: 27 public:
28 virtual ~MockAddressSorter() {} 28 virtual ~MockAddressSorter() {}
29 virtual void Sort(const AddressList& list, 29 virtual void Sort(const AddressList& list,
30 const CallbackType& callback) const OVERRIDE { 30 const CallbackType& callback) const override {
31 // Do nothing. 31 // Do nothing.
32 callback.Run(true, list); 32 callback.Run(true, list);
33 } 33 }
34 }; 34 };
35 35
36 // A DnsTransaction which uses MockDnsClientRuleList to determine the response. 36 // A DnsTransaction which uses MockDnsClientRuleList to determine the response.
37 class MockTransaction : public DnsTransaction, 37 class MockTransaction : public DnsTransaction,
38 public base::SupportsWeakPtr<MockTransaction> { 38 public base::SupportsWeakPtr<MockTransaction> {
39 public: 39 public:
40 MockTransaction(const MockDnsClientRuleList& rules, 40 MockTransaction(const MockDnsClientRuleList& rules,
(...skipping 12 matching lines...) Expand all
53 if ((rules[i].qtype == qtype) && 53 if ((rules[i].qtype == qtype) &&
54 (hostname.size() >= prefix.size()) && 54 (hostname.size() >= prefix.size()) &&
55 (hostname.compare(0, prefix.size(), prefix) == 0)) { 55 (hostname.compare(0, prefix.size(), prefix) == 0)) {
56 result_ = rules[i].result; 56 result_ = rules[i].result;
57 delayed_ = rules[i].delay; 57 delayed_ = rules[i].delay;
58 break; 58 break;
59 } 59 }
60 } 60 }
61 } 61 }
62 62
63 virtual const std::string& GetHostname() const OVERRIDE { 63 virtual const std::string& GetHostname() const override {
64 return hostname_; 64 return hostname_;
65 } 65 }
66 66
67 virtual uint16 GetType() const OVERRIDE { 67 virtual uint16 GetType() const override {
68 return qtype_; 68 return qtype_;
69 } 69 }
70 70
71 virtual void Start() OVERRIDE { 71 virtual void Start() override {
72 EXPECT_FALSE(started_); 72 EXPECT_FALSE(started_);
73 started_ = true; 73 started_ = true;
74 if (delayed_) 74 if (delayed_)
75 return; 75 return;
76 // Using WeakPtr to cleanly cancel when transaction is destroyed. 76 // Using WeakPtr to cleanly cancel when transaction is destroyed.
77 base::MessageLoop::current()->PostTask( 77 base::MessageLoop::current()->PostTask(
78 FROM_HERE, base::Bind(&MockTransaction::Finish, AsWeakPtr())); 78 FROM_HERE, base::Bind(&MockTransaction::Finish, AsWeakPtr()));
79 } 79 }
80 80
81 void FinishDelayedTransaction() { 81 void FinishDelayedTransaction() {
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 public: 165 public:
166 explicit MockTransactionFactory(const MockDnsClientRuleList& rules) 166 explicit MockTransactionFactory(const MockDnsClientRuleList& rules)
167 : rules_(rules) {} 167 : rules_(rules) {}
168 168
169 virtual ~MockTransactionFactory() {} 169 virtual ~MockTransactionFactory() {}
170 170
171 virtual scoped_ptr<DnsTransaction> CreateTransaction( 171 virtual scoped_ptr<DnsTransaction> CreateTransaction(
172 const std::string& hostname, 172 const std::string& hostname,
173 uint16 qtype, 173 uint16 qtype,
174 const DnsTransactionFactory::CallbackType& callback, 174 const DnsTransactionFactory::CallbackType& callback,
175 const BoundNetLog&) OVERRIDE { 175 const BoundNetLog&) override {
176 MockTransaction* transaction = 176 MockTransaction* transaction =
177 new MockTransaction(rules_, hostname, qtype, callback); 177 new MockTransaction(rules_, hostname, qtype, callback);
178 if (transaction->delayed()) 178 if (transaction->delayed())
179 delayed_transactions_.push_back(transaction->AsWeakPtr()); 179 delayed_transactions_.push_back(transaction->AsWeakPtr());
180 return scoped_ptr<DnsTransaction>(transaction); 180 return scoped_ptr<DnsTransaction>(transaction);
181 } 181 }
182 182
183 void CompleteDelayedTransactions() { 183 void CompleteDelayedTransactions() {
184 DelayedTransactionList old_delayed_transactions; 184 DelayedTransactionList old_delayed_transactions;
185 old_delayed_transactions.swap(delayed_transactions_); 185 old_delayed_transactions.swap(delayed_transactions_);
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 220
221 AddressSorter* MockDnsClient::GetAddressSorter() { 221 AddressSorter* MockDnsClient::GetAddressSorter() {
222 return address_sorter_.get(); 222 return address_sorter_.get();
223 } 223 }
224 224
225 void MockDnsClient::CompleteDelayedTransactions() { 225 void MockDnsClient::CompleteDelayedTransactions() {
226 factory_->CompleteDelayedTransactions(); 226 factory_->CompleteDelayedTransactions();
227 } 227 }
228 228
229 } // namespace net 229 } // namespace net
OLDNEW
« no previous file with comments | « net/dns/dns_test_util.h ('k') | net/dns/dns_transaction.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698