Remove PlatformFile from profile_browsertest
[chromium-blink-merge.git] / net / quic / quic_crypto_server_stream.h
blob546c3bd4cf13cb896fb8dff0b37d4b459d376c2b
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
3 // found in the LICENSE file.
5 #ifndef NET_QUIC_QUIC_CRYPTO_SERVER_STREAM_H_
6 #define NET_QUIC_QUIC_CRYPTO_SERVER_STREAM_H_
8 #include <string>
10 #include "net/quic/crypto/crypto_handshake.h"
11 #include "net/quic/crypto/quic_crypto_server_config.h"
12 #include "net/quic/quic_config.h"
13 #include "net/quic/quic_crypto_stream.h"
15 namespace net {
17 class CryptoHandshakeMessage;
18 class QuicCryptoServerConfig;
19 class QuicSession;
21 namespace test {
22 class CryptoTestUtils;
23 } // namespace test
25 class NET_EXPORT_PRIVATE QuicCryptoServerStream : public QuicCryptoStream {
26 public:
27 QuicCryptoServerStream(const QuicCryptoServerConfig& crypto_config,
28 QuicSession* session);
29 explicit QuicCryptoServerStream(QuicSession* session);
30 virtual ~QuicCryptoServerStream();
32 // Cancel any outstanding callbacks, such as asynchronous validation of client
33 // hello.
34 void CancelOutstandingCallbacks();
36 // CryptoFramerVisitorInterface implementation
37 virtual void OnHandshakeMessage(
38 const CryptoHandshakeMessage& message) OVERRIDE;
40 // GetBase64SHA256ClientChannelID sets |*output| to the base64 encoded,
41 // SHA-256 hash of the client's ChannelID key and returns true, if the client
42 // presented a ChannelID. Otherwise it returns false.
43 bool GetBase64SHA256ClientChannelID(std::string* output) const;
45 protected:
46 virtual QuicErrorCode ProcessClientHello(
47 const CryptoHandshakeMessage& message,
48 const ValidateClientHelloResultCallback::Result& result,
49 CryptoHandshakeMessage* reply,
50 std::string* error_details);
52 private:
53 friend class test::CryptoTestUtils;
55 class ValidateCallback : public ValidateClientHelloResultCallback {
56 public:
57 explicit ValidateCallback(QuicCryptoServerStream* parent);
58 // To allow the parent to detach itself from the callback before deletion.
59 void Cancel();
61 // From ValidateClientHelloResultCallback
62 virtual void RunImpl(const CryptoHandshakeMessage& client_hello,
63 const Result& result) OVERRIDE;
65 private:
66 QuicCryptoServerStream* parent_;
68 DISALLOW_COPY_AND_ASSIGN(ValidateCallback);
71 // Invoked by ValidateCallback::RunImpl once initial validation of
72 // the client hello is complete. Finishes processing of the client
73 // hello message and handles handshake success/failure.
74 void FinishProcessingHandshakeMessage(
75 const CryptoHandshakeMessage& message,
76 const ValidateClientHelloResultCallback::Result& result);
78 // crypto_config_ contains crypto parameters for the handshake.
79 const QuicCryptoServerConfig& crypto_config_;
81 // Pointer to the active callback that will receive the result of
82 // the client hello validation request and forward it to
83 // FinishProcessingHandshakeMessage for processing. NULL if no
84 // handshake message is being validated.
85 ValidateCallback* validate_client_hello_cb_;
88 } // namespace net
90 #endif // NET_QUIC_QUIC_CRYPTO_SERVER_STREAM_H_