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 #include "net/quic/chromium/quic_chromium_client_session.h" | 5 #include "net/quic/chromium/quic_chromium_client_session.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/callback_helpers.h" | 9 #include "base/callback_helpers.h" |
10 #include "base/location.h" | 10 #include "base/location.h" |
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
294 if (!session_) | 294 if (!session_) |
295 return ERR_CONNECTION_CLOSED; | 295 return ERR_CONNECTION_CLOSED; |
296 | 296 |
297 // base::MakeUnique does not work because the StreamRequest constructor | 297 // base::MakeUnique does not work because the StreamRequest constructor |
298 // is private. | 298 // is private. |
299 stream_request_ = std::unique_ptr<StreamRequest>( | 299 stream_request_ = std::unique_ptr<StreamRequest>( |
300 new StreamRequest(this, requires_confirmation)); | 300 new StreamRequest(this, requires_confirmation)); |
301 return stream_request_->StartRequest(callback); | 301 return stream_request_->StartRequest(callback); |
302 } | 302 } |
303 | 303 |
304 QuicChromiumClientStream* QuicChromiumClientSession::Handle::ReleaseStream( | 304 std::unique_ptr<QuicChromiumClientStream::Handle> |
| 305 QuicChromiumClientSession::Handle::ReleaseStream( |
305 QuicChromiumClientStream::Delegate* delegate) { | 306 QuicChromiumClientStream::Delegate* delegate) { |
306 DCHECK(stream_request_); | 307 DCHECK(stream_request_); |
307 | 308 |
308 auto* stream = stream_request_->ReleaseStream(delegate); | 309 auto handle = stream_request_->ReleaseStream(delegate); |
309 stream_request_.reset(); | 310 stream_request_.reset(); |
310 return stream; | 311 return handle; |
311 } | 312 } |
312 | 313 |
313 int QuicChromiumClientSession::Handle::WaitForHandshakeConfirmation( | 314 int QuicChromiumClientSession::Handle::WaitForHandshakeConfirmation( |
314 const CompletionCallback& callback) { | 315 const CompletionCallback& callback) { |
315 if (!session_) | 316 if (!session_) |
316 return ERR_CONNECTION_CLOSED; | 317 return ERR_CONNECTION_CLOSED; |
317 | 318 |
318 return session_->WaitForHandshakeConfirmation(callback); | 319 return session_->WaitForHandshakeConfirmation(callback); |
319 } | 320 } |
320 | 321 |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
369 return ERR_CONNECTION_CLOSED; | 370 return ERR_CONNECTION_CLOSED; |
370 | 371 |
371 next_state_ = STATE_WAIT_FOR_CONFIRMATION; | 372 next_state_ = STATE_WAIT_FOR_CONFIRMATION; |
372 int rv = DoLoop(OK); | 373 int rv = DoLoop(OK); |
373 if (rv == ERR_IO_PENDING) | 374 if (rv == ERR_IO_PENDING) |
374 callback_ = callback; | 375 callback_ = callback; |
375 | 376 |
376 return rv; | 377 return rv; |
377 } | 378 } |
378 | 379 |
379 QuicChromiumClientStream* | 380 std::unique_ptr<QuicChromiumClientStream::Handle> |
380 QuicChromiumClientSession::StreamRequest::ReleaseStream( | 381 QuicChromiumClientSession::StreamRequest::ReleaseStream( |
381 QuicChromiumClientStream::Delegate* delegate) { | 382 QuicChromiumClientStream::Delegate* delegate) { |
382 DCHECK(stream_); | 383 DCHECK(stream_); |
383 QuicChromiumClientStream* stream = stream_; | 384 QuicChromiumClientStream* stream = stream_; |
384 stream_ = nullptr; | 385 stream_ = nullptr; |
385 stream->SetDelegate(delegate); | 386 return stream->CreateHandle(delegate); |
386 return stream; | |
387 } | 387 } |
388 | 388 |
389 void QuicChromiumClientSession::StreamRequest::OnRequestCompleteSuccess( | 389 void QuicChromiumClientSession::StreamRequest::OnRequestCompleteSuccess( |
390 QuicChromiumClientStream* stream) { | 390 QuicChromiumClientStream* stream) { |
391 DCHECK_EQ(STATE_REQUEST_STREAM_COMPLETE, next_state_); | 391 DCHECK_EQ(STATE_REQUEST_STREAM_COMPLETE, next_state_); |
392 | 392 |
393 stream_ = stream; | 393 stream_ = stream; |
394 // This method is called even when the request completes synchronously. | 394 // This method is called even when the request completes synchronously. |
395 if (callback_) | 395 if (callback_) |
396 DoCallback(OK); | 396 DoCallback(OK); |
(...skipping 1360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1757 } | 1757 } |
1758 | 1758 |
1759 size_t QuicChromiumClientSession::EstimateMemoryUsage() const { | 1759 size_t QuicChromiumClientSession::EstimateMemoryUsage() const { |
1760 // TODO(xunjieli): Estimate |crypto_stream_|, QuicSpdySession's | 1760 // TODO(xunjieli): Estimate |crypto_stream_|, QuicSpdySession's |
1761 // QuicHeaderList, QuicSession's QuiCWriteBlockedList, open streams and | 1761 // QuicHeaderList, QuicSession's QuiCWriteBlockedList, open streams and |
1762 // unacked packet map. | 1762 // unacked packet map. |
1763 return base::trace_event::EstimateMemoryUsage(packet_readers_); | 1763 return base::trace_event::EstimateMemoryUsage(packet_readers_); |
1764 } | 1764 } |
1765 | 1765 |
1766 } // namespace net | 1766 } // namespace net |
OLD | NEW |