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

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

Issue 11415219: Move a number of static variables SPDY to HttpNetworkSession::Params. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Moar cleanup Created 8 years 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 | Annotate | Revision Log
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 #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 7
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "crypto/ec_private_key.h"
11 #include "crypto/ec_signature_creator.h"
10 #include "net/base/cert_verifier.h" 12 #include "net/base/cert_verifier.h"
11 #include "net/base/host_port_pair.h" 13 #include "net/base/host_port_pair.h"
12 #include "net/base/mock_host_resolver.h" 14 #include "net/base/mock_host_resolver.h"
13 #include "net/base/request_priority.h" 15 #include "net/base/request_priority.h"
14 #include "net/base/ssl_config_service_defaults.h" 16 #include "net/base/ssl_config_service_defaults.h"
15 #include "net/http/http_auth_handler_factory.h" 17 #include "net/http/http_auth_handler_factory.h"
16 #include "net/http/http_cache.h" 18 #include "net/http/http_cache.h"
17 #include "net/http/http_network_session.h" 19 #include "net/http/http_network_session.h"
18 #include "net/http/http_network_layer.h" 20 #include "net/http/http_network_layer.h"
19 #include "net/http/http_server_properties_impl.h" 21 #include "net/http/http_server_properties_impl.h"
20 #include "net/http/http_transaction_factory.h" 22 #include "net/http/http_transaction_factory.h"
21 #include "net/proxy/proxy_service.h" 23 #include "net/proxy/proxy_service.h"
22 #include "net/socket/socket_test_util.h" 24 #include "net/socket/socket_test_util.h"
25 #include "net/spdy/spdy_session.h"
23 #include "net/url_request/url_request_context.h" 26 #include "net/url_request/url_request_context.h"
24 #include "net/url_request/url_request_context_storage.h" 27 #include "net/url_request/url_request_context_storage.h"
25 28
26 namespace crypto { 29 namespace crypto {
27 class ECSignatureCreatorFactory; 30 class ECSignatureCreatorFactory;
28 } 31 }
29 32
30 namespace net { 33 namespace net {
31 34
32 namespace test_spdy3 { 35 namespace test_spdy3 {
(...skipping 13 matching lines...) Expand all
46 SpdyPriority priority; 49 SpdyPriority priority;
47 size_t credential_slot; 50 size_t credential_slot;
48 SpdyControlFlags control_flags; 51 SpdyControlFlags control_flags;
49 bool compressed; 52 bool compressed;
50 SpdyStatusCodes status; 53 SpdyStatusCodes status;
51 const char* data; 54 const char* data;
52 uint32 data_length; 55 uint32 data_length;
53 SpdyDataFlags data_flags; 56 SpdyDataFlags data_flags;
54 }; 57 };
55 58
59 // An ECSignatureCreator that returns deterministic signatures.
60 class MockECSignatureCreator : public crypto::ECSignatureCreator {
61 public:
62 explicit MockECSignatureCreator(crypto::ECPrivateKey* key);
63
64 // crypto::ECSignatureCreator
65 virtual bool Sign(const uint8* data,
66 int data_len,
67 std::vector<uint8>* signature) OVERRIDE;
68 virtual bool DecodeSignature(const std::vector<uint8>& signature,
69 std::vector<uint8>* out_raw_sig) OVERRIDE;
70
71 private:
72 crypto::ECPrivateKey* key_;
73
74 DISALLOW_COPY_AND_ASSIGN(MockECSignatureCreator);
75 };
76
77 // An ECSignatureCreatorFactory creates MockECSignatureCreator.
78 class MockECSignatureCreatorFactory : public crypto::ECSignatureCreatorFactory {
79 public:
80 MockECSignatureCreatorFactory();
81 virtual ~MockECSignatureCreatorFactory();
82
83 // crypto::ECSignatureCreatorFactory
84 virtual crypto::ECSignatureCreator* Create(
85 crypto::ECPrivateKey* key) OVERRIDE;
86
87 private:
88 DISALLOW_COPY_AND_ASSIGN(MockECSignatureCreatorFactory);
89 };
90
56 // Chop a frame into an array of MockWrites. 91 // Chop a frame into an array of MockWrites.
57 // |data| is the frame to chop. 92 // |data| is the frame to chop.
58 // |length| is the length of the frame to chop. 93 // |length| is the length of the frame to chop.
59 // |num_chunks| is the number of chunks to create. 94 // |num_chunks| is the number of chunks to create.
60 MockWrite* ChopWriteFrame(const char* data, int length, int num_chunks); 95 MockWrite* ChopWriteFrame(const char* data, int length, int num_chunks);
61 96
62 // Chop a SpdyFrame into an array of MockWrites. 97 // Chop a SpdyFrame into an array of MockWrites.
63 // |frame| is the frame to chop. 98 // |frame| is the frame to chop.
64 // |num_chunks| is the number of chunks to create. 99 // |num_chunks| is the number of chunks to create.
65 MockWrite* ChopWriteFrame(const SpdyFrame& frame, int num_chunks); 100 MockWrite* ChopWriteFrame(const SpdyFrame& frame, int num_chunks);
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after
364 399
365 // NOTE: host_resolver must be ordered before http_auth_handler_factory. 400 // NOTE: host_resolver must be ordered before http_auth_handler_factory.
366 scoped_ptr<MockHostResolverBase> host_resolver; 401 scoped_ptr<MockHostResolverBase> host_resolver;
367 scoped_ptr<CertVerifier> cert_verifier; 402 scoped_ptr<CertVerifier> cert_verifier;
368 scoped_ptr<ProxyService> proxy_service; 403 scoped_ptr<ProxyService> proxy_service;
369 scoped_refptr<SSLConfigService> ssl_config_service; 404 scoped_refptr<SSLConfigService> ssl_config_service;
370 scoped_ptr<MockClientSocketFactory> socket_factory; 405 scoped_ptr<MockClientSocketFactory> socket_factory;
371 scoped_ptr<DeterministicMockClientSocketFactory> deterministic_socket_factory; 406 scoped_ptr<DeterministicMockClientSocketFactory> deterministic_socket_factory;
372 scoped_ptr<HttpAuthHandlerFactory> http_auth_handler_factory; 407 scoped_ptr<HttpAuthHandlerFactory> http_auth_handler_factory;
373 HttpServerPropertiesImpl http_server_properties; 408 HttpServerPropertiesImpl http_server_properties;
409 bool enable_ip_pooling;
410 bool enable_compression;
411 bool enable_ping;
412 size_t initial_recv_window_size;
413 SpdySession::TimeFunc time_func;
374 std::string trusted_spdy_proxy; 414 std::string trusted_spdy_proxy;
375 NetLog* net_log; 415 NetLog* net_log;
376 }; 416 };
377 417
378 class SpdyURLRequestContext : public URLRequestContext { 418 class SpdyURLRequestContext : public URLRequestContext {
379 public: 419 public:
380 SpdyURLRequestContext(); 420 SpdyURLRequestContext();
381 virtual ~SpdyURLRequestContext(); 421 virtual ~SpdyURLRequestContext();
382 422
383 MockClientSocketFactory& socket_factory() { return socket_factory_; } 423 MockClientSocketFactory& socket_factory() { return socket_factory_; }
(...skipping 29 matching lines...) Expand all
413 void EnableSendingInitialSettings(bool enabled) { 453 void EnableSendingInitialSettings(bool enabled) {
414 pool_->enable_sending_initial_settings_ = enabled; 454 pool_->enable_sending_initial_settings_ = enabled;
415 } 455 }
416 456
417 private: 457 private:
418 SpdySessionPool* const pool_; 458 SpdySessionPool* const pool_;
419 459
420 DISALLOW_COPY_AND_ASSIGN(SpdySessionPoolPeer); 460 DISALLOW_COPY_AND_ASSIGN(SpdySessionPoolPeer);
421 }; 461 };
422 462
423 // Helper to manage the state of a number of SPDY global variables.
424 class SpdyTestStateHelper {
425 public:
426 SpdyTestStateHelper();
427 ~SpdyTestStateHelper();
428
429 private:
430 // In order to make CREDENTIAL frame creation deterministic, we need to
431 // use a mock EC signature creator, which needs to live throughout
432 // the life of the test.
433 scoped_ptr<crypto::ECSignatureCreatorFactory> ec_signature_creator_factory_;
434
435 DISALLOW_COPY_AND_ASSIGN(SpdyTestStateHelper);
436 };
437
438 } // namespace test_spdy3 463 } // namespace test_spdy3
439 464
440 } // namespace net 465 } // namespace net
441 466
442 #endif // NET_SPDY_SPDY_TEST_UTIL_H_ 467 #endif // NET_SPDY_SPDY_TEST_UTIL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698