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

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 TOT 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
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 HttpStreamFactoryImpl* factory =
111 static_cast<HttpStreamFactoryImpl*>(session->http_stream_factory());
112
113 DoNothingRequestDelegate request_delegate;
114 HttpRequestInfo request_info;
115 request_info.method = "GET";
116 request_info.url = GURL("http://www.google.com");
117
118 HttpStreamFactoryImpl::Request request(
119 request_info.url, factory, &request_delegate, NULL, BoundNetLog(),
120 HttpStreamFactoryImpl::Request::HTTP_STREAM);
121
122 HostPortPair server = HostPortPair::FromURL(request_info.url);
123 GURL original_url = factory->ApplyHostMappingRules(request_info.url, &server);
124
125 HttpStreamFactoryImpl::Job* job = new HttpStreamFactoryImpl::Job(
126 factory, session.get(), request_info, DEFAULT_PRIORITY, SSLConfig(),
127 SSLConfig(), server, original_url, NULL);
128 request.AttachJob(job);
129 EXPECT_EQ(DEFAULT_PRIORITY, job->priority());
130
131 AlternativeService alternative_service(net::NPN_HTTP_2, server);
132 HttpStreamFactoryImpl::Job* alternative_job = new HttpStreamFactoryImpl::Job(
133 factory, session.get(), request_info, DEFAULT_PRIORITY, SSLConfig(),
134 SSLConfig(), server, original_url, alternative_service, NULL);
135 request.AttachJob(alternative_job);
136
137 job->WaitFor(alternative_job);
138 EXPECT_EQ(HttpStreamFactoryImpl::Job::STATE_NONE, job->next_state_);
139
140 // Test |alternative_job| resuming the |job| after delay.
141 base::TimeDelta delay = base::TimeDelta::FromMilliseconds(1);
142 job->Resume(alternative_job, delay);
143
144 // Verify |job| has |wait_time_| and there is no |blocking_job_|
145 EXPECT_EQ(delay, job->wait_time_);
146 EXPECT_TRUE(!job->blocking_job_);
147
148 // Start the job to verify DoWaitForJob() and ResumeWaitingJobAfterDelay()
149 // methods are called. |next_state_| should be |STATE_WAIT_FOR_JOB_COMPLETE|.
150 job->Start(&request);
151
152 // When |job|'s ResumeWaitingJobAfterDelay() is called, |job|'s |wait_time_|
153 // should be cleared.
154 EXPECT_NE(delay, job->wait_time_);
155 EXPECT_TRUE(job->wait_time_.is_zero());
156 EXPECT_EQ(HttpStreamFactoryImpl::Job::STATE_WAIT_FOR_JOB_COMPLETE,
157 job->next_state_);
158 }
159
104 } // namespace net 160 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698