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 // A client specific QuicSession subclass. This class owns the underlying | 5 // A client specific QuicSession subclass. This class owns the underlying |
6 // QuicConnection and QuicConnectionHelper objects. The connection stores | 6 // QuicConnection and QuicConnectionHelper objects. The connection stores |
7 // a non-owning pointer to the helper so this session needs to ensure that | 7 // a non-owning pointer to the helper so this session needs to ensure that |
8 // the helper outlives the connection. | 8 // the helper outlives the connection. |
9 | 9 |
10 #ifndef NET_QUIC_CHROMIUM_QUIC_CHROMIUM_CLIENT_SESSION_H_ | 10 #ifndef NET_QUIC_CHROMIUM_QUIC_CHROMIUM_CLIENT_SESSION_H_ |
(...skipping 14 matching lines...) Expand all Loading... | |
25 #include "net/base/load_timing_info.h" | 25 #include "net/base/load_timing_info.h" |
26 #include "net/base/net_error_details.h" | 26 #include "net/base/net_error_details.h" |
27 #include "net/base/net_export.h" | 27 #include "net/base/net_export.h" |
28 #include "net/cert/ct_verify_result.h" | 28 #include "net/cert/ct_verify_result.h" |
29 #include "net/log/net_log_with_source.h" | 29 #include "net/log/net_log_with_source.h" |
30 #include "net/proxy/proxy_server.h" | 30 #include "net/proxy/proxy_server.h" |
31 #include "net/quic/chromium/quic_chromium_client_stream.h" | 31 #include "net/quic/chromium/quic_chromium_client_stream.h" |
32 #include "net/quic/chromium/quic_chromium_packet_reader.h" | 32 #include "net/quic/chromium/quic_chromium_packet_reader.h" |
33 #include "net/quic/chromium/quic_chromium_packet_writer.h" | 33 #include "net/quic/chromium/quic_chromium_packet_writer.h" |
34 #include "net/quic/chromium/quic_connection_logger.h" | 34 #include "net/quic/chromium/quic_connection_logger.h" |
35 #include "net/quic/core/quic_client_push_promise_index.h" | |
35 #include "net/quic/core/quic_client_session_base.h" | 36 #include "net/quic/core/quic_client_session_base.h" |
36 #include "net/quic/core/quic_crypto_client_stream.h" | 37 #include "net/quic/core/quic_crypto_client_stream.h" |
37 #include "net/quic/core/quic_packets.h" | 38 #include "net/quic/core/quic_packets.h" |
38 #include "net/quic/core/quic_server_id.h" | 39 #include "net/quic/core/quic_server_id.h" |
39 #include "net/quic/core/quic_time.h" | 40 #include "net/quic/core/quic_time.h" |
40 #include "net/socket/socket_performance_watcher.h" | 41 #include "net/socket/socket_performance_watcher.h" |
41 #include "net/spdy/chromium/multiplexed_session.h" | 42 #include "net/spdy/chromium/multiplexed_session.h" |
42 #include "net/spdy/chromium/server_push_delegate.h" | 43 #include "net/spdy/chromium/server_push_delegate.h" |
43 | 44 |
44 namespace net { | 45 namespace net { |
(...skipping 19 matching lines...) Expand all Loading... | |
64 : public QuicClientSessionBase, | 65 : public QuicClientSessionBase, |
65 public MultiplexedSession, | 66 public MultiplexedSession, |
66 public QuicChromiumPacketReader::Visitor, | 67 public QuicChromiumPacketReader::Visitor, |
67 public QuicChromiumPacketWriter::Delegate { | 68 public QuicChromiumPacketWriter::Delegate { |
68 public: | 69 public: |
69 class StreamRequest; | 70 class StreamRequest; |
70 | 71 |
71 // Wrapper for interacting with the session in a restricted fashion which | 72 // Wrapper for interacting with the session in a restricted fashion which |
72 // hides the details of the underlying session's lifetime. All methods of | 73 // hides the details of the underlying session's lifetime. All methods of |
73 // the Handle are safe to use even after the underlying session is destroyed. | 74 // the Handle are safe to use even after the underlying session is destroyed. |
74 class NET_EXPORT_PRIVATE Handle : public MultiplexedSessionHandle { | 75 class NET_EXPORT_PRIVATE Handle |
76 : public MultiplexedSessionHandle, | |
77 public QuicClientPushPromiseIndex::Delegate { | |
75 public: | 78 public: |
76 explicit Handle(const base::WeakPtr<QuicChromiumClientSession>& session); | 79 explicit Handle(const base::WeakPtr<QuicChromiumClientSession>& session); |
77 Handle(const Handle& other) = delete; | 80 Handle(const Handle& other) = delete; |
78 ~Handle() override; | 81 ~Handle() override; |
79 | 82 |
80 // Returns true if the session is still connected. | 83 // Returns true if the session is still connected. |
81 bool IsConnected() const; | 84 bool IsConnected() const; |
82 | 85 |
83 // Returns true if the handshake has been confirmed. | 86 // Returns true if the handshake has been confirmed. |
84 bool IsCryptoHandshakeConfirmed() const; | 87 bool IsCryptoHandshakeConfirmed() const; |
85 | 88 |
89 // Starts a request to rendezvous with a promised a stream. If OK is | |
90 // returned, then |push_stream_| will be updated with the promised | |
91 // stream. If ERR_IO_PENDING is returned, then when the rendezvous is | |
92 // eventuallly completed |callback| will be called. | |
xunjieli
2017/06/21 20:55:28
nit: s/eventuallly/eventually
Ryan Hamilton
2017/06/21 22:24:51
Done.
| |
93 int RendezvousWithPromised(const SpdyHeaderBlock& headers, | |
94 const CompletionCallback& callback); | |
95 | |
86 // Starts a request to create a stream. If OK is returned, then | 96 // Starts a request to create a stream. If OK is returned, then |
87 // |stream_| will be updated with the newly created stream. If | 97 // |stream_| will be updated with the newly created stream. If |
88 // ERR_IO_PENDING is returned, then when the request is eventuallly | 98 // ERR_IO_PENDING is returned, then when the request is eventuallly |
89 // complete |callback| will be called. | 99 // complete |callback| will be called. |
90 int RequestStream(bool requires_confirmation, | 100 int RequestStream(bool requires_confirmation, |
91 const CompletionCallback& callback); | 101 const CompletionCallback& callback); |
92 | 102 |
93 // Releases |stream_| to the caller. | 103 // Releases |stream_| to the caller. |
94 std::unique_ptr<QuicChromiumClientStream::Handle> ReleaseStream(); | 104 std::unique_ptr<QuicChromiumClientStream::Handle> ReleaseStream(); |
95 | 105 |
106 // Releases |stream_| to the caller. | |
xunjieli
2017/06/21 20:55:28
nit: s/stream_/push_stream_
Ryan Hamilton
2017/06/21 22:24:51
Done.
| |
107 std::unique_ptr<QuicChromiumClientStream::Handle> ReleasePromisedStream(); | |
108 | |
96 // Sends Rst for the stream, and makes sure that future calls to | 109 // Sends Rst for the stream, and makes sure that future calls to |
97 // IsClosedStream(id) return true, which ensures that any subsequent | 110 // IsClosedStream(id) return true, which ensures that any subsequent |
98 // frames related to this stream will be ignored (modulo flow | 111 // frames related to this stream will be ignored (modulo flow |
99 // control accounting). | 112 // control accounting). |
100 void ResetPromised(QuicStreamId id, QuicRstStreamErrorCode error_code); | 113 void ResetPromised(QuicStreamId id, QuicRstStreamErrorCode error_code); |
101 | 114 |
102 // Returns a new packet bundler while will cause writes to be batched up | 115 // Returns a new packet bundler while will cause writes to be batched up |
103 // until a packet is full, or the last bundler is destroyed. | 116 // until a packet is full, or the last bundler is destroyed. |
104 std::unique_ptr<QuicConnection::ScopedPacketBundler> CreatePacketBundler( | 117 std::unique_ptr<QuicConnection::ScopedPacketBundler> CreatePacketBundler( |
105 QuicConnection::AckBundling bundling_mode); | 118 QuicConnection::AckBundling bundling_mode); |
(...skipping 22 matching lines...) Expand all Loading... | |
128 | 141 |
129 // Returns the push promise index associated with the session. | 142 // Returns the push promise index associated with the session. |
130 QuicClientPushPromiseIndex* GetPushPromiseIndex(); | 143 QuicClientPushPromiseIndex* GetPushPromiseIndex(); |
131 | 144 |
132 // Returns the session's server ID. | 145 // Returns the session's server ID. |
133 QuicServerId server_id() const { return server_id_; } | 146 QuicServerId server_id() const { return server_id_; } |
134 | 147 |
135 // Returns the session's net log. | 148 // Returns the session's net log. |
136 const NetLogWithSource& net_log() const { return net_log_; } | 149 const NetLogWithSource& net_log() const { return net_log_; } |
137 | 150 |
151 // QuicClientPushPromiseIndex::Delegate implementation | |
152 bool CheckVary(const SpdyHeaderBlock& client_request, | |
153 const SpdyHeaderBlock& promise_request, | |
154 const SpdyHeaderBlock& promise_response) override; | |
155 void OnRendezvousResult(QuicSpdyStream* stream) override; | |
156 | |
138 private: | 157 private: |
139 friend class QuicChromiumClientSession; | 158 friend class QuicChromiumClientSession; |
140 friend class QuicChromiumClientSession::StreamRequest; | 159 friend class QuicChromiumClientSession::StreamRequest; |
141 | 160 |
142 // Waits for the handshake to be confirmed and invokes |callback| when | 161 // Waits for the handshake to be confirmed and invokes |callback| when |
143 // that happens. If the handshake has already been confirmed, returns OK. | 162 // that happens. If the handshake has already been confirmed, returns OK. |
144 // If the connection has already been closed, returns a net error. If the | 163 // If the connection has already been closed, returns a net error. If the |
145 // connection closes before the handshake is confirmed, |callback| will | 164 // connection closes before the handshake is confirmed, |callback| will |
146 // be invoked with an error. | 165 // be invoked with an error. |
147 int WaitForHandshakeConfirmation(const CompletionCallback& callback); | 166 int WaitForHandshakeConfirmation(const CompletionCallback& callback); |
(...skipping 22 matching lines...) Expand all Loading... | |
170 // Information saved from the session which can be used even after the | 189 // Information saved from the session which can be used even after the |
171 // session is destroyed. | 190 // session is destroyed. |
172 NetLogWithSource net_log_; | 191 NetLogWithSource net_log_; |
173 bool was_handshake_confirmed_; | 192 bool was_handshake_confirmed_; |
174 int error_; | 193 int error_; |
175 bool port_migration_detected_; | 194 bool port_migration_detected_; |
176 QuicServerId server_id_; | 195 QuicServerId server_id_; |
177 QuicVersion quic_version_; | 196 QuicVersion quic_version_; |
178 LoadTimingInfo::ConnectTiming connect_timing_; | 197 LoadTimingInfo::ConnectTiming connect_timing_; |
179 QuicClientPushPromiseIndex* push_promise_index_; | 198 QuicClientPushPromiseIndex* push_promise_index_; |
199 | |
200 // |QuicClientPromisedInfo| owns this. It will be set when |Try()| | |
201 // is asynchronous, i.e. it returned QUIC_PENDING, and remains valid | |
202 // until |OnRendezvouResult()| fires or |push_handle_->Cancel()| is | |
203 // invoked. | |
204 QuicClientPushPromiseIndex::TryHandle* push_handle_; | |
205 CompletionCallback push_callback_; | |
206 std::unique_ptr<QuicChromiumClientStream::Handle> push_stream_; | |
180 }; | 207 }; |
181 | 208 |
182 // A helper class used to manage a request to create a stream. | 209 // A helper class used to manage a request to create a stream. |
183 class NET_EXPORT_PRIVATE StreamRequest { | 210 class NET_EXPORT_PRIVATE StreamRequest { |
184 public: | 211 public: |
185 // Cancels any pending stream creation request and resets |stream_| if | 212 // Cancels any pending stream creation request and resets |stream_| if |
186 // it has not yet been released. | 213 // it has not yet been released. |
187 ~StreamRequest(); | 214 ~StreamRequest(); |
188 | 215 |
189 // Starts a request to create a stream. If OK is returned, then | 216 // Starts a request to create a stream. If OK is returned, then |
(...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
533 // the current sockets_.size() == the passed in value. | 560 // the current sockets_.size() == the passed in value. |
534 bool migration_pending_; // True while migration is underway. | 561 bool migration_pending_; // True while migration is underway. |
535 base::WeakPtrFactory<QuicChromiumClientSession> weak_factory_; | 562 base::WeakPtrFactory<QuicChromiumClientSession> weak_factory_; |
536 | 563 |
537 DISALLOW_COPY_AND_ASSIGN(QuicChromiumClientSession); | 564 DISALLOW_COPY_AND_ASSIGN(QuicChromiumClientSession); |
538 }; | 565 }; |
539 | 566 |
540 } // namespace net | 567 } // namespace net |
541 | 568 |
542 #endif // NET_QUIC_CHROMIUM_QUIC_CHROMIUM_CLIENT_SESSION_H_ | 569 #endif // NET_QUIC_CHROMIUM_QUIC_CHROMIUM_CLIENT_SESSION_H_ |
OLD | NEW |