OLD | NEW |
| (Empty) |
1 // Copyright (c) 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_QUIC_QUIC_CLIENT_PROMISED_INFO_H_ | |
6 #define NET_QUIC_QUIC_CLIENT_PROMISED_INFO_H_ | |
7 | |
8 #include <sys/types.h> | |
9 #include <string> | |
10 | |
11 #include "net/quic/quic_alarm.h" | |
12 #include "net/quic/quic_client_push_promise_index.h" | |
13 #include "net/quic/quic_client_session_base.h" | |
14 #include "net/quic/quic_protocol.h" | |
15 #include "net/quic/quic_spdy_stream.h" | |
16 #include "net/spdy/spdy_framer.h" | |
17 | |
18 namespace net { | |
19 | |
20 class QuicClientSessionBase; | |
21 class QuicDataToResend; | |
22 class QuicConnectionHelperInterface; | |
23 | |
24 namespace test { | |
25 class QuicClientPromisedInfoPeer; | |
26 } // namespace test | |
27 | |
28 // QuicClientPromisedInfo tracks the client state of a server push | |
29 // stream from the time a PUSH_PROMISE is received until rendezvous | |
30 // between the promised response and the corresponding client request | |
31 // is complete. | |
32 class NET_EXPORT_PRIVATE QuicClientPromisedInfo | |
33 : public QuicClientPushPromiseIndex::TryHandle { | |
34 public: | |
35 // Interface to QuicSpdyClientStream | |
36 QuicClientPromisedInfo(QuicClientSessionBase* session, | |
37 QuicStreamId id, | |
38 std::string url); | |
39 virtual ~QuicClientPromisedInfo(); | |
40 | |
41 void Init(); | |
42 | |
43 // Validate promise headers etc. | |
44 void OnPromiseHeaders(const SpdyHeaderBlock& request_headers); | |
45 | |
46 // Store response, possibly proceed with final validation. | |
47 void OnResponseHeaders(const SpdyHeaderBlock& response_headers); | |
48 | |
49 // Rendezvous between this promised stream and a client request that | |
50 // has a matching URL. | |
51 virtual QuicAsyncStatus HandleClientRequest( | |
52 const SpdyHeaderBlock& headers, | |
53 QuicClientPushPromiseIndex::Delegate* delegate); | |
54 | |
55 void Cancel() override; | |
56 | |
57 void Reset(QuicRstStreamErrorCode error_code); | |
58 | |
59 // Client requests are initially associated to promises by matching | |
60 // URL in the client request against the URL in the promise headers, | |
61 // uing the |promised_by_url| map. The push can be cross-origin, so | |
62 // the client should validate that the session is authoritative for | |
63 // the promised URL. If not, it should call |RejectUnauthorized|. | |
64 QuicClientSessionBase* session() { return session_; } | |
65 | |
66 // If the promised response contains Vary header, then the fields | |
67 // specified by Vary must match between the client request header | |
68 // and the promise headers (see https://crbug.com//554220). Vary | |
69 // validation requires the response headers (for the actual Vary | |
70 // field list), the promise headers (taking the role of the "cached" | |
71 // request), and the client request headers. | |
72 SpdyHeaderBlock* request_headers() { return request_headers_.get(); } | |
73 | |
74 SpdyHeaderBlock* response_headers() { return response_headers_.get(); } | |
75 | |
76 QuicStreamId id() const { return id_; } | |
77 | |
78 const std::string url() const { return url_; } | |
79 | |
80 private: | |
81 friend class test::QuicClientPromisedInfoPeer; | |
82 | |
83 class CleanupAlarm : public QuicAlarm::Delegate { | |
84 public: | |
85 explicit CleanupAlarm(QuicClientPromisedInfo* promised) | |
86 : promised_(promised) {} | |
87 | |
88 void OnAlarm() override; | |
89 | |
90 QuicClientPromisedInfo* promised_; | |
91 }; | |
92 | |
93 QuicAsyncStatus FinalValidation(); | |
94 | |
95 QuicClientSessionBase* session_; | |
96 QuicStreamId id_; | |
97 std::string url_; | |
98 std::unique_ptr<SpdyHeaderBlock> request_headers_; | |
99 std::unique_ptr<SpdyHeaderBlock> response_headers_; | |
100 std::unique_ptr<SpdyHeaderBlock> client_request_headers_; | |
101 QuicClientPushPromiseIndex::Delegate* client_request_delegate_; | |
102 | |
103 // The promise will commit suicide eventually if it is not claimed | |
104 // by a GET first. | |
105 std::unique_ptr<QuicAlarm> cleanup_alarm_; | |
106 | |
107 DISALLOW_COPY_AND_ASSIGN(QuicClientPromisedInfo); | |
108 }; | |
109 | |
110 } // namespace net | |
111 | |
112 #endif // NET_QUIC_QUIC_CLIENT_PROMISED_INFO_H_ | |
OLD | NEW |