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

Unified Diff: trunk/src/net/spdy/spdy_session_unittest.cc

Issue 310563002: Revert 273680 "Defer SpdySession destruction to support closing ..." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 6 years, 7 months 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 | « trunk/src/net/spdy/spdy_session_pool_unittest.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: trunk/src/net/spdy/spdy_session_unittest.cc
===================================================================
--- trunk/src/net/spdy/spdy_session_unittest.cc (revision 274100)
+++ trunk/src/net/spdy/spdy_session_unittest.cc (working copy)
@@ -282,7 +282,8 @@
EXPECT_EQ(ERR_ABORTED, callback1.WaitForResult());
}
-// A session receiving a GOAWAY frame with no active streams should close.
+// A session receiving a GOAWAY frame with no active streams should
+// immediately close.
TEST_P(SpdySessionTest, GoAwayWithNoActiveStreams) {
session_deps_.host_resolver->set_synchronous_mode(true);
@@ -306,8 +307,9 @@
// Read and process the GOAWAY frame.
data.RunFor(1);
+
EXPECT_FALSE(HasSpdySession(spdy_session_pool_, key_));
- base::RunLoop().RunUntilIdle();
+
EXPECT_TRUE(session == NULL);
}
@@ -407,13 +409,12 @@
EXPECT_EQ(NULL, spdy_stream2.get());
EXPECT_TRUE(session->IsStreamActive(1));
- EXPECT_TRUE(session->IsGoingAway());
+ EXPECT_FALSE(session->IsClosed());
// Should close the session.
spdy_stream1->Close();
EXPECT_EQ(NULL, spdy_stream1.get());
- base::MessageLoop::current()->RunUntilIdle();
EXPECT_TRUE(session == NULL);
}
@@ -488,12 +489,13 @@
EXPECT_FALSE(session->IsStreamActive(3));
EXPECT_EQ(NULL, spdy_stream2.get());
EXPECT_TRUE(session->IsStreamActive(1));
- EXPECT_TRUE(session->IsGoingAway());
+ EXPECT_FALSE(session->IsClosed());
+
// Read and process the second GOAWAY frame, which should close the
// session.
data.RunFor(1);
- base::MessageLoop::current()->RunUntilIdle();
+
EXPECT_TRUE(session == NULL);
}
@@ -566,12 +568,12 @@
EXPECT_FALSE(session->IsStreamActive(3));
EXPECT_EQ(NULL, spdy_stream2.get());
EXPECT_TRUE(session->IsStreamActive(1));
- EXPECT_TRUE(session->IsGoingAway());
+ EXPECT_FALSE(session->IsClosed());
+
session->CloseSessionOnError(ERR_ABORTED, "Aborting session");
- EXPECT_EQ(NULL, spdy_stream1.get());
- base::MessageLoop::current()->RunUntilIdle();
+ EXPECT_EQ(NULL, spdy_stream1.get());
EXPECT_TRUE(session == NULL);
}
@@ -700,7 +702,7 @@
// Read and process the SYN_STREAM frame, the subsequent RST_STREAM,
// and EOF.
data.RunFor(3);
- base::MessageLoop::current()->RunUntilIdle();
+
EXPECT_TRUE(session == NULL);
}
@@ -759,7 +761,7 @@
// pre-existing stream is still active.
EXPECT_FALSE(HasSpdySession(spdy_session_pool_, key_));
- EXPECT_TRUE(session->IsGoingAway());
+ EXPECT_FALSE(session->IsClosed());
EXPECT_TRUE(session->IsStreamActive(1));
@@ -768,7 +770,6 @@
#endif
EXPECT_EQ(NULL, spdy_stream.get());
- base::MessageLoop::current()->RunUntilIdle();
EXPECT_TRUE(session == NULL);
}
@@ -1041,7 +1042,6 @@
EXPECT_EQ(kUploadData, delegate2.TakeReceivedData());
// Session was destroyed.
- base::MessageLoop::current()->RunUntilIdle();
EXPECT_FALSE(session.get());
}
@@ -1195,7 +1195,6 @@
// Read and process EOF.
data.RunFor(1);
- base::MessageLoop::current()->RunUntilIdle();
EXPECT_TRUE(session == NULL);
}
@@ -1204,18 +1203,14 @@
MockConnect connect_data(SYNCHRONOUS, OK);
MockRead reads[] = {
- MockRead(SYNCHRONOUS, ERR_IO_PENDING) // Stall forever.
+ MockRead(ASYNC, 0, 0, 0) // EOF
};
scoped_ptr<SpdyFrame> write_ping(spdy_util_.ConstructSpdyPing(1, false));
- MockWrite writes[] = {
- CreateMockWrite(*write_ping),
- };
- StaticSocketDataProvider data(
- reads, arraysize(reads), writes, arraysize(writes));
+ DeterministicSocketData data(reads, arraysize(reads), NULL, 0);
data.set_connect_data(connect_data);
- session_deps_.socket_factory->AddSocketDataProvider(&data);
+ session_deps_.deterministic_socket_factory->AddSocketDataProvider(&data);
- CreateNetworkSession();
+ CreateDeterministicNetworkSession();
base::WeakPtr<SpdySession> session =
CreateInsecureSpdySession(http_session_, key_, BoundNetLog());
@@ -1237,7 +1232,7 @@
EXPECT_TRUE(session->check_ping_status_pending());
// Assert session is not closed.
- EXPECT_TRUE(session->IsAvailable());
+ EXPECT_FALSE(session->IsClosed());
EXPECT_LT(0u, session->num_active_streams() + session->num_created_streams());
EXPECT_TRUE(HasSpdySession(spdy_session_pool_, key_));
@@ -1246,7 +1241,6 @@
base::TimeTicks now = base::TimeTicks::Now();
session->last_activity_time_ = now - base::TimeDelta::FromSeconds(1);
session->CheckPingStatus(now);
- base::MessageLoop::current()->RunUntilIdle();
EXPECT_TRUE(session == NULL);
EXPECT_FALSE(HasSpdySession(spdy_session_pool_, key_));
@@ -1310,11 +1304,6 @@
EXPECT_EQ(OK, stream_releaser.WaitForResult());
data.RunFor(1);
- if (spdy_util_.spdy_version() >= SPDY4) {
- // Allow the SETTINGS+ACK to write, so the session finishes draining.
- data.RunFor(1);
- }
- base::MessageLoop::current()->RunUntilIdle();
EXPECT_TRUE(session == NULL);
}
@@ -1594,7 +1583,7 @@
EXPECT_NE(log.bound().source().id, socket_source.id);
}
-TEST_P(SpdySessionTest, NetLogOnSessionGoaway) {
+TEST_P(SpdySessionTest, CloseSessionOnError) {
session_deps_.host_resolver->set_synchronous_mode(true);
MockConnect connect_data(SYNCHRONOUS, OK);
@@ -1636,53 +1625,6 @@
CapturingNetLog::CapturedEntry entry = entries[pos];
int error_code = 0;
ASSERT_TRUE(entry.GetNetErrorCode(&error_code));
- EXPECT_EQ(OK, error_code);
- } else {
- ADD_FAILURE();
- }
-}
-
-TEST_P(SpdySessionTest, NetLogOnSessionEOF) {
- session_deps_.host_resolver->set_synchronous_mode(true);
-
- MockConnect connect_data(SYNCHRONOUS, OK);
- MockRead reads[] = {
- MockRead(SYNCHRONOUS, 0, 0) // EOF
- };
-
- StaticSocketDataProvider data(reads, arraysize(reads), NULL, 0);
- data.set_connect_data(connect_data);
- session_deps_.socket_factory->AddSocketDataProvider(&data);
-
- CreateNetworkSession();
-
- CapturingBoundNetLog log;
- base::WeakPtr<SpdySession> session =
- CreateInsecureSpdySession(http_session_, key_, log.bound());
- EXPECT_TRUE(HasSpdySession(spdy_session_pool_, key_));
-
- // Flush the read completion task.
- base::MessageLoop::current()->RunUntilIdle();
-
- EXPECT_FALSE(HasSpdySession(spdy_session_pool_, key_));
- EXPECT_TRUE(session == NULL);
-
- // Check that the NetLog was filled reasonably.
- net::CapturingNetLog::CapturedEntryList entries;
- log.GetEntries(&entries);
- EXPECT_LT(0u, entries.size());
-
- // Check that we logged SPDY_SESSION_CLOSE correctly.
- int pos =
- net::ExpectLogContainsSomewhere(entries,
- 0,
- net::NetLog::TYPE_SPDY_SESSION_CLOSE,
- net::NetLog::PHASE_NONE);
-
- if (pos < static_cast<int>(entries.size())) {
- CapturingNetLog::CapturedEntry entry = entries[pos];
- int error_code = 0;
- ASSERT_TRUE(entry.GetNetErrorCode(&error_code));
EXPECT_EQ(ERR_CONNECTION_CLOSED, error_code);
} else {
ADD_FAILURE();
@@ -1915,7 +1857,6 @@
EXPECT_TRUE(delegate1.StreamIsClosed());
EXPECT_TRUE(delegate2.StreamIsClosed());
- base::MessageLoop::current()->RunUntilIdle();
EXPECT_TRUE(session == NULL);
}
@@ -1989,7 +1930,6 @@
EXPECT_TRUE(delegate1.StreamIsClosed());
EXPECT_TRUE(delegate2.StreamIsClosed());
- base::MessageLoop::current()->RunUntilIdle();
EXPECT_TRUE(session == NULL);
}
@@ -2071,7 +2011,6 @@
EXPECT_TRUE(delegate1.StreamIsClosed());
EXPECT_TRUE(delegate2.StreamIsClosed());
- base::MessageLoop::current()->RunUntilIdle();
EXPECT_TRUE(session == NULL);
}
@@ -2155,7 +2094,6 @@
EXPECT_TRUE(delegate1.StreamIsClosed());
EXPECT_TRUE(delegate2.StreamIsClosed());
- base::MessageLoop::current()->RunUntilIdle();
EXPECT_TRUE(session == NULL);
}
@@ -2186,14 +2124,12 @@
scoped_ptr<SpdyFrame> req(
spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, MEDIUM, true));
- scoped_ptr<SpdyFrame> rst(
- spdy_util_.ConstructSpdyRstStream(1, RST_STREAM_CANCEL));
MockWrite writes[] = {
- CreateMockWrite(*req, 0), CreateMockWrite(*rst, 1),
+ CreateMockWrite(*req, 0),
};
MockRead reads[] = {
- MockRead(ASYNC, 0, 2) // EOF
+ MockRead(ASYNC, 0, 1) // EOF
};
DeterministicSocketData data(reads, arraysize(reads),
writes, arraysize(writes));
@@ -2230,12 +2166,8 @@
// session).
spdy_stream->Cancel();
- data.RunFor(1);
- base::MessageLoop::current()->RunUntilIdle();
-
EXPECT_EQ(NULL, spdy_stream.get());
EXPECT_TRUE(delegate.StreamIsClosed());
-
EXPECT_TRUE(session == NULL);
}
@@ -4376,7 +4308,6 @@
// Close the session (since we can't do it from within the delegate
// method, since it's in the stream's loop).
session->CloseSessionOnError(ERR_CONNECTION_CLOSED, "Closing session");
- base::RunLoop().RunUntilIdle();
EXPECT_TRUE(session == NULL);
EXPECT_FALSE(HasSpdySession(spdy_session_pool_, key_));
« no previous file with comments | « trunk/src/net/spdy/spdy_session_pool_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698