OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "chrome/browser/predictors/resource_prefetcher.h" | 5 #include "chrome/browser/predictors/resource_prefetcher.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <memory> | 9 #include <memory> |
10 #include <string> | 10 #include <string> |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 GURL("http://yahoo.com/resource2.png"), | 159 GURL("http://yahoo.com/resource2.png"), |
160 GURL("http://yahoo.com/resource3.png"), | 160 GURL("http://yahoo.com/resource3.png"), |
161 GURL("http://m.google.com/resource1.jpg"), | 161 GURL("http://m.google.com/resource1.jpg"), |
162 GURL("http://www.google.com/resource3.html"), | 162 GURL("http://www.google.com/resource3.html"), |
163 GURL("http://m.google.com/resource2.html"), | 163 GURL("http://m.google.com/resource2.html"), |
164 GURL("http://m.google.com/resource3.css"), | 164 GURL("http://m.google.com/resource3.css"), |
165 GURL("http://m.google.com/resource4.png"), | 165 GURL("http://m.google.com/resource4.png"), |
166 GURL("http://yahoo.com/resource4.png"), | 166 GURL("http://yahoo.com/resource4.png"), |
167 GURL("http://yahoo.com/resource5.png")}; | 167 GURL("http://yahoo.com/resource5.png")}; |
168 | 168 |
169 NavigationID navigation_id = CreateNavigationID(1, 2, main_frame_url.spec()); | 169 NavigationID navigation_id = CreateNavigationID(1, main_frame_url.spec()); |
170 | 170 |
171 prefetcher_.reset(new TestResourcePrefetcher(&prefetcher_delegate_, config_, | 171 prefetcher_.reset(new TestResourcePrefetcher(&prefetcher_delegate_, config_, |
172 main_frame_url, urls)); | 172 main_frame_url, urls)); |
173 | 173 |
174 // Starting the prefetcher maxes out the number of possible requests. | 174 // Starting the prefetcher maxes out the number of possible requests. |
175 AddStartUrlRequestExpectation("http://www.google.com/resource1.html"); | 175 AddStartUrlRequestExpectation("http://www.google.com/resource1.html"); |
176 AddStartUrlRequestExpectation("http://www.google.com/resource2.png"); | 176 AddStartUrlRequestExpectation("http://www.google.com/resource2.png"); |
177 AddStartUrlRequestExpectation("http://yahoo.com/resource1.png"); | 177 AddStartUrlRequestExpectation("http://yahoo.com/resource1.png"); |
178 AddStartUrlRequestExpectation("http://yahoo.com/resource2.png"); | 178 AddStartUrlRequestExpectation("http://yahoo.com/resource2.png"); |
179 AddStartUrlRequestExpectation("http://m.google.com/resource1.jpg"); | 179 AddStartUrlRequestExpectation("http://m.google.com/resource1.jpg"); |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
231 | 231 |
232 TEST_F(ResourcePrefetcherTest, TestPrefetcherStopped) { | 232 TEST_F(ResourcePrefetcherTest, TestPrefetcherStopped) { |
233 GURL main_frame_url("http://www.google.com"); | 233 GURL main_frame_url("http://www.google.com"); |
234 std::vector<GURL> urls = {GURL("http://www.google.com/resource1.html"), | 234 std::vector<GURL> urls = {GURL("http://www.google.com/resource1.html"), |
235 GURL("http://www.google.com/resource2.png"), | 235 GURL("http://www.google.com/resource2.png"), |
236 GURL("http://yahoo.com/resource1.png"), | 236 GURL("http://yahoo.com/resource1.png"), |
237 GURL("http://yahoo.com/resource2.png"), | 237 GURL("http://yahoo.com/resource2.png"), |
238 GURL("http://yahoo.com/resource3.png"), | 238 GURL("http://yahoo.com/resource3.png"), |
239 GURL("http://m.google.com/resource1.jpg")}; | 239 GURL("http://m.google.com/resource1.jpg")}; |
240 | 240 |
241 NavigationID navigation_id = CreateNavigationID(1, 2, main_frame_url.spec()); | 241 NavigationID navigation_id = CreateNavigationID(1, main_frame_url.spec()); |
242 | 242 |
243 prefetcher_.reset(new TestResourcePrefetcher(&prefetcher_delegate_, config_, | 243 prefetcher_.reset(new TestResourcePrefetcher(&prefetcher_delegate_, config_, |
244 main_frame_url, urls)); | 244 main_frame_url, urls)); |
245 | 245 |
246 // Starting the prefetcher maxes out the number of possible requests. | 246 // Starting the prefetcher maxes out the number of possible requests. |
247 AddStartUrlRequestExpectation("http://www.google.com/resource1.html"); | 247 AddStartUrlRequestExpectation("http://www.google.com/resource1.html"); |
248 AddStartUrlRequestExpectation("http://www.google.com/resource2.png"); | 248 AddStartUrlRequestExpectation("http://www.google.com/resource2.png"); |
249 AddStartUrlRequestExpectation("http://yahoo.com/resource1.png"); | 249 AddStartUrlRequestExpectation("http://yahoo.com/resource1.png"); |
250 AddStartUrlRequestExpectation("http://yahoo.com/resource2.png"); | 250 AddStartUrlRequestExpectation("http://yahoo.com/resource2.png"); |
251 AddStartUrlRequestExpectation("http://m.google.com/resource1.jpg"); | 251 AddStartUrlRequestExpectation("http://m.google.com/resource1.jpg"); |
(...skipping 17 matching lines...) Expand all Loading... |
269 | 269 |
270 // Expect the final call. | 270 // Expect the final call. |
271 EXPECT_CALL(prefetcher_delegate_, | 271 EXPECT_CALL(prefetcher_delegate_, |
272 ResourcePrefetcherFinished(Eq(prefetcher_.get()))); | 272 ResourcePrefetcherFinished(Eq(prefetcher_.get()))); |
273 | 273 |
274 OnResponse("http://m.google.com/resource1.jpg"); | 274 OnResponse("http://m.google.com/resource1.jpg"); |
275 CheckPrefetcherState(0, 1, 0); | 275 CheckPrefetcherState(0, 1, 0); |
276 } | 276 } |
277 | 277 |
278 } // namespace predictors | 278 } // namespace predictors |
OLD | NEW |