OLD | NEW |
| (Empty) |
1 // Copyright 2016 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. | |
4 | |
5 #ifndef NET_SPDY_MULTIPLEXED_SESSION_H_ | |
6 #define NET_SPDY_MULTIPLEXED_SESSION_H_ | |
7 | |
8 #include <vector> | |
9 | |
10 #include "net/base/ip_endpoint.h" | |
11 #include "net/base/net_errors.h" | |
12 #include "net/http/http_stream.h" | |
13 #include "net/ssl/ssl_info.h" | |
14 #include "net/ssl/token_binding.h" | |
15 | |
16 namespace crypto { | |
17 class ECPrivateKey; | |
18 } // namespace crypto | |
19 | |
20 namespace net { | |
21 | |
22 // Base class for SPDY and QUIC sessions. | |
23 class NET_EXPORT_PRIVATE MultiplexedSession { | |
24 public: | |
25 virtual ~MultiplexedSession() {} | |
26 | |
27 // Fills SSL info in |ssl_info| and returns true when SSL is in use. | |
28 virtual bool GetSSLInfo(SSLInfo* ssl_info) const = 0; | |
29 | |
30 // Gets the remote endpoint of the socket that the HTTP stream is using, if | |
31 // any. Returns true and fills in |endpoint| if it is available; returns false | |
32 // and does not modify |endpoint| if it is unavailable. | |
33 virtual bool GetRemoteEndpoint(IPEndPoint* endpoint) = 0; | |
34 | |
35 // Generates the signature used in Token Binding using key |*key| and for a | |
36 // Token Binding of type |tb_type|, putting the signature in |*out|. Returns a | |
37 // net error code. | |
38 virtual Error GetTokenBindingSignature(crypto::ECPrivateKey* key, | |
39 TokenBindingType tb_type, | |
40 std::vector<uint8_t>* out) = 0; | |
41 }; | |
42 | |
43 // A handle to a multiplexed session which will be valid even after the | |
44 // underlying session is deleted. | |
45 class NET_EXPORT_PRIVATE MultiplexedSessionHandle { | |
46 public: | |
47 explicit MultiplexedSessionHandle(base::WeakPtr<MultiplexedSession> session); | |
48 MultiplexedSessionHandle(const MultiplexedSessionHandle& other); | |
49 MultiplexedSessionHandle(MultiplexedSessionHandle&& other); | |
50 ~MultiplexedSessionHandle(); | |
51 | |
52 // Gets the remote endpoint of the socket that the HTTP stream is using, if | |
53 // any. Returns true and fills in |endpoint| if it is available; returns false | |
54 // and does not modify |endpoint| if it is unavailable. | |
55 bool GetRemoteEndpoint(IPEndPoint* endpoint); | |
56 | |
57 // Fills SSL info in |ssl_info| and returns true when SSL is in use. | |
58 bool GetSSLInfo(SSLInfo* ssl_info) const; | |
59 | |
60 // Caches SSL info from the underlying session. | |
61 void SaveSSLInfo(); | |
62 | |
63 // Generates the signature used in Token Binding using key |*key| and for a | |
64 // Token Binding of type |tb_type|, putting the signature in |*out|. Returns a | |
65 // net error code. | |
66 Error GetTokenBindingSignature(crypto::ECPrivateKey* key, | |
67 TokenBindingType tb_type, | |
68 std::vector<uint8_t>* out); | |
69 | |
70 private: | |
71 base::WeakPtr<MultiplexedSession> session_; | |
72 SSLInfo ssl_info_; | |
73 bool has_ssl_info_; | |
74 }; | |
75 | |
76 } // namespace net | |
77 | |
78 #endif // NET_SPDY_MULTIPLEXED_SESSION_H_ | |
OLD | NEW |