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 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
289 bool requires_confirmation, | 289 bool requires_confirmation, |
290 const CompletionCallback& callback) { | 290 const CompletionCallback& callback) { |
291 DCHECK(!stream_request_); | 291 DCHECK(!stream_request_); |
292 | 292 |
293 if (!session_) | 293 if (!session_) |
294 return ERR_CONNECTION_CLOSED; | 294 return ERR_CONNECTION_CLOSED; |
295 | 295 |
296 // base::MakeUnique does not work because the StreamRequest constructor | 296 // base::MakeUnique does not work because the StreamRequest constructor |
297 // is private. | 297 // is private. |
298 stream_request_ = std::unique_ptr<StreamRequest>( | 298 stream_request_ = std::unique_ptr<StreamRequest>( |
299 new StreamRequest(session_->CreateHandle(), requires_confirmation)); | 299 new StreamRequest(this, requires_confirmation)); |
300 return stream_request_->StartRequest(callback); | 300 return stream_request_->StartRequest(callback); |
301 } | 301 } |
302 | 302 |
303 QuicChromiumClientStream* QuicChromiumClientSession::Handle::ReleaseStream() { | 303 QuicChromiumClientStream* QuicChromiumClientSession::Handle::ReleaseStream() { |
304 DCHECK(stream_request_); | 304 DCHECK(stream_request_); |
305 | 305 |
306 auto* stream = stream_request_->ReleaseStream(); | 306 auto* stream = stream_request_->ReleaseStream(); |
307 stream_request_.reset(); | 307 stream_request_.reset(); |
308 return stream; | 308 return stream; |
309 } | 309 } |
(...skipping 29 matching lines...) Expand all Loading... |
339 int QuicChromiumClientSession::Handle::GetPeerAddress( | 339 int QuicChromiumClientSession::Handle::GetPeerAddress( |
340 IPEndPoint* address) const { | 340 IPEndPoint* address) const { |
341 if (!session_) | 341 if (!session_) |
342 return ERR_CONNECTION_CLOSED; | 342 return ERR_CONNECTION_CLOSED; |
343 | 343 |
344 *address = session_->peer_address().impl().socket_address(); | 344 *address = session_->peer_address().impl().socket_address(); |
345 return OK; | 345 return OK; |
346 } | 346 } |
347 | 347 |
348 QuicChromiumClientSession::StreamRequest::StreamRequest( | 348 QuicChromiumClientSession::StreamRequest::StreamRequest( |
349 std::unique_ptr<QuicChromiumClientSession::Handle> session, | 349 QuicChromiumClientSession::Handle* session, |
350 bool requires_confirmation) | 350 bool requires_confirmation) |
351 : session_(std::move(session)), | 351 : session_(std::move(session)), |
352 requires_confirmation_(requires_confirmation), | 352 requires_confirmation_(requires_confirmation), |
353 stream_(nullptr), | 353 stream_(nullptr), |
354 weak_factory_(this) {} | 354 weak_factory_(this) {} |
355 | 355 |
356 QuicChromiumClientSession::StreamRequest::~StreamRequest() { | 356 QuicChromiumClientSession::StreamRequest::~StreamRequest() { |
357 if (stream_) | 357 if (stream_) |
358 stream_->Reset(QUIC_STREAM_CANCELLED); | 358 stream_->Reset(QUIC_STREAM_CANCELLED); |
359 | 359 |
(...skipping 1388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1748 } | 1748 } |
1749 | 1749 |
1750 size_t QuicChromiumClientSession::EstimateMemoryUsage() const { | 1750 size_t QuicChromiumClientSession::EstimateMemoryUsage() const { |
1751 // TODO(xunjieli): Estimate |crypto_stream_|, QuicSpdySession's | 1751 // TODO(xunjieli): Estimate |crypto_stream_|, QuicSpdySession's |
1752 // QuicHeaderList, QuicSession's QuiCWriteBlockedList, open streams and | 1752 // QuicHeaderList, QuicSession's QuiCWriteBlockedList, open streams and |
1753 // unacked packet map. | 1753 // unacked packet map. |
1754 return base::trace_event::EstimateMemoryUsage(packet_readers_); | 1754 return base::trace_event::EstimateMemoryUsage(packet_readers_); |
1755 } | 1755 } |
1756 | 1756 |
1757 } // namespace net | 1757 } // namespace net |
OLD | NEW |