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
3 // found in the LICENSE file.
5 #include "net/quic/test_tools/quic_session_peer.h"
7 #include "base/stl_util.h"
8 #include "net/quic/quic_session.h"
9 #include "net/quic/reliable_quic_stream.h"
17 void QuicSessionPeer::SetNextStreamId(QuicSession
* session
, QuicStreamId id
) {
18 session
->next_stream_id_
= id
;
22 void QuicSessionPeer::SetMaxOpenStreams(QuicSession
* session
,
24 session
->max_open_streams_
= max_streams
;
28 QuicCryptoStream
* QuicSessionPeer::GetCryptoStream(QuicSession
* session
) {
29 return session
->GetCryptoStream();
33 QuicWriteBlockedList
* QuicSessionPeer::GetWriteBlockedStreams(
34 QuicSession
* session
) {
35 return &session
->write_blocked_streams_
;
39 ReliableQuicStream
* QuicSessionPeer::GetIncomingDynamicStream(
41 QuicStreamId stream_id
) {
42 return session
->GetIncomingDynamicStream(stream_id
);
46 map
<QuicStreamId
, QuicStreamOffset
>&
47 QuicSessionPeer::GetLocallyClosedStreamsHighestOffset(QuicSession
* session
) {
48 return session
->locally_closed_streams_highest_offset_
;
52 base::hash_set
<QuicStreamId
>* QuicSessionPeer::GetDrainingStreams(
53 QuicSession
* session
) {
54 return &session
->draining_streams_
;
58 bool QuicSessionPeer::IsStreamClosed(QuicSession
* session
, QuicStreamId id
) {
60 return session
->IsClosedStream(id
);
64 bool QuicSessionPeer::IsStreamCreated(QuicSession
* session
, QuicStreamId id
) {
66 return ContainsKey(session
->dynamic_streams(), id
);
70 bool QuicSessionPeer::IsStreamImplicitlyCreated(QuicSession
* session
,
73 return ContainsKey(session
->implicitly_created_streams_
, id
);
77 bool QuicSessionPeer::IsStreamUncreated(QuicSession
* session
, QuicStreamId id
) {
79 if (id
% 2 == session
->next_stream_id_
% 2) {
80 // locally-created stream.
81 return id
>= session
->next_stream_id_
;
83 // peer-created stream.
84 return id
> session
->largest_peer_created_stream_id_
;