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

Side by Side Diff: net/spdy/spdy_test_util.h

Issue 3518001: HttpAuthHandlerFactory::CreateDefault requires a HostResolver argument. (Closed)
Patch Set: Created 10 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/socket/ssl_client_socket_pool_unittest.cc ('k') | net/tools/fetch/fetch_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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 #ifndef NET_SPDY_SPDY_TEST_UTIL_H_ 5 #ifndef NET_SPDY_SPDY_TEST_UTIL_H_
6 #define NET_SPDY_SPDY_TEST_UTIL_H_ 6 #define NET_SPDY_SPDY_TEST_UTIL_H_
7 #pragma once 7 #pragma once
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "net/base/mock_host_resolver.h" 10 #include "net/base/mock_host_resolver.h"
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 spdy::SpdyFrame* ConstructSpdyGetSynReply(const char* const extra_headers[], 241 spdy::SpdyFrame* ConstructSpdyGetSynReply(const char* const extra_headers[],
242 int extra_header_count, 242 int extra_header_count,
243 int stream_id); 243 int stream_id);
244 244
245 // Constructs a standard SPDY SYN_REPLY packet to match the SPDY GET. 245 // Constructs a standard SPDY SYN_REPLY packet to match the SPDY GET.
246 // |extra_headers| are the extra header-value pairs, which typically 246 // |extra_headers| are the extra header-value pairs, which typically
247 // will vary the most between calls. 247 // will vary the most between calls.
248 // Returns a SpdyFrame. 248 // Returns a SpdyFrame.
249 spdy::SpdyFrame* ConstructSpdyGetSynReplyRedirect(int stream_id); 249 spdy::SpdyFrame* ConstructSpdyGetSynReplyRedirect(int stream_id);
250 250
251
252 // Constructs a standard SPDY POST SYN packet. 251 // Constructs a standard SPDY POST SYN packet.
253 // |extra_headers| are the extra header-value pairs, which typically 252 // |extra_headers| are the extra header-value pairs, which typically
254 // will vary the most between calls. 253 // will vary the most between calls.
255 // Returns a SpdyFrame. 254 // Returns a SpdyFrame.
256 spdy::SpdyFrame* ConstructSpdyPost(int64 content_length, 255 spdy::SpdyFrame* ConstructSpdyPost(int64 content_length,
257 const char* const extra_headers[], 256 const char* const extra_headers[],
258 int extra_header_count); 257 int extra_header_count);
259 258
260 // Constructs a standard SPDY SYN_REPLY packet to match the SPDY POST. 259 // Constructs a standard SPDY SYN_REPLY packet to match the SPDY POST.
261 // |extra_headers| are the extra header-value pairs, which typically 260 // |extra_headers| are the extra header-value pairs, which typically
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
297 // HttpNetworkTransaction. 296 // HttpNetworkTransaction.
298 class SpdySessionDependencies { 297 class SpdySessionDependencies {
299 public: 298 public:
300 // Default set of dependencies -- "null" proxy service. 299 // Default set of dependencies -- "null" proxy service.
301 SpdySessionDependencies() 300 SpdySessionDependencies()
302 : host_resolver(new MockHostResolver), 301 : host_resolver(new MockHostResolver),
303 proxy_service(ProxyService::CreateDirect()), 302 proxy_service(ProxyService::CreateDirect()),
304 ssl_config_service(new SSLConfigServiceDefaults), 303 ssl_config_service(new SSLConfigServiceDefaults),
305 socket_factory(new MockClientSocketFactory), 304 socket_factory(new MockClientSocketFactory),
306 deterministic_socket_factory(new DeterministicMockClientSocketFactory), 305 deterministic_socket_factory(new DeterministicMockClientSocketFactory),
307 http_auth_handler_factory(HttpAuthHandlerFactory::CreateDefault()), 306 http_auth_handler_factory(
307 HttpAuthHandlerFactory::CreateDefault(host_resolver)),
308 spdy_session_pool(new SpdySessionPool(NULL)) { 308 spdy_session_pool(new SpdySessionPool(NULL)) {
309 // Note: The CancelledTransaction test does cleanup by running all 309 // Note: The CancelledTransaction test does cleanup by running all
310 // tasks in the message loop (RunAllPending). Unfortunately, that 310 // tasks in the message loop (RunAllPending). Unfortunately, that
311 // doesn't clean up tasks on the host resolver thread; and 311 // doesn't clean up tasks on the host resolver thread; and
312 // TCPConnectJob is currently not cancellable. Using synchronous 312 // TCPConnectJob is currently not cancellable. Using synchronous
313 // lookups allows the test to shutdown cleanly. Until we have 313 // lookups allows the test to shutdown cleanly. Until we have
314 // cancellable TCPConnectJobs, use synchronous lookups. 314 // cancellable TCPConnectJobs, use synchronous lookups.
315 host_resolver->set_synchronous_mode(true); 315 host_resolver->set_synchronous_mode(true);
316 } 316 }
317 317
318 // Custom proxy service dependency. 318 // Custom proxy service dependency.
319 explicit SpdySessionDependencies(ProxyService* proxy_service) 319 explicit SpdySessionDependencies(ProxyService* proxy_service)
320 : host_resolver(new MockHostResolver), 320 : host_resolver(new MockHostResolver),
321 proxy_service(proxy_service), 321 proxy_service(proxy_service),
322 ssl_config_service(new SSLConfigServiceDefaults), 322 ssl_config_service(new SSLConfigServiceDefaults),
323 socket_factory(new MockClientSocketFactory), 323 socket_factory(new MockClientSocketFactory),
324 deterministic_socket_factory(new DeterministicMockClientSocketFactory), 324 deterministic_socket_factory(new DeterministicMockClientSocketFactory),
325 http_auth_handler_factory(HttpAuthHandlerFactory::CreateDefault()), 325 http_auth_handler_factory(
326 HttpAuthHandlerFactory::CreateDefault(host_resolver)),
326 spdy_session_pool(new SpdySessionPool(NULL)) {} 327 spdy_session_pool(new SpdySessionPool(NULL)) {}
327 328
329 // NOTE: host_resolver must be ordered before http_auth_handler_factory.
328 scoped_refptr<MockHostResolverBase> host_resolver; 330 scoped_refptr<MockHostResolverBase> host_resolver;
329 scoped_refptr<ProxyService> proxy_service; 331 scoped_refptr<ProxyService> proxy_service;
330 scoped_refptr<SSLConfigService> ssl_config_service; 332 scoped_refptr<SSLConfigService> ssl_config_service;
331 scoped_ptr<MockClientSocketFactory> socket_factory; 333 scoped_ptr<MockClientSocketFactory> socket_factory;
332 scoped_ptr<DeterministicMockClientSocketFactory> deterministic_socket_factory; 334 scoped_ptr<DeterministicMockClientSocketFactory> deterministic_socket_factory;
333 scoped_ptr<HttpAuthHandlerFactory> http_auth_handler_factory; 335 scoped_ptr<HttpAuthHandlerFactory> http_auth_handler_factory;
334 scoped_refptr<SpdySessionPool> spdy_session_pool; 336 scoped_refptr<SpdySessionPool> spdy_session_pool;
335 337
336 static HttpNetworkSession* SpdyCreateSession( 338 static HttpNetworkSession* SpdyCreateSession(
337 SpdySessionDependencies* session_deps) { 339 SpdySessionDependencies* session_deps) {
(...skipping 20 matching lines...) Expand all
358 } 360 }
359 }; 361 };
360 362
361 class SpdyURLRequestContext : public URLRequestContext { 363 class SpdyURLRequestContext : public URLRequestContext {
362 public: 364 public:
363 SpdyURLRequestContext() { 365 SpdyURLRequestContext() {
364 host_resolver_ = new MockHostResolver; 366 host_resolver_ = new MockHostResolver;
365 proxy_service_ = ProxyService::CreateDirect(); 367 proxy_service_ = ProxyService::CreateDirect();
366 spdy_session_pool_ = new SpdySessionPool(NULL); 368 spdy_session_pool_ = new SpdySessionPool(NULL);
367 ssl_config_service_ = new SSLConfigServiceDefaults; 369 ssl_config_service_ = new SSLConfigServiceDefaults;
368 http_auth_handler_factory_ = HttpAuthHandlerFactory::CreateDefault(); 370 http_auth_handler_factory_ = HttpAuthHandlerFactory::CreateDefault(
371 host_resolver_);
369 http_transaction_factory_ = new net::HttpCache( 372 http_transaction_factory_ = new net::HttpCache(
370 new HttpNetworkLayer(&socket_factory_, 373 new HttpNetworkLayer(&socket_factory_,
371 host_resolver_, 374 host_resolver_,
372 proxy_service_, 375 proxy_service_,
373 ssl_config_service_, 376 ssl_config_service_,
374 spdy_session_pool_.get(), 377 spdy_session_pool_.get(),
375 http_auth_handler_factory_, 378 http_auth_handler_factory_,
376 network_delegate_, 379 network_delegate_,
377 NULL), 380 NULL),
378 net::HttpCache::DefaultBackend::InMemory(0)); 381 net::HttpCache::DefaultBackend::InMemory(0));
379 } 382 }
380 383
381 MockClientSocketFactory& socket_factory() { return socket_factory_; } 384 MockClientSocketFactory& socket_factory() { return socket_factory_; }
382 385
383 protected: 386 protected:
384 virtual ~SpdyURLRequestContext() { 387 virtual ~SpdyURLRequestContext() {
385 delete http_transaction_factory_; 388 delete http_transaction_factory_;
386 delete http_auth_handler_factory_; 389 delete http_auth_handler_factory_;
387 } 390 }
388 391
389 private: 392 private:
390 MockClientSocketFactory socket_factory_; 393 MockClientSocketFactory socket_factory_;
391 scoped_refptr<SpdySessionPool> spdy_session_pool_; 394 scoped_refptr<SpdySessionPool> spdy_session_pool_;
392 }; 395 };
393 396
394 const SpdyHeaderInfo make_spdy_header(spdy::SpdyControlType type); 397 const SpdyHeaderInfo make_spdy_header(spdy::SpdyControlType type);
395 } // namespace net 398 } // namespace net
396 399
397 #endif // NET_SPDY_SPDY_TEST_UTIL_H_ 400 #endif // NET_SPDY_SPDY_TEST_UTIL_H_
OLDNEW
« no previous file with comments | « net/socket/ssl_client_socket_pool_unittest.cc ('k') | net/tools/fetch/fetch_client.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698