OLD | NEW |
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_QUIC_QUIC_CRYPTO_CLIENT_STREAM_H_ | 5 #ifndef NET_QUIC_QUIC_CRYPTO_CLIENT_STREAM_H_ |
6 #define NET_QUIC_QUIC_CRYPTO_CLIENT_STREAM_H_ | 6 #define NET_QUIC_QUIC_CRYPTO_CLIENT_STREAM_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/memory/weak_ptr.h" | 10 #include "base/memory/weak_ptr.h" |
11 #include "base/time/time.h" | 11 #include "base/time/time.h" |
12 #include "net/cert/cert_verify_result.h" | 12 #include "net/cert/cert_verify_result.h" |
13 #include "net/cert/x509_certificate.h" | 13 #include "net/cert/x509_certificate.h" |
14 #include "net/quic/crypto/proof_verifier.h" | 14 #include "net/quic/crypto/proof_verifier.h" |
15 #include "net/quic/crypto/quic_crypto_client_config.h" | 15 #include "net/quic/crypto/quic_crypto_client_config.h" |
16 #include "net/quic/quic_config.h" | 16 #include "net/quic/quic_config.h" |
17 #include "net/quic/quic_crypto_stream.h" | 17 #include "net/quic/quic_crypto_stream.h" |
18 | 18 |
19 namespace net { | 19 namespace net { |
20 | 20 |
21 class ProofVerifyDetails; | 21 class QuicServerInfo; |
22 class QuicSession; | 22 class QuicSession; |
23 class SSLInfo; | 23 class SSLInfo; |
24 | 24 |
25 namespace test { | 25 namespace test { |
26 class CryptoTestUtils; | 26 class CryptoTestUtils; |
27 } // namespace test | 27 } // namespace test |
28 | 28 |
29 class NET_EXPORT_PRIVATE QuicCryptoClientStream : public QuicCryptoStream { | 29 class NET_EXPORT_PRIVATE QuicCryptoClientStream : public QuicCryptoStream { |
30 public: | 30 public: |
31 QuicCryptoClientStream(const string& server_hostname, | 31 QuicCryptoClientStream(const string& server_hostname, |
(...skipping 13 matching lines...) Expand all Loading... |
45 // num_sent_client_hellos returns the number of client hello messages that | 45 // num_sent_client_hellos returns the number of client hello messages that |
46 // have been sent. If the handshake has completed then this is one greater | 46 // have been sent. If the handshake has completed then this is one greater |
47 // than the number of round-trips needed for the handshake. | 47 // than the number of round-trips needed for the handshake. |
48 int num_sent_client_hellos() const; | 48 int num_sent_client_hellos() const; |
49 | 49 |
50 // Gets the SSL connection information. | 50 // Gets the SSL connection information. |
51 virtual bool GetSSLInfo(SSLInfo* ssl_info); | 51 virtual bool GetSSLInfo(SSLInfo* ssl_info); |
52 | 52 |
53 void OnIOComplete(int result); | 53 void OnIOComplete(int result); |
54 | 54 |
| 55 void SetQuicServerInfo(scoped_ptr<QuicServerInfo> server_info); |
| 56 |
55 private: | 57 private: |
56 // ProofVerifierCallbackImpl is passed as the callback method to VerifyProof. | 58 // ProofVerifierCallbackImpl is passed as the callback method to VerifyProof. |
57 // The ProofVerifier calls this class with the result of proof verification | 59 // The ProofVerifier calls this class with the result of proof verification |
58 // when verification is performed asynchronously. | 60 // when verification is performed asynchronously. |
59 class ProofVerifierCallbackImpl : public ProofVerifierCallback { | 61 class ProofVerifierCallbackImpl : public ProofVerifierCallback { |
60 public: | 62 public: |
61 explicit ProofVerifierCallbackImpl(QuicCryptoClientStream* stream); | 63 explicit ProofVerifierCallbackImpl(QuicCryptoClientStream* stream); |
62 virtual ~ProofVerifierCallbackImpl(); | 64 virtual ~ProofVerifierCallbackImpl(); |
63 | 65 |
64 // ProofVerifierCallback interface. | 66 // ProofVerifierCallback interface. |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 // functions. | 98 // functions. |
97 | 99 |
98 // Call QuicServerInfo's WaitForDataReady to load the server information from | 100 // Call QuicServerInfo's WaitForDataReady to load the server information from |
99 // the disk cache. | 101 // the disk cache. |
100 int DoLoadQuicServerInfo(QuicCryptoClientConfig::CachedState* cached); | 102 int DoLoadQuicServerInfo(QuicCryptoClientConfig::CachedState* cached); |
101 void DoLoadQuicServerInfoComplete( | 103 void DoLoadQuicServerInfoComplete( |
102 QuicCryptoClientConfig::CachedState* cached); | 104 QuicCryptoClientConfig::CachedState* cached); |
103 // LoadQuicServerInfo is a helper function for DoLoadQuicServerInfoComplete. | 105 // LoadQuicServerInfo is a helper function for DoLoadQuicServerInfoComplete. |
104 void LoadQuicServerInfo(QuicCryptoClientConfig::CachedState* cached); | 106 void LoadQuicServerInfo(QuicCryptoClientConfig::CachedState* cached); |
105 | 107 |
| 108 // Should be aclled whenever cached->SetProofValid() is called. |
| 109 // TODO(rch): move this to some chrome-specific class. |
| 110 void SaveQuicServerInfo(const QuicCryptoClientConfig::CachedState& cached); |
| 111 |
106 State next_state_; | 112 State next_state_; |
107 // num_client_hellos_ contains the number of client hello messages that this | 113 // num_client_hellos_ contains the number of client hello messages that this |
108 // connection has sent. | 114 // connection has sent. |
109 int num_client_hellos_; | 115 int num_client_hellos_; |
110 | 116 |
111 QuicCryptoClientConfig* const crypto_config_; | 117 QuicCryptoClientConfig* const crypto_config_; |
112 | 118 |
113 // Client's connection nonce (4-byte timestamp + 28 random bytes) | 119 // Client's connection nonce (4-byte timestamp + 28 random bytes) |
114 std::string nonce_; | 120 std::string nonce_; |
115 // Server's hostname | 121 // Server's hostname |
116 std::string server_hostname_; | 122 std::string server_hostname_; |
117 | 123 |
118 // Generation counter from QuicCryptoClientConfig's CachedState. | 124 // Generation counter from QuicCryptoClientConfig's CachedState. |
119 uint64 generation_counter_; | 125 uint64 generation_counter_; |
120 | 126 |
121 // proof_verify_callback_ contains the callback object that we passed to an | 127 // proof_verify_callback_ contains the callback object that we passed to an |
122 // asynchronous proof verification. The ProofVerifier owns this object. | 128 // asynchronous proof verification. The ProofVerifier owns this object. |
123 ProofVerifierCallbackImpl* proof_verify_callback_; | 129 ProofVerifierCallbackImpl* proof_verify_callback_; |
124 | 130 |
125 // These members are used to store the result of an asynchronous proof | 131 // These members are used to store the result of an asynchronous proof |
126 // verification. These members must not be used after | 132 // verification. These members must not be used after |
127 // STATE_VERIFY_PROOF_COMPLETE. | 133 // STATE_VERIFY_PROOF_COMPLETE. |
128 bool verify_ok_; | 134 bool verify_ok_; |
129 string verify_error_details_; | 135 string verify_error_details_; |
130 scoped_ptr<ProofVerifyDetails> verify_details_; | 136 scoped_ptr<ProofVerifyDetails> verify_details_; |
131 | 137 |
132 // The result of certificate verification. | 138 // The result of certificate verification. |
133 scoped_ptr<CertVerifyResult> cert_verify_result_; | 139 scoped_ptr<CertVerifyResult> cert_verify_result_; |
134 | 140 |
| 141 scoped_ptr<QuicServerInfo> quic_server_info_; |
| 142 |
135 // This member is used to store the result of an asynchronous disk cache read. | 143 // This member is used to store the result of an asynchronous disk cache read. |
136 // It must not be used after STATE_LOAD_QUIC_SERVER_INFO_COMPLETE. | 144 // It must not be used after STATE_LOAD_QUIC_SERVER_INFO_COMPLETE. |
137 int disk_cache_load_result_; | 145 int disk_cache_load_result_; |
138 | 146 |
139 // Time when call to WaitForDataReady was made, used for computing time spent | 147 // Time when call to WaitForDataReady was made, used for computing time spent |
140 // to load QUIC server information from disk cache. | 148 // to load QUIC server information from disk cache. |
141 base::TimeTicks disk_cache_load_start_time_; | 149 base::TimeTicks disk_cache_load_start_time_; |
142 | 150 |
143 base::WeakPtrFactory<QuicCryptoClientStream> weak_factory_; | 151 base::WeakPtrFactory<QuicCryptoClientStream> weak_factory_; |
144 | 152 |
145 DISALLOW_COPY_AND_ASSIGN(QuicCryptoClientStream); | 153 DISALLOW_COPY_AND_ASSIGN(QuicCryptoClientStream); |
146 }; | 154 }; |
147 | 155 |
148 } // namespace net | 156 } // namespace net |
149 | 157 |
150 #endif // NET_QUIC_QUIC_CRYPTO_CLIENT_STREAM_H_ | 158 #endif // NET_QUIC_QUIC_CRYPTO_CLIENT_STREAM_H_ |
OLD | NEW |