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

Side by Side Diff: net/quic/core/crypto/quic_crypto_server_config.h

Issue 2353763002: Use refcounted ownership for ValidateClientHelloResultCallback::Result (Closed)
Patch Set: Created 4 years, 3 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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_CRYPTO_QUIC_CRYPTO_SERVER_CONFIG_H_ 5 #ifndef NET_QUIC_CRYPTO_QUIC_CRYPTO_SERVER_CONFIG_H_
6 #define NET_QUIC_CRYPTO_QUIC_CRYPTO_SERVER_CONFIG_H_ 6 #define NET_QUIC_CRYPTO_QUIC_CRYPTO_SERVER_CONFIG_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 10
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 82
83 private: 83 private:
84 DISALLOW_COPY_AND_ASSIGN(PrimaryConfigChangedCallback); 84 DISALLOW_COPY_AND_ASSIGN(PrimaryConfigChangedCallback);
85 }; 85 };
86 86
87 // Callback used to accept the result of the |client_hello| validation step. 87 // Callback used to accept the result of the |client_hello| validation step.
88 class NET_EXPORT_PRIVATE ValidateClientHelloResultCallback { 88 class NET_EXPORT_PRIVATE ValidateClientHelloResultCallback {
89 public: 89 public:
90 // Opaque token that holds information about the client_hello and 90 // Opaque token that holds information about the client_hello and
91 // its validity. Can be interpreted by calling ProcessClientHello. 91 // its validity. Can be interpreted by calling ProcessClientHello.
92 struct NET_EXPORT_PRIVATE Result { 92 struct NET_EXPORT_PRIVATE Result : public base::RefCountedThreadSafe<Result> {
93 Result(const CryptoHandshakeMessage& in_client_hello, 93 Result(const CryptoHandshakeMessage& in_client_hello,
94 IPAddress in_client_ip, 94 IPAddress in_client_ip,
95 QuicWallTime in_now); 95 QuicWallTime in_now);
96 ~Result();
97 96
98 CryptoHandshakeMessage client_hello; 97 CryptoHandshakeMessage client_hello;
99 ClientHelloInfo info; 98 ClientHelloInfo info;
100 QuicErrorCode error_code; 99 QuicErrorCode error_code;
101 std::string error_details; 100 std::string error_details;
102 101
103 // Populated if the CHLO STK contained a CachedNetworkParameters proto. 102 // Populated if the CHLO STK contained a CachedNetworkParameters proto.
104 CachedNetworkParameters cached_network_params; 103 CachedNetworkParameters cached_network_params;
104
105 private:
106 friend class base::RefCountedThreadSafe<Result>;
107 ~Result();
105 }; 108 };
106 109
107 ValidateClientHelloResultCallback(); 110 ValidateClientHelloResultCallback();
111 virtual void Run(scoped_refptr<Result> result,
112 std::unique_ptr<ProofSource::Details> details) = 0;
108 virtual ~ValidateClientHelloResultCallback(); 113 virtual ~ValidateClientHelloResultCallback();
109 virtual void Run(std::unique_ptr<Result> result,
110 std::unique_ptr<ProofSource::Details> details) = 0;
111 114
112 private: 115 private:
113 DISALLOW_COPY_AND_ASSIGN(ValidateClientHelloResultCallback); 116 DISALLOW_COPY_AND_ASSIGN(ValidateClientHelloResultCallback);
114 }; 117 };
115 118
116 // Callback used to receive the results of a call to 119 // Callback used to receive the results of a call to
117 // BuildServerConfigUpdateMessage. 120 // BuildServerConfigUpdateMessage.
118 class BuildServerConfigUpdateMessageResultCallback { 121 class BuildServerConfigUpdateMessageResultCallback {
119 public: 122 public:
120 BuildServerConfigUpdateMessageResultCallback() = default; 123 BuildServerConfigUpdateMessageResultCallback() = default;
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 // a proof demand. 281 // a proof demand.
279 // total_framing_overhead: the total per-packet overhead for a stream frame 282 // total_framing_overhead: the total per-packet overhead for a stream frame
280 // chlo_packet_size: the size, in bytes, of the CHLO packet 283 // chlo_packet_size: the size, in bytes, of the CHLO packet
281 // out: the resulting handshake message (either REJ or SHLO) 284 // out: the resulting handshake message (either REJ or SHLO)
282 // out_diversification_nonce: If the resulting handshake message is SHLO and 285 // out_diversification_nonce: If the resulting handshake message is SHLO and
283 // the version is greater than QUIC_VERSION_32 then this contains a 286 // the version is greater than QUIC_VERSION_32 then this contains a
284 // 32-byte value that should be included in the public header of 287 // 32-byte value that should be included in the public header of
285 // initially encrypted packets. 288 // initially encrypted packets.
286 // error_details: used to store a std::string describing any error. 289 // error_details: used to store a std::string describing any error.
287 QuicErrorCode ProcessClientHello( 290 QuicErrorCode ProcessClientHello(
288 const ValidateClientHelloResultCallback::Result& validate_chlo_result, 291 scoped_refptr<ValidateClientHelloResultCallback::Result>
292 validate_chlo_result,
289 bool reject_only, 293 bool reject_only,
290 QuicConnectionId connection_id, 294 QuicConnectionId connection_id,
291 const IPAddress& server_ip, 295 const IPAddress& server_ip,
292 const IPEndPoint& client_address, 296 const IPEndPoint& client_address,
293 QuicVersion version, 297 QuicVersion version,
294 const QuicVersionVector& supported_versions, 298 const QuicVersionVector& supported_versions,
295 bool use_stateless_rejects, 299 bool use_stateless_rejects,
296 QuicConnectionId server_designated_connection_id, 300 QuicConnectionId server_designated_connection_id,
297 const QuicClock* clock, 301 const QuicClock* clock,
298 QuicRandom* rand, 302 QuicRandom* rand,
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
511 // EvaluateClientHello checks |client_hello| for gross errors and determines 515 // EvaluateClientHello checks |client_hello| for gross errors and determines
512 // whether it can be shown to be fresh (i.e. not a replay). The results are 516 // whether it can be shown to be fresh (i.e. not a replay). The results are
513 // written to |info|. 517 // written to |info|.
514 void EvaluateClientHello( 518 void EvaluateClientHello(
515 const IPAddress& server_ip, 519 const IPAddress& server_ip,
516 QuicVersion version, 520 QuicVersion version,
517 const uint8_t* primary_orbit, 521 const uint8_t* primary_orbit,
518 scoped_refptr<Config> requested_config, 522 scoped_refptr<Config> requested_config,
519 scoped_refptr<Config> primary_config, 523 scoped_refptr<Config> primary_config,
520 QuicCryptoProof* crypto_proof, 524 QuicCryptoProof* crypto_proof,
521 std::unique_ptr<ValidateClientHelloResultCallback::Result> 525 scoped_refptr<ValidateClientHelloResultCallback::Result>
522 client_hello_state, 526 client_hello_state,
523 std::unique_ptr<ValidateClientHelloResultCallback> done_cb) const; 527 std::unique_ptr<ValidateClientHelloResultCallback> done_cb) const;
524 528
525 // Callback class for bridging between EvaluateClientHello and 529 // Callback class for bridging between EvaluateClientHello and
526 // EvaluateClientHelloAfterGetProof 530 // EvaluateClientHelloAfterGetProof.
531 class EvaluateClientHelloCallback;
527 friend class EvaluateClientHelloCallback; 532 friend class EvaluateClientHelloCallback;
528 533
529 // Continuation of EvaluateClientHello after the call to 534 // Continuation of EvaluateClientHello after the call to
530 // ProofSource::GetProof. |found_error| indicates whether an error was 535 // ProofSource::GetProof. |found_error| indicates whether an error was
531 // detected in EvaluateClientHello, and |get_proof_failed| indicates whether 536 // detected in EvaluateClientHello, and |get_proof_failed| indicates whether
532 // GetProof failed. If GetProof was not run, then |get_proof_failed| will be 537 // GetProof failed. If GetProof was not run, then |get_proof_failed| will be
533 // set to false. 538 // set to false.
534 void EvaluateClientHelloAfterGetProof( 539 void EvaluateClientHelloAfterGetProof(
535 bool found_error, 540 bool found_error,
536 const IPAddress& server_ip, 541 const IPAddress& server_ip,
537 QuicVersion version, 542 QuicVersion version,
538 const uint8_t* primary_orbit, 543 const uint8_t* primary_orbit,
539 scoped_refptr<Config> requested_config, 544 scoped_refptr<Config> requested_config,
540 scoped_refptr<Config> primary_config, 545 scoped_refptr<Config> primary_config,
541 QuicCryptoProof* crypto_proof, 546 QuicCryptoProof* crypto_proof,
542 std::unique_ptr<ProofSource::Details> proof_source_details, 547 std::unique_ptr<ProofSource::Details> proof_source_details,
543 bool get_proof_failed, 548 bool get_proof_failed,
544 std::unique_ptr<ValidateClientHelloResultCallback::Result> 549 scoped_refptr<ValidateClientHelloResultCallback::Result>
545 client_hello_state, 550 client_hello_state,
546 std::unique_ptr<ValidateClientHelloResultCallback> done_cb) const; 551 std::unique_ptr<ValidateClientHelloResultCallback> done_cb) const;
547 552
548 // BuildRejection sets |out| to be a REJ message in reply to |client_hello|. 553 // BuildRejection sets |out| to be a REJ message in reply to |client_hello|.
549 void BuildRejection(QuicVersion version, 554 void BuildRejection(QuicVersion version,
550 QuicWallTime now, 555 QuicWallTime now,
551 const Config& config, 556 const Config& config,
552 const CryptoHandshakeMessage& client_hello, 557 const CryptoHandshakeMessage& client_hello,
553 const ClientHelloInfo& info, 558 const ClientHelloInfo& info,
554 const CachedNetworkParameters& cached_network_params, 559 const CachedNetworkParameters& cached_network_params,
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
791 std::string cert_sct; 796 std::string cert_sct;
792 // The server config that is used for this proof (and the rest of the 797 // The server config that is used for this proof (and the rest of the
793 // request). 798 // request).
794 scoped_refptr<QuicCryptoServerConfig::Config> config; 799 scoped_refptr<QuicCryptoServerConfig::Config> config;
795 std::string primary_scid; 800 std::string primary_scid;
796 }; 801 };
797 802
798 } // namespace net 803 } // namespace net
799 804
800 #endif // NET_QUIC_CRYPTO_QUIC_CRYPTO_SERVER_CONFIG_H_ 805 #endif // NET_QUIC_CRYPTO_QUIC_CRYPTO_SERVER_CONFIG_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698