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/spdy/spdy_session.h" | 5 #include "net/spdy/spdy_session.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <map> | 8 #include <map> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 1496 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1507 break; | 1507 break; |
1508 } | 1508 } |
1509 | 1509 |
1510 CHECK(in_io_loop_); | 1510 CHECK(in_io_loop_); |
1511 in_io_loop_ = false; | 1511 in_io_loop_ = false; |
1512 | 1512 |
1513 return result; | 1513 return result; |
1514 } | 1514 } |
1515 | 1515 |
1516 int SpdySession::DoWrite() { | 1516 int SpdySession::DoWrite() { |
1517 // TODO(pkasting): Remove ScopedTracker below once crbug.com/457517 is fixed. | |
1518 tracked_objects::ScopedTracker tracking_profile1( | |
1519 FROM_HERE_WITH_EXPLICIT_FUNCTION("457517 SpdySession::DoWrite1")); | |
1520 CHECK(in_io_loop_); | 1517 CHECK(in_io_loop_); |
1521 | 1518 |
1522 DCHECK(buffered_spdy_framer_); | 1519 DCHECK(buffered_spdy_framer_); |
1523 if (in_flight_write_) { | 1520 if (in_flight_write_) { |
1524 DCHECK_GT(in_flight_write_->GetRemainingSize(), 0u); | 1521 DCHECK_GT(in_flight_write_->GetRemainingSize(), 0u); |
1525 } else { | 1522 } else { |
1526 // TODO(pkasting): Remove ScopedTracker below once crbug.com/457517 is | |
1527 // fixed. | |
1528 tracked_objects::ScopedTracker tracking_profile2( | |
1529 FROM_HERE_WITH_EXPLICIT_FUNCTION("457517 SpdySession::DoWrite2")); | |
1530 // Grab the next frame to send. | 1523 // Grab the next frame to send. |
1531 SpdyFrameType frame_type = DATA; | 1524 SpdyFrameType frame_type = DATA; |
1532 scoped_ptr<SpdyBufferProducer> producer; | 1525 scoped_ptr<SpdyBufferProducer> producer; |
1533 base::WeakPtr<SpdyStream> stream; | 1526 base::WeakPtr<SpdyStream> stream; |
1534 if (!write_queue_.Dequeue(&frame_type, &producer, &stream)) { | 1527 if (!write_queue_.Dequeue(&frame_type, &producer, &stream)) { |
1535 write_state_ = WRITE_STATE_IDLE; | 1528 write_state_ = WRITE_STATE_IDLE; |
1536 return ERR_IO_PENDING; | 1529 return ERR_IO_PENDING; |
1537 } | 1530 } |
1538 | 1531 |
1539 if (stream.get()) | 1532 if (stream.get()) |
1540 CHECK(!stream->IsClosed()); | 1533 CHECK(!stream->IsClosed()); |
1541 | 1534 |
1542 // Activate the stream only when sending the SYN_STREAM frame to | 1535 // Activate the stream only when sending the SYN_STREAM frame to |
1543 // guarantee monotonically-increasing stream IDs. | 1536 // guarantee monotonically-increasing stream IDs. |
1544 if (frame_type == SYN_STREAM) { | 1537 if (frame_type == SYN_STREAM) { |
1545 // TODO(pkasting): Remove ScopedTracker below once crbug.com/457517 is | |
1546 // fixed. | |
1547 tracked_objects::ScopedTracker tracking_profile3( | |
1548 FROM_HERE_WITH_EXPLICIT_FUNCTION("457517 SpdySession::DoWrite3")); | |
1549 CHECK(stream.get()); | 1538 CHECK(stream.get()); |
1550 CHECK_EQ(stream->stream_id(), 0u); | 1539 CHECK_EQ(stream->stream_id(), 0u); |
1551 scoped_ptr<SpdyStream> owned_stream = | 1540 scoped_ptr<SpdyStream> owned_stream = |
1552 ActivateCreatedStream(stream.get()); | 1541 ActivateCreatedStream(stream.get()); |
1553 InsertActivatedStream(owned_stream.Pass()); | 1542 InsertActivatedStream(owned_stream.Pass()); |
1554 | 1543 |
1555 if (stream_hi_water_mark_ > kLastStreamId) { | 1544 if (stream_hi_water_mark_ > kLastStreamId) { |
1556 CHECK_EQ(stream->stream_id(), kLastStreamId); | 1545 CHECK_EQ(stream->stream_id(), kLastStreamId); |
1557 // We've exhausted the stream ID space, and no new streams may be | 1546 // We've exhausted the stream ID space, and no new streams may be |
1558 // created after this one. | 1547 // created after this one. |
1559 MakeUnavailable(); | 1548 MakeUnavailable(); |
1560 StartGoingAway(kLastStreamId, ERR_ABORTED); | 1549 StartGoingAway(kLastStreamId, ERR_ABORTED); |
1561 } | 1550 } |
1562 } | 1551 } |
1563 | 1552 |
1564 // TODO(pkasting): Remove ScopedTracker below once crbug.com/457517 is | 1553 // TODO(pkasting): Remove ScopedTracker below once crbug.com/457517 is |
1565 // fixed. | 1554 // fixed. |
1566 tracked_objects::ScopedTracker tracking_profile4( | 1555 tracked_objects::ScopedTracker tracking_profile1( |
1567 FROM_HERE_WITH_EXPLICIT_FUNCTION("457517 SpdySession::DoWrite4")); | 1556 FROM_HERE_WITH_EXPLICIT_FUNCTION("457517 SpdySession::DoWrite1")); |
1568 in_flight_write_ = producer->ProduceBuffer(); | 1557 in_flight_write_ = producer->ProduceBuffer(); |
1569 if (!in_flight_write_) { | 1558 if (!in_flight_write_) { |
1570 NOTREACHED(); | 1559 NOTREACHED(); |
1571 return ERR_UNEXPECTED; | 1560 return ERR_UNEXPECTED; |
1572 } | 1561 } |
1573 in_flight_write_frame_type_ = frame_type; | 1562 in_flight_write_frame_type_ = frame_type; |
1574 in_flight_write_frame_size_ = in_flight_write_->GetRemainingSize(); | 1563 in_flight_write_frame_size_ = in_flight_write_->GetRemainingSize(); |
1575 DCHECK_GE(in_flight_write_frame_size_, | 1564 DCHECK_GE(in_flight_write_frame_size_, |
1576 buffered_spdy_framer_->GetFrameMinimumSize()); | 1565 buffered_spdy_framer_->GetFrameMinimumSize()); |
1577 in_flight_write_stream_ = stream; | 1566 in_flight_write_stream_ = stream; |
1578 } | 1567 } |
1579 | 1568 |
1580 write_state_ = WRITE_STATE_DO_WRITE_COMPLETE; | 1569 write_state_ = WRITE_STATE_DO_WRITE_COMPLETE; |
1581 | 1570 |
1582 // Explicitly store in a scoped_refptr<IOBuffer> to avoid problems | 1571 // Explicitly store in a scoped_refptr<IOBuffer> to avoid problems |
1583 // with Socket implementations that don't store their IOBuffer | 1572 // with Socket implementations that don't store their IOBuffer |
1584 // argument in a scoped_refptr<IOBuffer> (see crbug.com/232345). | 1573 // argument in a scoped_refptr<IOBuffer> (see crbug.com/232345). |
| 1574 // TODO(pkasting): Remove ScopedTracker below once crbug.com/457517 is fixed. |
| 1575 tracked_objects::ScopedTracker tracking_profile2( |
| 1576 FROM_HERE_WITH_EXPLICIT_FUNCTION("457517 SpdySession::DoWrite2")); |
1585 scoped_refptr<IOBuffer> write_io_buffer = | 1577 scoped_refptr<IOBuffer> write_io_buffer = |
1586 in_flight_write_->GetIOBufferForRemainingData(); | 1578 in_flight_write_->GetIOBufferForRemainingData(); |
1587 return connection_->socket()->Write( | 1579 return connection_->socket()->Write( |
1588 write_io_buffer.get(), | 1580 write_io_buffer.get(), |
1589 in_flight_write_->GetRemainingSize(), | 1581 in_flight_write_->GetRemainingSize(), |
1590 base::Bind(&SpdySession::PumpWriteLoop, | 1582 base::Bind(&SpdySession::PumpWriteLoop, |
1591 weak_factory_.GetWeakPtr(), WRITE_STATE_DO_WRITE_COMPLETE)); | 1583 weak_factory_.GetWeakPtr(), WRITE_STATE_DO_WRITE_COMPLETE)); |
1592 } | 1584 } |
1593 | 1585 |
1594 int SpdySession::DoWriteComplete(int result) { | 1586 int SpdySession::DoWriteComplete(int result) { |
(...skipping 1673 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3268 if (!queue->empty()) { | 3260 if (!queue->empty()) { |
3269 SpdyStreamId stream_id = queue->front(); | 3261 SpdyStreamId stream_id = queue->front(); |
3270 queue->pop_front(); | 3262 queue->pop_front(); |
3271 return stream_id; | 3263 return stream_id; |
3272 } | 3264 } |
3273 } | 3265 } |
3274 return 0; | 3266 return 0; |
3275 } | 3267 } |
3276 | 3268 |
3277 } // namespace net | 3269 } // namespace net |
OLD | NEW |