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

Side by Side Diff: content/browser/loader/resource_scheduler_unittest.cc

Issue 1192673002: Ensure ResourceScheduler starts requests even if the tab is closed. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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
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 "content/browser/loader/resource_scheduler.h" 5 #include "content/browser/loader/resource_scheduler.h"
6 6
7 #include "base/memory/scoped_vector.h" 7 #include "base/memory/scoped_vector.h"
8 #include "base/message_loop/message_loop.h" 8 #include "base/message_loop/message_loop.h"
9 #include "base/run_loop.h" 9 #include "base/run_loop.h"
10 #include "base/strings/string_number_conversions.h" 10 #include "base/strings/string_number_conversions.h"
(...skipping 2195 matching lines...) Expand 10 before | Expand all | Expand 10 after
2206 rvh2->GetRoutingID())); 2206 rvh2->GetRoutingID()));
2207 // Clean up. 2207 // Clean up.
2208 web_contents_1.reset(); 2208 web_contents_1.reset();
2209 web_contents_2.reset(); 2209 web_contents_2.reset();
2210 base::RunLoop().RunUntilIdle(); 2210 base::RunLoop().RunUntilIdle();
2211 2211
2212 browser_context.reset(); 2212 browser_context.reset();
2213 render_process_host_factory.reset(); 2213 render_process_host_factory.reset();
2214 } 2214 }
2215 2215
2216 // Async revalidations which are not started when the tab is closed must be
2217 // started at some point, or they will hang around forever and prevent other
2218 // async revalidations to the same URL from being issued.
2219 TEST_F(ResourceSchedulerTest, RequestStartedAfterClientDeleted) {
2220 scheduler_.OnClientCreated(kChildId2, kRouteId2, false, false);
2221 scoped_ptr<TestRequest> high(NewRequestWithChildAndRoute(
2222 "http://host/high", net::HIGHEST, kChildId2, kRouteId2));
2223 scoped_ptr<TestRequest> lowest1(NewRequestWithChildAndRoute(
2224 "http://host/lowest", net::LOWEST, kChildId2, kRouteId2));
2225 scoped_ptr<TestRequest> lowest2(NewRequestWithChildAndRoute(
2226 "http://host/lowest", net::LOWEST, kChildId2, kRouteId2));
2227 EXPECT_FALSE(lowest2->started());
2228 scheduler_.OnClientDeleted(kChildId2, kRouteId2);
2229 high.reset();
2230 lowest1.reset();
2231 EXPECT_TRUE(lowest2->started());
2232 }
2233
2234 // The ResourceScheduler::Client destructor calls
2235 // LoadAnyStartablePendingRequests(), which may start some pending requests.
2236 // This test is to verify that requests will be started at some point
2237 // even if they were not started by the destructor.
2238 TEST_F(ResourceSchedulerTest, RequestStartedAfterClientDeletedManyDelayable) {
2239 scheduler_.OnClientCreated(kChildId2, kRouteId2, false, false);
2240 scoped_ptr<TestRequest> high(NewRequestWithChildAndRoute(
2241 "http://host/high", net::HIGHEST, kChildId2, kRouteId2));
2242 const int kMaxNumDelayableRequestsPerClient = 10;
2243 ScopedVector<TestRequest> delayable_requests;
2244 for (int i = 0; i < kMaxNumDelayableRequestsPerClient + 1; ++i) {
2245 delayable_requests.push_back(NewRequestWithChildAndRoute(
2246 "http://host/lowest", net::LOWEST, kChildId2, kRouteId2));
2247 }
2248 scoped_ptr<TestRequest> lowest(NewRequestWithChildAndRoute(
2249 "http://host/lowest", net::LOWEST, kChildId2, kRouteId2));
2250 EXPECT_FALSE(lowest->started());
2251 scheduler_.OnClientDeleted(kChildId2, kRouteId2);
2252 high.reset();
2253 delayable_requests.clear();
2254 EXPECT_TRUE(lowest->started());
2255 }
2256
2216 } // unnamed namespace 2257 } // unnamed namespace
2217 2258
2218 } // namespace content 2259 } // namespace content
OLDNEW
« content/browser/loader/resource_scheduler.cc ('K') | « content/browser/loader/resource_scheduler.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698