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

Side by Side Diff: net/dns/single_request_host_resolver_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/serial_worker_unittest.cc ('k') | net/extras/sqlite/sqlite_channel_id_store.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/single_request_host_resolver.h" 5 #include "net/dns/single_request_host_resolver.h"
6 6
7 #include "net/base/address_list.h" 7 #include "net/base/address_list.h"
8 #include "net/base/net_errors.h" 8 #include "net/base/net_errors.h"
9 #include "net/base/net_log.h" 9 #include "net/base/net_log.h"
10 #include "net/base/test_completion_callback.h" 10 #include "net/base/test_completion_callback.h"
11 #include "net/dns/mock_host_resolver.h" 11 #include "net/dns/mock_host_resolver.h"
12 #include "testing/gtest/include/gtest/gtest.h" 12 #include "testing/gtest/include/gtest/gtest.h"
13 13
14 namespace net { 14 namespace net {
15 15
16 namespace { 16 namespace {
17 17
18 // Helper class used by SingleRequestHostResolverTest.Cancel test. 18 // Helper class used by SingleRequestHostResolverTest.Cancel test.
19 // It checks that only one request is outstanding at a time, and that 19 // It checks that only one request is outstanding at a time, and that
20 // it is cancelled before the class is destroyed. 20 // it is cancelled before the class is destroyed.
21 class HangingHostResolver : public HostResolver { 21 class HangingHostResolver : public HostResolver {
22 public: 22 public:
23 HangingHostResolver() : outstanding_request_(NULL) {} 23 HangingHostResolver() : outstanding_request_(NULL) {}
24 24
25 virtual ~HangingHostResolver() { 25 ~HangingHostResolver() override { EXPECT_TRUE(!has_outstanding_request()); }
26 EXPECT_TRUE(!has_outstanding_request());
27 }
28 26
29 bool has_outstanding_request() const { 27 bool has_outstanding_request() const {
30 return outstanding_request_ != NULL; 28 return outstanding_request_ != NULL;
31 } 29 }
32 30
33 virtual int Resolve(const RequestInfo& info, 31 int Resolve(const RequestInfo& info,
34 RequestPriority priority, 32 RequestPriority priority,
35 AddressList* addresses, 33 AddressList* addresses,
36 const CompletionCallback& callback, 34 const CompletionCallback& callback,
37 RequestHandle* out_req, 35 RequestHandle* out_req,
38 const BoundNetLog& net_log) override { 36 const BoundNetLog& net_log) override {
39 EXPECT_FALSE(has_outstanding_request()); 37 EXPECT_FALSE(has_outstanding_request());
40 outstanding_request_ = reinterpret_cast<RequestHandle>(0x1234); 38 outstanding_request_ = reinterpret_cast<RequestHandle>(0x1234);
41 *out_req = outstanding_request_; 39 *out_req = outstanding_request_;
42 40
43 // Never complete this request! Caller is expected to cancel it 41 // Never complete this request! Caller is expected to cancel it
44 // before destroying the resolver. 42 // before destroying the resolver.
45 return ERR_IO_PENDING; 43 return ERR_IO_PENDING;
46 } 44 }
47 45
48 virtual int ResolveFromCache(const RequestInfo& info, 46 int ResolveFromCache(const RequestInfo& info,
49 AddressList* addresses, 47 AddressList* addresses,
50 const BoundNetLog& net_log) override { 48 const BoundNetLog& net_log) override {
51 NOTIMPLEMENTED(); 49 NOTIMPLEMENTED();
52 return ERR_UNEXPECTED; 50 return ERR_UNEXPECTED;
53 } 51 }
54 52
55 virtual void CancelRequest(RequestHandle req) override { 53 void CancelRequest(RequestHandle req) override {
56 EXPECT_TRUE(has_outstanding_request()); 54 EXPECT_TRUE(has_outstanding_request());
57 EXPECT_EQ(req, outstanding_request_); 55 EXPECT_EQ(req, outstanding_request_);
58 outstanding_request_ = NULL; 56 outstanding_request_ = NULL;
59 } 57 }
60 58
61 private: 59 private:
62 RequestHandle outstanding_request_; 60 RequestHandle outstanding_request_;
63 61
64 DISALLOW_COPY_AND_ASSIGN(HangingHostResolver); 62 DISALLOW_COPY_AND_ASSIGN(HangingHostResolver);
65 }; 63 };
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 SingleRequestHostResolver single_request_resolver(&resolver); 117 SingleRequestHostResolver single_request_resolver(&resolver);
120 single_request_resolver.Cancel(); 118 single_request_resolver.Cancel();
121 119
122 // To pass, HangingHostResolver should not have received a cancellation 120 // To pass, HangingHostResolver should not have received a cancellation
123 // request (since there is nothing to cancel). If it does, it will crash. 121 // request (since there is nothing to cancel). If it does, it will crash.
124 } 122 }
125 123
126 } // namespace 124 } // namespace
127 125
128 } // namespace net 126 } // namespace net
OLDNEW
« no previous file with comments | « net/dns/serial_worker_unittest.cc ('k') | net/extras/sqlite/sqlite_channel_id_store.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698