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