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

Side by Side Diff: net/proxy/multi_threaded_proxy_resolver_unittest.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/proxy/multi_threaded_proxy_resolver.cc ('k') | net/proxy/network_delegate_error_observer.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/proxy/multi_threaded_proxy_resolver.h" 5 #include "net/proxy/multi_threaded_proxy_resolver.h"
6 6
7 #include "base/message_loop/message_loop.h" 7 #include "base/message_loop/message_loop.h"
8 #include "base/stl_util.h" 8 #include "base/stl_util.h"
9 #include "base/strings/string_util.h" 9 #include "base/strings/string_util.h"
10 #include "base/strings/stringprintf.h" 10 #include "base/strings/stringprintf.h"
(...skipping 22 matching lines...) Expand all
33 MockProxyResolver() 33 MockProxyResolver()
34 : ProxyResolver(true /*expects_pac_bytes*/), 34 : ProxyResolver(true /*expects_pac_bytes*/),
35 wrong_loop_(base::MessageLoop::current()), 35 wrong_loop_(base::MessageLoop::current()),
36 request_count_(0) {} 36 request_count_(0) {}
37 37
38 // ProxyResolver implementation. 38 // ProxyResolver implementation.
39 virtual int GetProxyForURL(const GURL& query_url, 39 virtual int GetProxyForURL(const GURL& query_url,
40 ProxyInfo* results, 40 ProxyInfo* results,
41 const CompletionCallback& callback, 41 const CompletionCallback& callback,
42 RequestHandle* request, 42 RequestHandle* request,
43 const BoundNetLog& net_log) OVERRIDE { 43 const BoundNetLog& net_log) override {
44 if (resolve_latency_ != base::TimeDelta()) 44 if (resolve_latency_ != base::TimeDelta())
45 base::PlatformThread::Sleep(resolve_latency_); 45 base::PlatformThread::Sleep(resolve_latency_);
46 46
47 CheckIsOnWorkerThread(); 47 CheckIsOnWorkerThread();
48 48
49 EXPECT_TRUE(callback.is_null()); 49 EXPECT_TRUE(callback.is_null());
50 EXPECT_TRUE(request == NULL); 50 EXPECT_TRUE(request == NULL);
51 51
52 // Write something into |net_log| (doesn't really have any meaning.) 52 // Write something into |net_log| (doesn't really have any meaning.)
53 net_log.BeginEvent(NetLog::TYPE_PAC_JAVASCRIPT_ALERT); 53 net_log.BeginEvent(NetLog::TYPE_PAC_JAVASCRIPT_ALERT);
54 54
55 results->UseNamedProxy(query_url.host()); 55 results->UseNamedProxy(query_url.host());
56 56
57 // Return a success code which represents the request's order. 57 // Return a success code which represents the request's order.
58 return request_count_++; 58 return request_count_++;
59 } 59 }
60 60
61 virtual void CancelRequest(RequestHandle request) OVERRIDE { 61 virtual void CancelRequest(RequestHandle request) override {
62 NOTREACHED(); 62 NOTREACHED();
63 } 63 }
64 64
65 virtual LoadState GetLoadState(RequestHandle request) const OVERRIDE { 65 virtual LoadState GetLoadState(RequestHandle request) const override {
66 NOTREACHED(); 66 NOTREACHED();
67 return LOAD_STATE_IDLE; 67 return LOAD_STATE_IDLE;
68 } 68 }
69 69
70 virtual void CancelSetPacScript() OVERRIDE { 70 virtual void CancelSetPacScript() override {
71 NOTREACHED(); 71 NOTREACHED();
72 } 72 }
73 73
74 virtual int SetPacScript( 74 virtual int SetPacScript(
75 const scoped_refptr<ProxyResolverScriptData>& script_data, 75 const scoped_refptr<ProxyResolverScriptData>& script_data,
76 const CompletionCallback& callback) OVERRIDE { 76 const CompletionCallback& callback) override {
77 CheckIsOnWorkerThread(); 77 CheckIsOnWorkerThread();
78 last_script_data_ = script_data; 78 last_script_data_ = script_data;
79 return OK; 79 return OK;
80 } 80 }
81 81
82 int request_count() const { return request_count_; } 82 int request_count() const { return request_count_; }
83 83
84 const ProxyResolverScriptData* last_script_data() const { 84 const ProxyResolverScriptData* last_script_data() const {
85 return last_script_data_.get(); 85 return last_script_data_.get();
86 } 86 }
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 } 130 }
131 131
132 void WaitUntilBlocked() { 132 void WaitUntilBlocked() {
133 blocked_.Wait(); 133 blocked_.Wait();
134 } 134 }
135 135
136 virtual int GetProxyForURL(const GURL& query_url, 136 virtual int GetProxyForURL(const GURL& query_url,
137 ProxyInfo* results, 137 ProxyInfo* results,
138 const CompletionCallback& callback, 138 const CompletionCallback& callback,
139 RequestHandle* request, 139 RequestHandle* request,
140 const BoundNetLog& net_log) OVERRIDE { 140 const BoundNetLog& net_log) override {
141 if (should_block_) { 141 if (should_block_) {
142 blocked_.Signal(); 142 blocked_.Signal();
143 unblocked_.Wait(); 143 unblocked_.Wait();
144 } 144 }
145 145
146 return MockProxyResolver::GetProxyForURL( 146 return MockProxyResolver::GetProxyForURL(
147 query_url, results, callback, request, net_log); 147 query_url, results, callback, request, net_log);
148 } 148 }
149 149
150 private: 150 private:
151 bool should_block_; 151 bool should_block_;
152 base::WaitableEvent unblocked_; 152 base::WaitableEvent unblocked_;
153 base::WaitableEvent blocked_; 153 base::WaitableEvent blocked_;
154 }; 154 };
155 155
156 // ForwardingProxyResolver forwards all requests to |impl|. 156 // ForwardingProxyResolver forwards all requests to |impl|.
157 class ForwardingProxyResolver : public ProxyResolver { 157 class ForwardingProxyResolver : public ProxyResolver {
158 public: 158 public:
159 explicit ForwardingProxyResolver(ProxyResolver* impl) 159 explicit ForwardingProxyResolver(ProxyResolver* impl)
160 : ProxyResolver(impl->expects_pac_bytes()), 160 : ProxyResolver(impl->expects_pac_bytes()),
161 impl_(impl) {} 161 impl_(impl) {}
162 162
163 virtual int GetProxyForURL(const GURL& query_url, 163 virtual int GetProxyForURL(const GURL& query_url,
164 ProxyInfo* results, 164 ProxyInfo* results,
165 const CompletionCallback& callback, 165 const CompletionCallback& callback,
166 RequestHandle* request, 166 RequestHandle* request,
167 const BoundNetLog& net_log) OVERRIDE { 167 const BoundNetLog& net_log) override {
168 return impl_->GetProxyForURL( 168 return impl_->GetProxyForURL(
169 query_url, results, callback, request, net_log); 169 query_url, results, callback, request, net_log);
170 } 170 }
171 171
172 virtual void CancelRequest(RequestHandle request) OVERRIDE { 172 virtual void CancelRequest(RequestHandle request) override {
173 impl_->CancelRequest(request); 173 impl_->CancelRequest(request);
174 } 174 }
175 175
176 virtual LoadState GetLoadState(RequestHandle request) const OVERRIDE { 176 virtual LoadState GetLoadState(RequestHandle request) const override {
177 NOTREACHED(); 177 NOTREACHED();
178 return LOAD_STATE_IDLE; 178 return LOAD_STATE_IDLE;
179 } 179 }
180 180
181 virtual void CancelSetPacScript() OVERRIDE { 181 virtual void CancelSetPacScript() override {
182 impl_->CancelSetPacScript(); 182 impl_->CancelSetPacScript();
183 } 183 }
184 184
185 virtual int SetPacScript( 185 virtual int SetPacScript(
186 const scoped_refptr<ProxyResolverScriptData>& script_data, 186 const scoped_refptr<ProxyResolverScriptData>& script_data,
187 const CompletionCallback& callback) OVERRIDE { 187 const CompletionCallback& callback) override {
188 return impl_->SetPacScript(script_data, callback); 188 return impl_->SetPacScript(script_data, callback);
189 } 189 }
190 190
191 private: 191 private:
192 ProxyResolver* impl_; 192 ProxyResolver* impl_;
193 }; 193 };
194 194
195 // This factory returns ProxyResolvers that forward all requests to 195 // This factory returns ProxyResolvers that forward all requests to
196 // |resolver|. 196 // |resolver|.
197 class ForwardingProxyResolverFactory : public ProxyResolverFactory { 197 class ForwardingProxyResolverFactory : public ProxyResolverFactory {
198 public: 198 public:
199 explicit ForwardingProxyResolverFactory(ProxyResolver* resolver) 199 explicit ForwardingProxyResolverFactory(ProxyResolver* resolver)
200 : ProxyResolverFactory(resolver->expects_pac_bytes()), 200 : ProxyResolverFactory(resolver->expects_pac_bytes()),
201 resolver_(resolver) {} 201 resolver_(resolver) {}
202 202
203 virtual ProxyResolver* CreateProxyResolver() OVERRIDE { 203 virtual ProxyResolver* CreateProxyResolver() override {
204 return new ForwardingProxyResolver(resolver_); 204 return new ForwardingProxyResolver(resolver_);
205 } 205 }
206 206
207 private: 207 private:
208 ProxyResolver* resolver_; 208 ProxyResolver* resolver_;
209 }; 209 };
210 210
211 // This factory returns new instances of BlockableProxyResolver. 211 // This factory returns new instances of BlockableProxyResolver.
212 class BlockableProxyResolverFactory : public ProxyResolverFactory { 212 class BlockableProxyResolverFactory : public ProxyResolverFactory {
213 public: 213 public:
214 BlockableProxyResolverFactory() : ProxyResolverFactory(true) {} 214 BlockableProxyResolverFactory() : ProxyResolverFactory(true) {}
215 215
216 virtual ~BlockableProxyResolverFactory() { 216 virtual ~BlockableProxyResolverFactory() {
217 STLDeleteElements(&resolvers_); 217 STLDeleteElements(&resolvers_);
218 } 218 }
219 219
220 virtual ProxyResolver* CreateProxyResolver() OVERRIDE { 220 virtual ProxyResolver* CreateProxyResolver() override {
221 BlockableProxyResolver* resolver = new BlockableProxyResolver; 221 BlockableProxyResolver* resolver = new BlockableProxyResolver;
222 resolvers_.push_back(resolver); 222 resolvers_.push_back(resolver);
223 return new ForwardingProxyResolver(resolver); 223 return new ForwardingProxyResolver(resolver);
224 } 224 }
225 225
226 std::vector<BlockableProxyResolver*> resolvers() { 226 std::vector<BlockableProxyResolver*> resolvers() {
227 return resolvers_; 227 return resolvers_;
228 } 228 }
229 229
230 private: 230 private:
(...skipping 523 matching lines...) Expand 10 before | Expand all | Expand 10 after
754 // All in all, the first thread should have seen just 1 request. And the 754 // All in all, the first thread should have seen just 1 request. And the
755 // second thread 3 requests. 755 // second thread 3 requests.
756 ASSERT_EQ(2u, factory->resolvers().size()); 756 ASSERT_EQ(2u, factory->resolvers().size());
757 EXPECT_EQ(1, factory->resolvers()[0]->request_count()); 757 EXPECT_EQ(1, factory->resolvers()[0]->request_count());
758 EXPECT_EQ(3, factory->resolvers()[1]->request_count()); 758 EXPECT_EQ(3, factory->resolvers()[1]->request_count());
759 } 759 }
760 760
761 } // namespace 761 } // namespace
762 762
763 } // namespace net 763 } // namespace net
OLDNEW
« no previous file with comments | « net/proxy/multi_threaded_proxy_resolver.cc ('k') | net/proxy/network_delegate_error_observer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698