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

Side by Side Diff: net/spdy/spdy_session_spdy2_unittest.cc

Issue 15892015: [SPDY] Refactor SpdyStream state machine (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove default: Created 7 years, 6 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "net/spdy/spdy_session.h" 5 #include "net/spdy/spdy_session.h"
6 6
7 #include "base/memory/scoped_ptr.h" 7 #include "base/memory/scoped_ptr.h"
8 #include "base/run_loop.h" 8 #include "base/run_loop.h"
9 #include "net/base/io_buffer.h" 9 #include "net/base/io_buffer.h"
10 #include "net/base/ip_endpoint.h" 10 #include "net/base/ip_endpoint.h"
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 session_deps_.deterministic_socket_factory->AddSSLSocketDataProvider(&ssl); 158 session_deps_.deterministic_socket_factory->AddSSLSocketDataProvider(&ssl);
159 159
160 CreateDeterministicNetworkSession(); 160 CreateDeterministicNetworkSession();
161 161
162 scoped_refptr<SpdySession> session = CreateInitializedSession(); 162 scoped_refptr<SpdySession> session = CreateInitializedSession();
163 163
164 EXPECT_EQ(2, session->GetProtocolVersion()); 164 EXPECT_EQ(2, session->GetProtocolVersion());
165 165
166 GURL url("http://www.google.com"); 166 GURL url("http://www.google.com");
167 base::WeakPtr<SpdyStream> spdy_stream1 = 167 base::WeakPtr<SpdyStream> spdy_stream1 =
168 CreateStreamSynchronously( 168 CreateStreamSynchronously(SPDY_REQUEST_RESPONSE_STREAM,
169 SPDY_BIDIRECTIONAL_STREAM, session, url, MEDIUM, BoundNetLog()); 169 session, url, MEDIUM, BoundNetLog());
170 test::StreamDelegateDoNothing delegate1(spdy_stream1);
171 spdy_stream1->SetDelegate(&delegate1);
170 172
171 base::WeakPtr<SpdyStream> spdy_stream2 = 173 base::WeakPtr<SpdyStream> spdy_stream2 =
172 CreateStreamSynchronously( 174 CreateStreamSynchronously(SPDY_REQUEST_RESPONSE_STREAM,
173 SPDY_BIDIRECTIONAL_STREAM, session, url, MEDIUM, BoundNetLog()); 175 session, url, MEDIUM, BoundNetLog());
176 test::StreamDelegateDoNothing delegate2(spdy_stream2);
177 spdy_stream2->SetDelegate(&delegate2);
174 178
175 scoped_ptr<SpdyHeaderBlock> headers(new SpdyHeaderBlock); 179 scoped_ptr<SpdyHeaderBlock> headers(new SpdyHeaderBlock);
176 (*headers)["method"] = "GET"; 180 (*headers)["method"] = "GET";
177 (*headers)["scheme"] = url.scheme(); 181 (*headers)["scheme"] = url.scheme();
178 (*headers)["host"] = url.host(); 182 (*headers)["host"] = url.host();
179 (*headers)["url"] = url.path(); 183 (*headers)["url"] = url.path();
180 (*headers)["version"] = "HTTP/1.1"; 184 (*headers)["version"] = "HTTP/1.1";
181 scoped_ptr<SpdyHeaderBlock> headers2(new SpdyHeaderBlock); 185 scoped_ptr<SpdyHeaderBlock> headers2(new SpdyHeaderBlock);
182 *headers2 = *headers; 186 *headers2 = *headers;
183 187
(...skipping 979 matching lines...) Expand 10 before | Expand all | Expand 10 after
1163 SSLSocketDataProvider ssl(SYNCHRONOUS, OK); 1167 SSLSocketDataProvider ssl(SYNCHRONOUS, OK);
1164 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl); 1168 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl);
1165 1169
1166 CreateNetworkSession(); 1170 CreateNetworkSession();
1167 1171
1168 scoped_refptr<SpdySession> session = CreateInitializedSession(); 1172 scoped_refptr<SpdySession> session = CreateInitializedSession();
1169 1173
1170 GURL url("http://www.google.com"); 1174 GURL url("http://www.google.com");
1171 1175
1172 base::WeakPtr<SpdyStream> spdy_stream1 = 1176 base::WeakPtr<SpdyStream> spdy_stream1 =
1173 CreateStreamSynchronously( 1177 CreateStreamSynchronously(SPDY_REQUEST_RESPONSE_STREAM,
1174 SPDY_BIDIRECTIONAL_STREAM, session, url, LOWEST, BoundNetLog()); 1178 session, url, LOWEST, BoundNetLog());
1175 ASSERT_TRUE(spdy_stream1.get() != NULL); 1179 ASSERT_TRUE(spdy_stream1.get() != NULL);
1176 EXPECT_EQ(0u, spdy_stream1->stream_id()); 1180 EXPECT_EQ(0u, spdy_stream1->stream_id());
1177 test::StreamDelegateDoNothing delegate1(spdy_stream1); 1181 test::StreamDelegateDoNothing delegate1(spdy_stream1);
1178 spdy_stream1->SetDelegate(&delegate1); 1182 spdy_stream1->SetDelegate(&delegate1);
1179 1183
1180 base::WeakPtr<SpdyStream> spdy_stream2 = 1184 base::WeakPtr<SpdyStream> spdy_stream2 =
1181 CreateStreamSynchronously(SPDY_BIDIRECTIONAL_STREAM, 1185 CreateStreamSynchronously(SPDY_REQUEST_RESPONSE_STREAM,
1182 session, url, HIGHEST, BoundNetLog()); 1186 session, url, HIGHEST, BoundNetLog());
1183 ASSERT_TRUE(spdy_stream2.get() != NULL); 1187 ASSERT_TRUE(spdy_stream2.get() != NULL);
1184 EXPECT_EQ(0u, spdy_stream2->stream_id()); 1188 EXPECT_EQ(0u, spdy_stream2->stream_id());
1185 test::StreamDelegateDoNothing delegate2(spdy_stream2); 1189 test::StreamDelegateDoNothing delegate2(spdy_stream2);
1186 spdy_stream2->SetDelegate(&delegate2); 1190 spdy_stream2->SetDelegate(&delegate2);
1187 1191
1188 scoped_ptr<SpdyHeaderBlock> headers(new SpdyHeaderBlock); 1192 scoped_ptr<SpdyHeaderBlock> headers(new SpdyHeaderBlock);
1189 (*headers)["method"] = "GET"; 1193 (*headers)["method"] = "GET";
1190 (*headers)["scheme"] = url.scheme(); 1194 (*headers)["scheme"] = url.scheme();
1191 (*headers)["host"] = url.host(); 1195 (*headers)["host"] = url.host();
(...skipping 929 matching lines...) Expand 10 before | Expand all | Expand 10 after
2121 2125
2122 SSLSocketDataProvider ssl(SYNCHRONOUS, OK); 2126 SSLSocketDataProvider ssl(SYNCHRONOUS, OK);
2123 session_deps_.deterministic_socket_factory->AddSSLSocketDataProvider(&ssl); 2127 session_deps_.deterministic_socket_factory->AddSSLSocketDataProvider(&ssl);
2124 2128
2125 CreateDeterministicNetworkSession(); 2129 CreateDeterministicNetworkSession();
2126 2130
2127 scoped_refptr<SpdySession> session = CreateInitializedSession(); 2131 scoped_refptr<SpdySession> session = CreateInitializedSession();
2128 2132
2129 GURL url1("http://www.google.com"); 2133 GURL url1("http://www.google.com");
2130 base::WeakPtr<SpdyStream> spdy_stream1 = 2134 base::WeakPtr<SpdyStream> spdy_stream1 =
2131 CreateStreamSynchronously(SPDY_BIDIRECTIONAL_STREAM, 2135 CreateStreamSynchronously(SPDY_REQUEST_RESPONSE_STREAM,
2132 session, url1, MEDIUM, BoundNetLog()); 2136 session, url1, MEDIUM, BoundNetLog());
2137 test::StreamDelegateDoNothing delegate1(spdy_stream1);
2138 spdy_stream1->SetDelegate(&delegate1);
2133 session = NULL; 2139 session = NULL;
2134 ASSERT_TRUE(spdy_stream1.get() != NULL); 2140 ASSERT_TRUE(spdy_stream1.get() != NULL);
2135 EXPECT_EQ(0u, spdy_stream1->stream_id()); 2141 EXPECT_EQ(0u, spdy_stream1->stream_id());
2136 2142
2137 scoped_ptr<SpdyHeaderBlock> headers(new SpdyHeaderBlock); 2143 scoped_ptr<SpdyHeaderBlock> headers(new SpdyHeaderBlock);
2138 (*headers)["method"] = "GET"; 2144 (*headers)["method"] = "GET";
2139 (*headers)["scheme"] = url1.scheme(); 2145 (*headers)["scheme"] = url1.scheme();
2140 (*headers)["host"] = url1.host(); 2146 (*headers)["host"] = url1.host();
2141 (*headers)["url"] = url1.path(); 2147 (*headers)["url"] = url1.path();
2142 (*headers)["version"] = "HTTP/1.1"; 2148 (*headers)["version"] = "HTTP/1.1";
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
2344 EXPECT_EQ( 2350 EXPECT_EQ(
2345 OK, 2351 OK,
2346 InitializeSession(http_session_.get(), session1.get(), 2352 InitializeSession(http_session_.get(), session1.get(),
2347 key1.host_port_pair())); 2353 key1.host_port_pair()));
2348 EXPECT_FALSE(pool->IsStalled()); 2354 EXPECT_FALSE(pool->IsStalled());
2349 2355
2350 // Create a stream using the session, and send a request. 2356 // Create a stream using the session, and send a request.
2351 2357
2352 TestCompletionCallback callback1; 2358 TestCompletionCallback callback1;
2353 base::WeakPtr<SpdyStream> spdy_stream1 = 2359 base::WeakPtr<SpdyStream> spdy_stream1 =
2354 CreateStreamSynchronously(SPDY_BIDIRECTIONAL_STREAM, 2360 CreateStreamSynchronously(SPDY_REQUEST_RESPONSE_STREAM,
2355 session1, url1, DEFAULT_PRIORITY, 2361 session1, url1, DEFAULT_PRIORITY,
2356 BoundNetLog()); 2362 BoundNetLog());
2357 ASSERT_TRUE(spdy_stream1.get()); 2363 ASSERT_TRUE(spdy_stream1.get());
2364 test::StreamDelegateDoNothing delegate1(spdy_stream1);
2365 spdy_stream1->SetDelegate(&delegate1);
2358 2366
2359 scoped_ptr<SpdyHeaderBlock> headers( 2367 scoped_ptr<SpdyHeaderBlock> headers(
2360 spdy_util_.ConstructGetHeaderBlock(url1.spec())); 2368 spdy_util_.ConstructGetHeaderBlock(url1.spec()));
2361 spdy_stream1->SendRequestHeaders(headers.Pass(), NO_MORE_DATA_TO_SEND); 2369 spdy_stream1->SendRequestHeaders(headers.Pass(), NO_MORE_DATA_TO_SEND);
2362 EXPECT_TRUE(spdy_stream1->HasUrl()); 2370 EXPECT_TRUE(spdy_stream1->HasUrl());
2363 base::MessageLoop::current()->RunUntilIdle(); 2371 base::MessageLoop::current()->RunUntilIdle();
2364 2372
2365 // Release the session, so holding onto a pointer here does not affect 2373 // Release the session, so holding onto a pointer here does not affect
2366 // anything. 2374 // anything.
2367 session1 = NULL; 2375 session1 = NULL;
(...skipping 21 matching lines...) Expand all
2389 // Cancelling the request should still not release the session's socket, 2397 // Cancelling the request should still not release the session's socket,
2390 // since the session is still kept alive by the SpdySessionPool. 2398 // since the session is still kept alive by the SpdySessionPool.
2391 ASSERT_TRUE(spdy_stream1.get()); 2399 ASSERT_TRUE(spdy_stream1.get());
2392 spdy_stream1->Cancel(); 2400 spdy_stream1->Cancel();
2393 base::RunLoop().RunUntilIdle(); 2401 base::RunLoop().RunUntilIdle();
2394 EXPECT_TRUE(pool->IsStalled()); 2402 EXPECT_TRUE(pool->IsStalled());
2395 EXPECT_FALSE(callback2.have_result()); 2403 EXPECT_FALSE(callback2.have_result());
2396 } 2404 }
2397 2405
2398 } // namespace net 2406 } // namespace net
OLDNEW
« no previous file with comments | « net/spdy/spdy_network_transaction_spdy3_unittest.cc ('k') | net/spdy/spdy_session_spdy3_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698