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_QUIC_CHROMIUM_CLIENT_SESSION_H_ | 10 #ifndef NET_QUIC_QUIC_CHROMIUM_CLIENT_SESSION_H_ |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
156 QuicChromiumClientStream** stream); | 156 QuicChromiumClientStream** stream); |
157 | 157 |
158 // Cancels the pending stream creation request. | 158 // Cancels the pending stream creation request. |
159 void CancelRequest(StreamRequest* request); | 159 void CancelRequest(StreamRequest* request); |
160 | 160 |
161 // QuicChromiumPacketWriter::Delegate override. | 161 // QuicChromiumPacketWriter::Delegate override. |
162 int HandleWriteError(int error_code, | 162 int HandleWriteError(int error_code, |
163 scoped_refptr<StringIOBuffer> last_packet) override; | 163 scoped_refptr<StringIOBuffer> last_packet) override; |
164 void OnWriteError(int error_code) override; | 164 void OnWriteError(int error_code) override; |
165 void OnWriteUnblocked() override; | 165 void OnWriteUnblocked() override; |
166 bool ShouldWriteBlock() override; | |
166 | 167 |
167 // QuicSpdySession methods: | 168 // QuicSpdySession methods: |
168 void OnHeadersHeadOfLineBlocking(QuicTime::Delta delta) override; | 169 void OnHeadersHeadOfLineBlocking(QuicTime::Delta delta) override; |
169 | 170 |
170 // QuicSession methods: | 171 // QuicSession methods: |
171 void OnStreamFrame(const QuicStreamFrame& frame) override; | 172 void OnStreamFrame(const QuicStreamFrame& frame) override; |
172 QuicChromiumClientStream* CreateOutgoingDynamicStream( | 173 QuicChromiumClientStream* CreateOutgoingDynamicStream( |
173 SpdyPriority priority) override; | 174 SpdyPriority priority) override; |
174 QuicCryptoClientStream* GetCryptoStream() override; | 175 QuicCryptoClientStream* GetCryptoStream() override; |
175 void CloseStream(QuicStreamId stream_id) override; | 176 void CloseStream(QuicStreamId stream_id) override; |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
246 | 247 |
247 // Returns true if |hostname| may be pooled onto this session. If this | 248 // Returns true if |hostname| may be pooled onto this session. If this |
248 // is a secure QUIC session, then |hostname| must match the certificate | 249 // is a secure QUIC session, then |hostname| must match the certificate |
249 // presented during the handshake. | 250 // presented during the handshake. |
250 bool CanPool(const std::string& hostname, PrivacyMode privacy_mode) const; | 251 bool CanPool(const std::string& hostname, PrivacyMode privacy_mode) const; |
251 | 252 |
252 const QuicServerId& server_id() const { return server_id_; } | 253 const QuicServerId& server_id() const { return server_id_; } |
253 | 254 |
254 QuicDisabledReason disabled_reason() const { return disabled_reason_; } | 255 QuicDisabledReason disabled_reason() const { return disabled_reason_; } |
255 | 256 |
257 // Attempts to migrate session when a write error is encountered. | |
258 void MigrateSessionOnWriteError(); | |
259 | |
260 // Helper method that writes a packet on the new socket after | |
261 // migration completes. If not null, the packet_ member is written, | |
262 // else a PING packet is written. | |
263 void WriteToNewSocket(); | |
264 | |
256 // Migrates session onto new socket, i.e., starts reading from | 265 // Migrates session onto new socket, i.e., starts reading from |
257 // |socket| in addition to any previous sockets, and sets |writer| | 266 // |socket| in addition to any previous sockets, and sets |writer| |
258 // to be the new default writer. Returns true if socket was | 267 // to be the new default writer. Returns true if socket was |
259 // successfully added to the session and the session was | 268 // successfully added to the session and the session was |
260 // successfully migrated to using the new socket. If not null, | 269 // successfully migrated to using the new socket. Returns true on |
261 // |packet| is sent on the new network, else a PING frame is | 270 // successful migration, or false if number of migrations exceeds |
262 // sent. Returns true on successful migration, or false if number of | 271 // kMaxReadersPerQuicSession. Takes ownership of |socket|, |reader|, |
263 // migrations exceeds kMaxReadersPerQuicSession. Takes ownership of | 272 // and |writer|. |
264 // |socket|, |reader|, and |writer|. | |
265 bool MigrateToSocket(std::unique_ptr<DatagramClientSocket> socket, | 273 bool MigrateToSocket(std::unique_ptr<DatagramClientSocket> socket, |
266 std::unique_ptr<QuicChromiumPacketReader> reader, | 274 std::unique_ptr<QuicChromiumPacketReader> reader, |
267 std::unique_ptr<QuicChromiumPacketWriter> writer, | 275 std::unique_ptr<QuicChromiumPacketWriter> writer); |
268 scoped_refptr<StringIOBuffer> packet); | |
269 | 276 |
270 // Populates network error details for this session. | 277 // Populates network error details for this session. |
271 void PopulateNetErrorDetails(NetErrorDetails* details); | 278 void PopulateNetErrorDetails(NetErrorDetails* details); |
272 | 279 |
273 // Returns current default socket. This is the socket over which all | 280 // Returns current default socket. This is the socket over which all |
274 // QUIC packets are sent. This default socket can change, so do not store the | 281 // QUIC packets are sent. This default socket can change, so do not store the |
275 // returned socket. | 282 // returned socket. |
276 const DatagramClientSocket* GetDefaultSocket() const; | 283 const DatagramClientSocket* GetDefaultSocket() const; |
277 | 284 |
278 bool IsAuthorized(const std::string& hostname) override; | 285 bool IsAuthorized(const std::string& hostname) override; |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
358 // True when the session is going away, and streams may no longer be created | 365 // True when the session is going away, and streams may no longer be created |
359 // on this session. Existing stream will continue to be processed. | 366 // on this session. Existing stream will continue to be processed. |
360 bool going_away_; | 367 bool going_away_; |
361 // True when the session receives a go away from server due to port migration. | 368 // True when the session receives a go away from server due to port migration. |
362 bool port_migration_detected_; | 369 bool port_migration_detected_; |
363 QuicDisabledReason disabled_reason_; | 370 QuicDisabledReason disabled_reason_; |
364 TokenBindingSignatureMap token_binding_signatures_; | 371 TokenBindingSignatureMap token_binding_signatures_; |
365 // UMA histogram counters for streams pushed to this session. | 372 // UMA histogram counters for streams pushed to this session. |
366 int streams_pushed_count_; | 373 int streams_pushed_count_; |
367 int streams_pushed_and_claimed_count_; | 374 int streams_pushed_and_claimed_count_; |
368 // Return value from packet rewrite packet on new socket. Used | 375 // Stores packet that witnesses socket write error. This packet is |
369 // during connection migration on socket write error. | 376 // written to a new socket after migration completes. |
370 int error_code_from_rewrite_; | 377 scoped_refptr<StringIOBuffer> packet_; |
371 bool use_error_code_from_rewrite_; | 378 bool migration_pending_; // True while migration is underway. |
379 bool should_write_block_; // True if the writer should write block. | |
Ryan Hamilton
2016/09/11 15:38:42
Instead of doings this, it might just be easier to
Jana
2016/09/11 18:32:30
Given that the delegate is part of the process any
Ryan Hamilton
2016/09/11 20:44:24
That's a fair point. I think set_write_blocked() m
Jana
2016/09/11 21:37:40
Fair enough. Done.
| |
372 base::WeakPtrFactory<QuicChromiumClientSession> weak_factory_; | 380 base::WeakPtrFactory<QuicChromiumClientSession> weak_factory_; |
373 | 381 |
374 DISALLOW_COPY_AND_ASSIGN(QuicChromiumClientSession); | 382 DISALLOW_COPY_AND_ASSIGN(QuicChromiumClientSession); |
375 }; | 383 }; |
376 | 384 |
377 } // namespace net | 385 } // namespace net |
378 | 386 |
379 #endif // NET_QUIC_QUIC_CHROMIUM_CLIENT_SESSION_H_ | 387 #endif // NET_QUIC_QUIC_CHROMIUM_CLIENT_SESSION_H_ |
OLD | NEW |