Remove QuicStreamIdManager::DelegateInterface::OnCanCreateNewOutgoingStream().

It can be replaced by return value.

gfe-relnote: no behavior change. not protected.
PiperOrigin-RevId: 303828768
Change-Id: I0526af5ea2e1e9edca41daabd93cf4111871aebb
diff --git a/quic/core/quic_session.cc b/quic/core/quic_session.cc
index d925fea..22252ae 100644
--- a/quic/core/quic_session.cc
+++ b/quic/core/quic_session.cc
@@ -1013,7 +1013,10 @@
     QUIC_DVLOG(1) << ENDPOINT
                   << "Setting Bidirectional outgoing_max_streams_ to "
                   << max_streams;
-    v99_streamid_manager_.SetMaxOpenOutgoingBidirectionalStreams(max_streams);
+    if (v99_streamid_manager_.MaybeAllowNewOutgoingBidirectionalStreams(
+            max_streams)) {
+      OnCanCreateNewOutgoingStream(/*unidirectional = */ false);
+    }
 
     max_streams = 0;
     if (config_.HasReceivedMaxUnidirectionalStreams()) {
@@ -1031,7 +1034,10 @@
     QUIC_DVLOG(1) << ENDPOINT
                   << "Setting Unidirectional outgoing_max_streams_ to "
                   << max_streams;
-    v99_streamid_manager_.SetMaxOpenOutgoingUnidirectionalStreams(max_streams);
+    if (v99_streamid_manager_.MaybeAllowNewOutgoingUnidirectionalStreams(
+            max_streams)) {
+      OnCanCreateNewOutgoingStream(/*unidirectional = */ true);
+    }
   } else {
     uint32_t max_streams = 0;
     if (config_.HasReceivedMaxBidirectionalStreams()) {
@@ -2188,8 +2194,6 @@
   control_frame_manager_.WriteOrBufferStopSending(code, stream_id);
 }
 
-void QuicSession::OnCanCreateNewOutgoingStream(bool /*unidirectional*/) {}
-
 QuicStreamId QuicSession::next_outgoing_bidirectional_stream_id() const {
   if (VersionHasIetfQuicFrames(transport_version())) {
     return v99_streamid_manager_.next_outgoing_bidirectional_stream_id();
@@ -2205,7 +2209,17 @@
 }
 
 bool QuicSession::OnMaxStreamsFrame(const QuicMaxStreamsFrame& frame) {
-  return v99_streamid_manager_.OnMaxStreamsFrame(frame);
+  const bool allow_new_streams =
+      frame.unidirectional
+          ? v99_streamid_manager_.MaybeAllowNewOutgoingUnidirectionalStreams(
+                frame.stream_count)
+          : v99_streamid_manager_.MaybeAllowNewOutgoingBidirectionalStreams(
+                frame.stream_count);
+  if (allow_new_streams) {
+    OnCanCreateNewOutgoingStream(frame.unidirectional);
+  }
+
+  return true;
 }
 
 bool QuicSession::OnStreamsBlockedFrame(const QuicStreamsBlockedFrame& frame) {
diff --git a/quic/core/quic_session.h b/quic/core/quic_session.h
index 06dfd0a..567126a 100644
--- a/quic/core/quic_session.h
+++ b/quic/core/quic_session.h
@@ -156,7 +156,7 @@
                       bool unidirectional) override;
   // The default implementation does nothing. Subclasses should override if
   // for example they queue up stream requests.
-  void OnCanCreateNewOutgoingStream(bool unidirectional) override;
+  virtual void OnCanCreateNewOutgoingStream(bool /*unidirectional*/) {}
 
   // Called on every incoming packet. Passes |packet| through to |connection_|.
   virtual void ProcessUdpPacket(const QuicSocketAddress& self_address,
diff --git a/quic/core/quic_session_test.cc b/quic/core/quic_session_test.cc
index 25237c4..36e0b53 100644
--- a/quic/core/quic_session_test.cc
+++ b/quic/core/quic_session_test.cc
@@ -12,6 +12,7 @@
 #include "net/third_party/quiche/src/quic/core/crypto/crypto_protocol.h"
 #include "net/third_party/quiche/src/quic/core/crypto/null_encrypter.h"
 #include "net/third_party/quiche/src/quic/core/crypto/transport_parameters.h"
+#include "net/third_party/quiche/src/quic/core/frames/quic_max_streams_frame.h"
 #include "net/third_party/quiche/src/quic/core/quic_crypto_stream.h"
 #include "net/third_party/quiche/src/quic/core/quic_data_writer.h"
 #include "net/third_party/quiche/src/quic/core/quic_error_codes.h"
@@ -364,6 +365,10 @@
         kInitialSessionFlowControlWindowForTest);
 
     if (configure_session) {
+      if (VersionHasIetfQuicFrames(transport_version())) {
+        EXPECT_CALL(session_, OnCanCreateNewOutgoingStream(false)).Times(1);
+        EXPECT_CALL(session_, OnCanCreateNewOutgoingStream(true)).Times(1);
+      }
       QuicConfigPeer::SetReceivedMaxBidirectionalStreams(
           session_.config(), kDefaultMaxStreamsPerConnection);
       QuicConfigPeer::SetReceivedMaxUnidirectionalStreams(
@@ -382,6 +387,7 @@
     TestCryptoStream* crypto_stream = session_.GetMutableCryptoStream();
     EXPECT_CALL(*crypto_stream, HasPendingRetransmission())
         .Times(testing::AnyNumber());
+    testing::Mock::VerifyAndClearExpectations(&session_);
   }
 
   ~QuicSessionTestBase() {
@@ -2049,6 +2055,23 @@
       &session_, GetNthClientInitiatedBidirectionalId(1)));
 }
 
+TEST_P(QuicSessionTestClient, OnMaxStreamFrame) {
+  if (!VersionUsesHttp3(transport_version())) {
+    return;
+  }
+  QuicMaxStreamsFrame frame;
+  frame.unidirectional = false;
+  frame.stream_count = 120;
+  EXPECT_CALL(session_, OnCanCreateNewOutgoingStream(false)).Times(1);
+  session_.OnMaxStreamsFrame(frame);
+
+  QuicMaxStreamsFrame frame2;
+  frame2.unidirectional = false;
+  frame2.stream_count = 110;
+  EXPECT_CALL(session_, OnCanCreateNewOutgoingStream(false)).Times(0);
+  session_.OnMaxStreamsFrame(frame2);
+}
+
 TEST_P(QuicSessionTestClient, AvailableUnidirectionalStreamsClient) {
   ASSERT_TRUE(session_.GetOrCreateStream(
                   GetNthServerInitiatedUnidirectionalId(2)) != nullptr);
diff --git a/quic/core/quic_stream_id_manager.cc b/quic/core/quic_stream_id_manager.cc
index ec0cda9..2878a9b 100644
--- a/quic/core/quic_stream_id_manager.cc
+++ b/quic/core/quic_stream_id_manager.cc
@@ -48,17 +48,6 @@
 
 QuicStreamIdManager::~QuicStreamIdManager() {}
 
-bool QuicStreamIdManager::OnMaxStreamsFrame(const QuicMaxStreamsFrame& frame) {
-  // Ensure that the frame has the correct directionality.
-  DCHECK_EQ(frame.unidirectional, unidirectional_);
-  QUIC_CODE_COUNT_N(quic_max_streams_received, 2, 2);
-
-  // Set the limit to be exactly the stream count in the frame.
-  // Also informs the higher layers that they can create more
-  // streams if the limit is increased.
-  return SetMaxOpenOutgoingStreams(frame.stream_count);
-}
-
 // The peer sends a streams blocked frame when it can not open any more
 // streams because it has runs into the limit.
 bool QuicStreamIdManager::OnStreamsBlockedFrame(
@@ -83,15 +72,11 @@
   return true;
 }
 
-// Used when configuration has been done and we have an initial
-// maximum stream count from the peer.
-bool QuicStreamIdManager::SetMaxOpenOutgoingStreams(
+bool QuicStreamIdManager::MaybeAllowNewOutgoingStreams(
     QuicStreamCount max_open_streams) {
   if (max_open_streams <= outgoing_max_streams_) {
     // Only update the stream count if it would increase the limit.
-    // If it decreases the limit, or doesn't change it, then do not update.
-    // Note that this handles the case of receiving a count of 0 in the frame
-    return true;
+    return false;
   }
 
   // This implementation only supports 32 bit Stream IDs, so limit max streams
@@ -99,10 +84,6 @@
   outgoing_max_streams_ =
       std::min(max_open_streams, QuicUtils::GetMaxStreamCount());
 
-  // Inform the higher layers that the stream limit has increased and that
-  // new streams may be created.
-  delegate_->OnCanCreateNewOutgoingStream(unidirectional_);
-
   return true;
 }
 
diff --git a/quic/core/quic_stream_id_manager.h b/quic/core/quic_stream_id_manager.h
index da94233..b3079b2 100644
--- a/quic/core/quic_stream_id_manager.h
+++ b/quic/core/quic_stream_id_manager.h
@@ -33,14 +33,6 @@
    public:
     virtual ~DelegateInterface() = default;
 
-    // Called when new outgoing streams are available to be opened. This occurs
-    // when an extant, open, stream is moved to draining or closed.
-    // |unidirectional| indicates whether unidirectional or bidirectional
-    // streams are now available. If both become available at the same time then
-    // there will be two calls to this method, one with unidirectional==true,
-    // the other with it ==false.
-    virtual void OnCanCreateNewOutgoingStream(bool unidirectional) = 0;
-
     // Closes the connection when an error is encountered.
     virtual void OnStreamIdManagerError(QuicErrorCode error_code,
                                         std::string error_details) = 0;
@@ -77,12 +69,6 @@
         ", max_streams_window_: ", max_streams_window_, " }");
   }
 
-  // Processes the MAX_STREAMS frame, invoked from
-  // QuicSession::OnMaxStreamsFrame. It has the same semantics as the
-  // QuicFramerVisitorInterface, returning true if the framer should continue
-  // processing the packet, false if not.
-  bool OnMaxStreamsFrame(const QuicMaxStreamsFrame& frame);
-
   // Processes the STREAMS_BLOCKED frame, invoked from
   // QuicSession::OnStreamsBlockedFrame. It has the same semantics as the
   // QuicFramerVisitorInterface, returning true if the framer should continue
@@ -108,12 +94,10 @@
 
   void SetMaxOpenIncomingStreams(QuicStreamCount max_open_streams);
 
-  // Sets the maximum number of outgoing streams to max_open_streams.
-  // Used when configuration has been done and we have an initial
-  // maximum stream count from the peer. Note that if the stream count is such
-  // that it would result in stream ID values that are greater than the
-  // implementation limit, it pegs the count at the implementation limit.
-  bool SetMaxOpenOutgoingStreams(QuicStreamCount max_open_streams);
+  // Called on |max_open_streams| outgoing streams can be created because of 1)
+  // config negotiated or 2) MAX_STREAMS received. Returns true if new
+  // streams can be created.
+  bool MaybeAllowNewOutgoingStreams(QuicStreamCount max_open_streams);
 
   // Checks if the incoming stream ID exceeds the MAX_STREAMS limit.  If the
   // limit is exceeded, closes the connection and returns false.  Uses the
diff --git a/quic/core/quic_stream_id_manager_test.cc b/quic/core/quic_stream_id_manager_test.cc
index 17d76b2..73a4ff9 100644
--- a/quic/core/quic_stream_id_manager_test.cc
+++ b/quic/core/quic_stream_id_manager_test.cc
@@ -139,8 +139,8 @@
   // Ensure that the limit is less than the implementation maximum.
   EXPECT_LT(stream_id_manager_.outgoing_max_streams(), implementation_max);
 
-  EXPECT_CALL(delegate_, OnCanCreateNewOutgoingStream(IsUnidirectional()));
-  stream_id_manager_.SetMaxOpenOutgoingStreams(implementation_max + 1);
+  EXPECT_TRUE(
+      stream_id_manager_.MaybeAllowNewOutgoingStreams(implementation_max + 1));
   // Should be pegged at the max.
   EXPECT_EQ(implementation_max, stream_id_manager_.outgoing_max_streams());
 }
@@ -210,34 +210,6 @@
   EXPECT_FALSE(stream_id_manager_.MaybeIncreaseLargestPeerStreamId(stream_id));
 }
 
-TEST_P(QuicStreamIdManagerTest, OnMaxStreamsFrame) {
-  QuicMaxStreamsFrame frame;
-  frame.stream_count = 10;
-
-  frame.unidirectional = IsUnidirectional();
-  EXPECT_CALL(delegate_, OnCanCreateNewOutgoingStream(IsUnidirectional()));
-  EXPECT_TRUE(stream_id_manager_.OnMaxStreamsFrame(frame));
-  EXPECT_EQ(10u, stream_id_manager_.outgoing_max_streams());
-
-  QuicStreamCount save_outgoing_max_streams =
-      stream_id_manager_.outgoing_max_streams();
-  // Now that there has been one MAX STREAMS frame, we should not
-  // accept a MAX_STREAMS that reduces the limit...
-  frame.stream_count = 8;
-  frame.unidirectional = IsUnidirectional();
-  EXPECT_TRUE(stream_id_manager_.OnMaxStreamsFrame(frame));
-  // should not change from previous setting.
-  EXPECT_EQ(save_outgoing_max_streams,
-            stream_id_manager_.outgoing_max_streams());
-
-  // A stream count greater than the current limit should increase the limit.
-  frame.stream_count = 12;
-  EXPECT_CALL(delegate_, OnCanCreateNewOutgoingStream(IsUnidirectional()));
-  EXPECT_TRUE(stream_id_manager_.OnMaxStreamsFrame(frame));
-
-  EXPECT_EQ(12u, stream_id_manager_.outgoing_max_streams());
-}
-
 TEST_P(QuicStreamIdManagerTest, OnStreamsBlockedFrame) {
   // Get the current maximum allowed incoming stream count.
   QuicStreamCount advertised_stream_count =
@@ -299,8 +271,8 @@
   // opening...
   size_t number_of_streams = kDefaultMaxStreamsPerConnection;
 
-  EXPECT_CALL(delegate_, OnCanCreateNewOutgoingStream(IsUnidirectional()));
-  stream_id_manager_.SetMaxOpenOutgoingStreams(kDefaultMaxStreamsPerConnection);
+  EXPECT_TRUE(
+      stream_id_manager_.MaybeAllowNewOutgoingStreams(number_of_streams));
 
   QuicStreamId stream_id =
       IsUnidirectional()
@@ -426,13 +398,6 @@
   stream_id_manager_.OnStreamsBlockedFrame(frame);
 }
 
-TEST_P(QuicStreamIdManagerTest, CheckMaxAllowedOutgoingInitialization) {
-  const size_t kIncomingStreamCount = 123;
-  EXPECT_CALL(delegate_, OnCanCreateNewOutgoingStream(IsUnidirectional()));
-  stream_id_manager_.SetMaxOpenOutgoingStreams(kIncomingStreamCount);
-  EXPECT_EQ(kIncomingStreamCount, stream_id_manager_.outgoing_max_streams());
-}
-
 // Test that a MAX_STREAMS frame is generated when half the stream ids become
 // available. This has a useful side effect of testing that when streams are
 // closed, the number of available stream ids increases.
@@ -462,8 +427,7 @@
 }
 
 TEST_P(QuicStreamIdManagerTest, NewStreamDoesNotExceedLimit) {
-  EXPECT_CALL(delegate_, OnCanCreateNewOutgoingStream(IsUnidirectional()));
-  stream_id_manager_.SetMaxOpenOutgoingStreams(100);
+  EXPECT_TRUE(stream_id_manager_.MaybeAllowNewOutgoingStreams(100));
 
   size_t stream_count = stream_id_manager_.outgoing_max_streams();
   EXPECT_NE(0u, stream_count);
diff --git a/quic/core/uber_quic_stream_id_manager.cc b/quic/core/uber_quic_stream_id_manager.cc
index e85336f..7ef5688 100644
--- a/quic/core/uber_quic_stream_id_manager.cc
+++ b/quic/core/uber_quic_stream_id_manager.cc
@@ -31,13 +31,15 @@
           max_open_outgoing_unidirectional_streams,
           max_open_incoming_unidirectional_streams) {}
 
-void UberQuicStreamIdManager::SetMaxOpenOutgoingBidirectionalStreams(
+bool UberQuicStreamIdManager::MaybeAllowNewOutgoingBidirectionalStreams(
     QuicStreamCount max_open_streams) {
-  bidirectional_stream_id_manager_.SetMaxOpenOutgoingStreams(max_open_streams);
+  return bidirectional_stream_id_manager_.MaybeAllowNewOutgoingStreams(
+      max_open_streams);
 }
-void UberQuicStreamIdManager::SetMaxOpenOutgoingUnidirectionalStreams(
+bool UberQuicStreamIdManager::MaybeAllowNewOutgoingUnidirectionalStreams(
     QuicStreamCount max_open_streams) {
-  unidirectional_stream_id_manager_.SetMaxOpenOutgoingStreams(max_open_streams);
+  return unidirectional_stream_id_manager_.MaybeAllowNewOutgoingStreams(
+      max_open_streams);
 }
 void UberQuicStreamIdManager::SetMaxOpenIncomingBidirectionalStreams(
     QuicStreamCount max_open_streams) {
@@ -81,14 +83,6 @@
   unidirectional_stream_id_manager_.OnStreamClosed(id);
 }
 
-bool UberQuicStreamIdManager::OnMaxStreamsFrame(
-    const QuicMaxStreamsFrame& frame) {
-  if (frame.unidirectional) {
-    return unidirectional_stream_id_manager_.OnMaxStreamsFrame(frame);
-  }
-  return bidirectional_stream_id_manager_.OnMaxStreamsFrame(frame);
-}
-
 bool UberQuicStreamIdManager::OnStreamsBlockedFrame(
     const QuicStreamsBlockedFrame& frame) {
   if (frame.unidirectional) {
diff --git a/quic/core/uber_quic_stream_id_manager.h b/quic/core/uber_quic_stream_id_manager.h
index bc76be3..b505487 100644
--- a/quic/core/uber_quic_stream_id_manager.h
+++ b/quic/core/uber_quic_stream_id_manager.h
@@ -30,10 +30,15 @@
       QuicStreamCount max_open_incoming_bidirectional_streams,
       QuicStreamCount max_open_incoming_unidirectional_streams);
 
-  // Sets the limits to max_open_streams.
-  void SetMaxOpenOutgoingBidirectionalStreams(QuicStreamCount max_open_streams);
-  void SetMaxOpenOutgoingUnidirectionalStreams(
+  // Called on |max_open_streams| outgoing streams can be created because of 1)
+  // config negotiated or 2) MAX_STREAMS received. Returns true if new
+  // streams can be created.
+  bool MaybeAllowNewOutgoingBidirectionalStreams(
       QuicStreamCount max_open_streams);
+  bool MaybeAllowNewOutgoingUnidirectionalStreams(
+      QuicStreamCount max_open_streams);
+
+  // Sets the limits to max_open_streams.
   void SetMaxOpenIncomingBidirectionalStreams(QuicStreamCount max_open_streams);
   void SetMaxOpenIncomingUnidirectionalStreams(
       QuicStreamCount max_open_streams);
@@ -56,9 +61,6 @@
   // Called when |id| is released.
   void OnStreamClosed(QuicStreamId id);
 
-  // Called when a MAX_STREAMS frame is received.
-  bool OnMaxStreamsFrame(const QuicMaxStreamsFrame& frame);
-
   // Called when a STREAMS_BLOCKED frame is received.
   bool OnStreamsBlockedFrame(const QuicStreamsBlockedFrame& frame);
 
diff --git a/quic/core/uber_quic_stream_id_manager_test.cc b/quic/core/uber_quic_stream_id_manager_test.cc
index a8f86a6..3522008 100644
--- a/quic/core/uber_quic_stream_id_manager_test.cc
+++ b/quic/core/uber_quic_stream_id_manager_test.cc
@@ -146,10 +146,10 @@
   const size_t kNumMaxOutgoingStream = 123;
   // Set the uni- and bi- directional limits to different values to ensure
   // that they are managed separately.
-  EXPECT_CALL(delegate_, OnCanCreateNewOutgoingStream(false));
-  manager_.SetMaxOpenOutgoingBidirectionalStreams(kNumMaxOutgoingStream);
-  EXPECT_CALL(delegate_, OnCanCreateNewOutgoingStream(true));
-  manager_.SetMaxOpenOutgoingUnidirectionalStreams(kNumMaxOutgoingStream + 1);
+  EXPECT_TRUE(manager_.MaybeAllowNewOutgoingBidirectionalStreams(
+      kNumMaxOutgoingStream));
+  EXPECT_TRUE(manager_.MaybeAllowNewOutgoingUnidirectionalStreams(
+      kNumMaxOutgoingStream + 1));
   EXPECT_EQ(kNumMaxOutgoingStream,
             manager_.max_outgoing_bidirectional_streams());
   EXPECT_EQ(kNumMaxOutgoingStream + 1,
@@ -209,9 +209,8 @@
 }
 
 TEST_P(UberQuicStreamIdManagerTest, GetNextOutgoingStreamId) {
-  EXPECT_CALL(delegate_, OnCanCreateNewOutgoingStream(_)).Times(2);
-  manager_.SetMaxOpenOutgoingBidirectionalStreams(10);
-  manager_.SetMaxOpenOutgoingUnidirectionalStreams(10);
+  EXPECT_TRUE(manager_.MaybeAllowNewOutgoingBidirectionalStreams(10));
+  EXPECT_TRUE(manager_.MaybeAllowNewOutgoingUnidirectionalStreams(10));
   EXPECT_EQ(GetNthSelfInitiatedBidirectionalStreamId(0),
             manager_.GetNextOutgoingBidirectionalStreamId());
   EXPECT_EQ(GetNthSelfInitiatedBidirectionalStreamId(1),
@@ -267,52 +266,6 @@
       QuicUtils::InvertPerspective(perspective()), /* bidirectional=*/false)));
 }
 
-TEST_P(UberQuicStreamIdManagerTest, OnMaxStreamsFrame) {
-  QuicStreamCount max_outgoing_bidirectional_stream_count =
-      manager_.max_outgoing_bidirectional_streams();
-
-  QuicStreamCount max_outgoing_unidirectional_stream_count =
-      manager_.max_outgoing_unidirectional_streams();
-
-  // Inject a MAX_STREAMS frame that does not increase the limit and then
-  // check that there are no changes. First try the bidirectional manager.
-  QuicMaxStreamsFrame frame(kInvalidControlFrameId,
-                            max_outgoing_bidirectional_stream_count,
-                            /*unidirectional=*/false);
-  EXPECT_TRUE(manager_.OnMaxStreamsFrame(frame));
-  EXPECT_EQ(max_outgoing_bidirectional_stream_count,
-            manager_.max_outgoing_bidirectional_streams());
-
-  // Now try the unidirectioanl manager
-  frame.stream_count = max_outgoing_unidirectional_stream_count;
-  frame.unidirectional = true;
-  EXPECT_TRUE(manager_.OnMaxStreamsFrame(frame));
-  EXPECT_EQ(max_outgoing_unidirectional_stream_count,
-            manager_.max_outgoing_unidirectional_streams());
-
-  // Now try to increase the bidirectional stream count.
-  frame.stream_count = max_outgoing_bidirectional_stream_count + 1;
-  frame.unidirectional = false;
-  EXPECT_CALL(delegate_, OnCanCreateNewOutgoingStream(frame.unidirectional));
-  EXPECT_TRUE(manager_.OnMaxStreamsFrame(frame));
-  EXPECT_EQ(max_outgoing_bidirectional_stream_count + 1,
-            manager_.max_outgoing_bidirectional_streams());
-  // Make sure that the unidirectional state does not change.
-  EXPECT_EQ(max_outgoing_unidirectional_stream_count,
-            manager_.max_outgoing_unidirectional_streams());
-
-  // Now check that a MAX_STREAMS for the unidirectional manager increases
-  // just the unidirectiomal manager's state.
-  frame.stream_count = max_outgoing_unidirectional_stream_count + 1;
-  frame.unidirectional = true;
-  EXPECT_CALL(delegate_, OnCanCreateNewOutgoingStream(frame.unidirectional));
-  EXPECT_TRUE(manager_.OnMaxStreamsFrame(frame));
-  EXPECT_EQ(max_outgoing_bidirectional_stream_count + 1,
-            manager_.max_outgoing_bidirectional_streams());
-  EXPECT_EQ(max_outgoing_unidirectional_stream_count + 1,
-            manager_.max_outgoing_unidirectional_streams());
-}
-
 TEST_P(UberQuicStreamIdManagerTest, OnStreamsBlockedFrame) {
   QuicStreamCount stream_count =
       manager_.advertised_max_incoming_bidirectional_streams() - 1;
@@ -349,10 +302,10 @@
   const size_t kNumMaxOutgoingStream = 123;
   // Set the uni- and bi- directional limits to different values to ensure
   // that they are managed separately.
-  EXPECT_CALL(delegate_, OnCanCreateNewOutgoingStream(false));
-  manager_.SetMaxOpenOutgoingBidirectionalStreams(kNumMaxOutgoingStream);
-  EXPECT_CALL(delegate_, OnCanCreateNewOutgoingStream(true));
-  manager_.SetMaxOpenOutgoingUnidirectionalStreams(kNumMaxOutgoingStream + 1);
+  EXPECT_TRUE(manager_.MaybeAllowNewOutgoingBidirectionalStreams(
+      kNumMaxOutgoingStream));
+  EXPECT_TRUE(manager_.MaybeAllowNewOutgoingUnidirectionalStreams(
+      kNumMaxOutgoingStream + 1));
   EXPECT_EQ(kNumMaxOutgoingStream,
             manager_.max_outgoing_bidirectional_streams());
   EXPECT_EQ(kNumMaxOutgoingStream + 1,
@@ -374,16 +327,6 @@
   // Both should be exhausted...
   EXPECT_FALSE(manager_.CanOpenNextOutgoingUnidirectionalStream());
   EXPECT_FALSE(manager_.CanOpenNextOutgoingBidirectionalStream());
-
-  // Now cons a MAX STREAMS frame for unidirectional streams to raise
-  // the limit.
-  QuicMaxStreamsFrame frame(1, kNumMaxOutgoingStream + 10,
-                            /*unidirectional=*/true);
-  EXPECT_CALL(delegate_, OnCanCreateNewOutgoingStream(frame.unidirectional));
-  manager_.OnMaxStreamsFrame(frame);
-  // We now should be able to get another uni- stream, but not a bi.
-  EXPECT_TRUE(manager_.CanOpenNextOutgoingUnidirectionalStream());
-  EXPECT_FALSE(manager_.CanOpenNextOutgoingBidirectionalStream());
 }
 
 }  // namespace
diff --git a/quic/test_tools/quic_session_peer.cc b/quic/test_tools/quic_session_peer.cc
index 70f6e5c..cbaf5d6 100644
--- a/quic/test_tools/quic_session_peer.cc
+++ b/quic/test_tools/quic_session_peer.cc
@@ -75,10 +75,6 @@
                                                 uint32_t max_streams) {
   if (VersionHasIetfQuicFrames(session->transport_version())) {
     QUIC_BUG << "SetmaxOpenOutgoingStreams deprecated for IETF QUIC";
-    session->v99_streamid_manager_.SetMaxOpenOutgoingUnidirectionalStreams(
-        max_streams);
-    session->v99_streamid_manager_.SetMaxOpenOutgoingBidirectionalStreams(
-        max_streams);
     return;
   }
   session->stream_id_manager_.set_max_open_outgoing_streams(max_streams);
@@ -91,7 +87,7 @@
   DCHECK(VersionHasIetfQuicFrames(session->transport_version()))
       << "SetmaxOpenOutgoingBidirectionalStreams not supported for Google "
          "QUIC";
-  session->v99_streamid_manager_.SetMaxOpenOutgoingBidirectionalStreams(
+  session->v99_streamid_manager_.MaybeAllowNewOutgoingBidirectionalStreams(
       max_streams);
 }
 // static
@@ -101,7 +97,7 @@
   DCHECK(VersionHasIetfQuicFrames(session->transport_version()))
       << "SetmaxOpenOutgoingUnidirectionalStreams not supported for Google "
          "QUIC";
-  session->v99_streamid_manager_.SetMaxOpenOutgoingUnidirectionalStreams(
+  session->v99_streamid_manager_.MaybeAllowNewOutgoingUnidirectionalStreams(
       max_streams);
 }