OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/linked_ptr.h" | 8 #include "base/linked_ptr.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
(...skipping 618 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
629 | 629 |
630 // We only notify the stream when we've fully written the pending frame. | 630 // We only notify the stream when we've fully written the pending frame. |
631 if (!in_flight_write_.buffer()->BytesRemaining()) { | 631 if (!in_flight_write_.buffer()->BytesRemaining()) { |
632 if (stream) { | 632 if (stream) { |
633 // Report the number of bytes written to the caller, but exclude the | 633 // Report the number of bytes written to the caller, but exclude the |
634 // frame size overhead. NOTE: if this frame was compressed the | 634 // frame size overhead. NOTE: if this frame was compressed the |
635 // reported bytes written is the compressed size, not the original | 635 // reported bytes written is the compressed size, not the original |
636 // size. | 636 // size. |
637 if (result > 0) { | 637 if (result > 0) { |
638 result = in_flight_write_.buffer()->size(); | 638 result = in_flight_write_.buffer()->size(); |
639 DCHECK_GT(result, static_cast<int>(spdy::SpdyFrame::size())); | 639 DCHECK_GE(result, static_cast<int>(spdy::SpdyFrame::size())); |
640 result -= static_cast<int>(spdy::SpdyFrame::size()); | 640 result -= static_cast<int>(spdy::SpdyFrame::size()); |
641 } | 641 } |
642 | 642 |
643 // It is possible that the stream was cancelled while we were writing | 643 // It is possible that the stream was cancelled while we were writing |
644 // to the socket. | 644 // to the socket. |
645 if (!stream->cancelled()) | 645 if (!stream->cancelled()) |
646 stream->OnWriteComplete(result); | 646 stream->OnWriteComplete(result); |
647 } | 647 } |
648 | 648 |
649 // Cleanup the write which just completed. | 649 // Cleanup the write which just completed. |
(...skipping 835 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1485 if (it == pending_callback_map_.end()) | 1485 if (it == pending_callback_map_.end()) |
1486 return; | 1486 return; |
1487 | 1487 |
1488 CompletionCallback* callback = it->second.callback; | 1488 CompletionCallback* callback = it->second.callback; |
1489 int result = it->second.result; | 1489 int result = it->second.result; |
1490 pending_callback_map_.erase(it); | 1490 pending_callback_map_.erase(it); |
1491 callback->Run(result); | 1491 callback->Run(result); |
1492 } | 1492 } |
1493 | 1493 |
1494 } // namespace net | 1494 } // namespace net |
OLD | NEW |