Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(164)

Unified Diff: net/quic/reliable_quic_stream.cc

Issue 11365080: Revert 165858 - Add QuicStream and friends to QUIC code. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/quic/reliable_quic_stream.h ('k') | net/quic/test_tools/quic_test_utils.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/quic/reliable_quic_stream.cc
===================================================================
--- net/quic/reliable_quic_stream.cc (revision 165858)
+++ net/quic/reliable_quic_stream.cc (working copy)
@@ -1,126 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "net/quic/reliable_quic_stream.h"
-
-#include "net/quic/quic_session.h"
-
-using base::StringPiece;
-
-namespace net {
-
-ReliableQuicStream::ReliableQuicStream(QuicStreamId id,
- QuicSession* session)
- : sequencer_(this),
- id_(id),
- offset_(0),
- session_(session),
- error_(QUIC_NO_ERROR),
- read_side_closed_(false),
- write_side_closed_(false) {
-}
-
-ReliableQuicStream::~ReliableQuicStream() {
-}
-
-bool ReliableQuicStream::WillAcceptStreamFrame(
- const QuicStreamFrame& frame) const {
- if (read_side_closed_) {
- return false;
- }
- if (frame.stream_id != id_) {
- LOG(ERROR) << "Error!";
- return false;
- }
- return sequencer_.WillAcceptStreamFrame(frame);
-}
-
-bool ReliableQuicStream::OnStreamFrame(const QuicStreamFrame& frame) {
- DCHECK_EQ(frame.stream_id, id_);
- if (read_side_closed_) {
- // This can only happen if a client sends data after sending a fin or stream
- // reset.
- Close(QUIC_STREAM_DATA_AFTER_TERMINATION);
- return false;
- }
-
- bool accepted = sequencer_.OnStreamFrame(frame);
-
- if (frame.fin) {
- sequencer_.CloseStreamAtOffset(frame.offset + frame.data.size(),
- true);
- }
-
- return accepted;
-}
-
-void ReliableQuicStream::OnStreamReset(QuicErrorCode error,
- QuicStreamOffset offset) {
- error_ = error;
- sequencer_.CloseStreamAtOffset(offset, false); // Full close
-}
-
-void ReliableQuicStream::ConnectionClose(QuicErrorCode error, bool from_peer) {
- error_ = error;
- if (from_peer) {
- TerminateFromPeer(false);
- } else {
- CloseWriteSide();
- CloseReadSide();
- }
-}
-
-void ReliableQuicStream::TerminateFromPeer(bool half_close) {
- if (!half_close) {
- CloseWriteSide();
- }
- CloseReadSide();
-}
-
-void ReliableQuicStream::Close(QuicErrorCode error) {
- error_ = error;
- session()->SendRstStream(id(), error, offset_);
-}
-
-bool ReliableQuicStream::IsHalfClosed() {
- return sequencer_.IsHalfClosed();
-}
-
-bool ReliableQuicStream::HasBytesToRead() {
- return sequencer_.HasBytesToRead();
-}
-
-int ReliableQuicStream::WriteData(StringPiece data, bool fin) {
- if (write_side_closed_) {
- DLOG(ERROR) << "Attempt to write when the write side is closed";
- return 0;
- }
-
- session()->WriteData(id(), data, offset_, fin);
- offset_ += data.length();
- if (fin) {
- CloseWriteSide();
- }
- return data.length();
-}
-
-void ReliableQuicStream::CloseReadSide() {
- DLOG(INFO) << "Done reading from stream " << id();
-
- read_side_closed_ = true;
- if (write_side_closed_) {
- session_->CloseStream(id());
- }
-}
-
-void ReliableQuicStream::CloseWriteSide() {
- DLOG(INFO) << "Done writing to stream " << id();
-
- write_side_closed_ = true;
- if (read_side_closed_) {
- session_->CloseStream(id());
- }
-}
-
-} // namespace net
« no previous file with comments | « net/quic/reliable_quic_stream.h ('k') | net/quic/test_tools/quic_test_utils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698