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

Side by Side Diff: net/http/http_stream_factory_impl_request_unittest.cc

Issue 1586513002: QUIC - Whne alternate job decides to delay the main(TCP) job and if the (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase and fix comments Created 4 years, 11 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
« no previous file with comments | « net/http/http_stream_factory_impl_job.cc ('k') | net/log/net_log_event_type_list.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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/http/http_stream_factory_impl_request.h" 5 #include "net/http/http_stream_factory_impl_request.h"
6 6
7 #include "base/memory/scoped_ptr.h" 7 #include "base/memory/scoped_ptr.h"
8 #include "net/http/http_stream_factory_impl_job.h" 8 #include "net/http/http_stream_factory_impl_job.h"
9 #include "net/proxy/proxy_info.h" 9 #include "net/proxy/proxy_info.h"
10 #include "net/proxy/proxy_service.h" 10 #include "net/proxy/proxy_service.h"
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 request.SetPriority(MEDIUM); 94 request.SetPriority(MEDIUM);
95 EXPECT_EQ(MEDIUM, job->priority()); 95 EXPECT_EQ(MEDIUM, job->priority());
96 96
97 // Make |job| the bound job. 97 // Make |job| the bound job.
98 request.OnStreamFailed(job, ERR_FAILED, SSLConfig(), SSL_FAILURE_NONE); 98 request.OnStreamFailed(job, ERR_FAILED, SSLConfig(), SSL_FAILURE_NONE);
99 99
100 request.SetPriority(IDLE); 100 request.SetPriority(IDLE);
101 EXPECT_EQ(IDLE, job->priority()); 101 EXPECT_EQ(IDLE, job->priority());
102 } 102 }
103 103
104 TEST_P(HttpStreamFactoryImplRequestTest, DelayMainJob) {
105 SpdySessionDependencies session_deps(GetParam(),
106 ProxyService::CreateDirect());
107
108 scoped_ptr<HttpNetworkSession> session =
109 SpdySessionDependencies::SpdyCreateSession(&session_deps);
110
111 StaticSocketDataProvider socket_data;
112 socket_data.set_connect_data(MockConnect(SYNCHRONOUS, ERR_IO_PENDING));
113 session_deps.socket_factory->AddSocketDataProvider(&socket_data);
114
115 HttpStreamFactoryImpl* factory =
116 static_cast<HttpStreamFactoryImpl*>(session->http_stream_factory());
117
118 DoNothingRequestDelegate request_delegate;
119 HttpRequestInfo request_info;
120 request_info.method = "GET";
121 request_info.url = GURL("http://www.google.com");
122
123 HttpStreamFactoryImpl::Request request(
124 request_info.url, factory, &request_delegate, NULL, BoundNetLog(),
125 HttpStreamFactoryImpl::Request::HTTP_STREAM);
126
127 HostPortPair server = HostPortPair::FromURL(request_info.url);
128 GURL original_url = factory->ApplyHostMappingRules(request_info.url, &server);
129
130 HttpStreamFactoryImpl::Job* job = new HttpStreamFactoryImpl::Job(
131 factory, session.get(), request_info, DEFAULT_PRIORITY, SSLConfig(),
132 SSLConfig(), server, original_url, NULL);
133 request.AttachJob(job);
134 EXPECT_EQ(DEFAULT_PRIORITY, job->priority());
135
136 AlternativeService alternative_service(net::NPN_HTTP_2, server);
137 HttpStreamFactoryImpl::Job* alternative_job = new HttpStreamFactoryImpl::Job(
138 factory, session.get(), request_info, DEFAULT_PRIORITY, SSLConfig(),
139 SSLConfig(), server, original_url, alternative_service, NULL);
140 request.AttachJob(alternative_job);
141
142 job->WaitFor(alternative_job);
143 EXPECT_EQ(HttpStreamFactoryImpl::Job::STATE_NONE, job->next_state_);
144
145 // Test |alternative_job| resuming the |job| after delay.
146 int wait_time = 1;
147 base::TimeDelta delay = base::TimeDelta::FromMilliseconds(wait_time);
148 job->Resume(alternative_job, delay);
149
150 // Verify |job| has |wait_time_| and there is no |blocking_job_|
151 EXPECT_EQ(delay, job->wait_time_);
152 EXPECT_TRUE(!job->blocking_job_);
153
154 // Start the |job| and verify |job|'s |wait_time_| is cleared.
155 job->Start(&request);
156
157 base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(wait_time + 1));
158 base::MessageLoop::current()->RunUntilIdle();
159
160 EXPECT_NE(delay, job->wait_time_);
161 EXPECT_TRUE(job->wait_time_.is_zero());
162 EXPECT_EQ(HttpStreamFactoryImpl::Job::STATE_INIT_CONNECTION_COMPLETE,
163 job->next_state_);
164 }
165
104 } // namespace net 166 } // namespace net
OLDNEW
« no previous file with comments | « net/http/http_stream_factory_impl_job.cc ('k') | net/log/net_log_event_type_list.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698