12a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// Copyright (c) 2012 The Chromium Authors. All rights reserved.
22a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be
32a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// found in the LICENSE file.
42a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
52a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "net/quic/test_tools/reliable_quic_stream_peer.h"
62a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
7e5d81f57cb97b3b6b7fccc9c5610d21eb81db09dBen Murdoch#include <list>
8e5d81f57cb97b3b6b7fccc9c5610d21eb81db09dBen Murdoch
92a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "net/quic/reliable_quic_stream.h"
102a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
112a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)namespace net {
122a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)namespace test {
132a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
142a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// static
152a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)void ReliableQuicStreamPeer::SetWriteSideClosed(bool value,
162a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)                                                ReliableQuicStream* stream) {
172a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  stream->write_side_closed_ = value;
182a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}
192a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
202a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// static
212a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)void ReliableQuicStreamPeer::SetStreamBytesWritten(
222a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    QuicStreamOffset stream_bytes_written,
232a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    ReliableQuicStream* stream) {
242a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  stream->stream_bytes_written_ = stream_bytes_written;
252a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}
262a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
275d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// static
285d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void ReliableQuicStreamPeer::CloseReadSide(ReliableQuicStream* stream) {
295d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  stream->CloseReadSide();
305d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
315d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
325d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// static
335d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)bool ReliableQuicStreamPeer::FinSent(ReliableQuicStream* stream) {
345d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  return stream->fin_sent_;
355d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
365d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
375d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// static
385d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)bool ReliableQuicStreamPeer::RstSent(ReliableQuicStream* stream) {
395d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  return stream->rst_sent_;
402385ea399aae016c0806a4f9ef3c9cfe3d2a39dfBen Murdoch}
412385ea399aae016c0806a4f9ef3c9cfe3d2a39dfBen Murdoch
42e5d81f57cb97b3b6b7fccc9c5610d21eb81db09dBen Murdoch// static
43e5d81f57cb97b3b6b7fccc9c5610d21eb81db09dBen Murdochuint32 ReliableQuicStreamPeer::SizeOfQueuedData(ReliableQuicStream* stream) {
44e5d81f57cb97b3b6b7fccc9c5610d21eb81db09dBen Murdoch  uint32 total = 0;
45e5d81f57cb97b3b6b7fccc9c5610d21eb81db09dBen Murdoch  std::list<ReliableQuicStream::PendingData>::iterator it =
46e5d81f57cb97b3b6b7fccc9c5610d21eb81db09dBen Murdoch      stream->queued_data_.begin();
47e5d81f57cb97b3b6b7fccc9c5610d21eb81db09dBen Murdoch  while (it != stream->queued_data_.end()) {
48e5d81f57cb97b3b6b7fccc9c5610d21eb81db09dBen Murdoch    total += it->data.size();
49e5d81f57cb97b3b6b7fccc9c5610d21eb81db09dBen Murdoch    ++it;
50e5d81f57cb97b3b6b7fccc9c5610d21eb81db09dBen Murdoch  }
51e5d81f57cb97b3b6b7fccc9c5610d21eb81db09dBen Murdoch  return total;
52e5d81f57cb97b3b6b7fccc9c5610d21eb81db09dBen Murdoch}
53e5d81f57cb97b3b6b7fccc9c5610d21eb81db09dBen Murdoch
54f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)// static
55f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)void ReliableQuicStreamPeer::SetFecPolicy(ReliableQuicStream* stream,
56f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)                                          FecPolicy fec_policy) {
57f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)  stream->set_fec_policy(fec_policy);
58f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)}
59f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)
60116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch// static
61116680a4aac90f2aa7413d9095a592090648e557Ben Murdochbool ReliableQuicStreamPeer::StreamContributesToConnectionFlowControl(
62116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch    ReliableQuicStream* stream) {
63116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch  return stream->stream_contributes_to_connection_flow_control_;
64116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch}
65116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch
662a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}  // namespace test
672a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}  // namespace net
68