Roll src/third_party/WebKit d9c6159:8139f33 (svn 201974:201975)
[chromium-blink-merge.git] / net / quic / test_tools / quic_session_peer.cc
blobc1f86198c023e5664e8aac679d9ab15ff7c43f0b
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"
11 using std::map;
13 namespace net {
14 namespace test {
16 // static
17 void QuicSessionPeer::SetNextStreamId(QuicSession* session, QuicStreamId id) {
18 session->next_stream_id_ = id;
21 // static
22 void QuicSessionPeer::SetMaxOpenStreams(QuicSession* session,
23 uint32 max_streams) {
24 session->max_open_streams_ = max_streams;
27 // static
28 QuicCryptoStream* QuicSessionPeer::GetCryptoStream(QuicSession* session) {
29 return session->GetCryptoStream();
32 // static
33 QuicWriteBlockedList* QuicSessionPeer::GetWriteBlockedStreams(
34 QuicSession* session) {
35 return &session->write_blocked_streams_;
38 // static
39 ReliableQuicStream* QuicSessionPeer::GetIncomingDynamicStream(
40 QuicSession* session,
41 QuicStreamId stream_id) {
42 return session->GetIncomingDynamicStream(stream_id);
45 // static
46 map<QuicStreamId, QuicStreamOffset>&
47 QuicSessionPeer::GetLocallyClosedStreamsHighestOffset(QuicSession* session) {
48 return session->locally_closed_streams_highest_offset_;
51 // static
52 base::hash_set<QuicStreamId>* QuicSessionPeer::GetDrainingStreams(
53 QuicSession* session) {
54 return &session->draining_streams_;
57 // static
58 bool QuicSessionPeer::IsStreamClosed(QuicSession* session, QuicStreamId id) {
59 DCHECK_NE(0u, id);
60 return session->IsClosedStream(id);
63 // static
64 bool QuicSessionPeer::IsStreamCreated(QuicSession* session, QuicStreamId id) {
65 DCHECK_NE(0u, id);
66 return ContainsKey(session->dynamic_streams(), id);
69 // static
70 bool QuicSessionPeer::IsStreamImplicitlyCreated(QuicSession* session,
71 QuicStreamId id) {
72 DCHECK_NE(0u, id);
73 return ContainsKey(session->implicitly_created_streams_, id);
76 // static
77 bool QuicSessionPeer::IsStreamUncreated(QuicSession* session, QuicStreamId id) {
78 DCHECK_NE(0u, id);
79 if (id % 2 == session->next_stream_id_ % 2) {
80 // locally-created stream.
81 return id >= session->next_stream_id_;
82 } else {
83 // peer-created stream.
84 return id > session->largest_peer_created_stream_id_;
88 } // namespace test
89 } // namespace net