| 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 <utility> | 10 #include <utility> |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 182 "http://m.google.com/resource2.html"))); | 182 "http://m.google.com/resource2.html"))); |
| 183 requests->push_back(new ResourcePrefetcher::Request(GURL( | 183 requests->push_back(new ResourcePrefetcher::Request(GURL( |
| 184 "http://m.google.com/resource3.css"))); | 184 "http://m.google.com/resource3.css"))); |
| 185 requests->push_back(new ResourcePrefetcher::Request(GURL( | 185 requests->push_back(new ResourcePrefetcher::Request(GURL( |
| 186 "http://m.google.com/resource4.png"))); | 186 "http://m.google.com/resource4.png"))); |
| 187 requests->push_back(new ResourcePrefetcher::Request(GURL( | 187 requests->push_back(new ResourcePrefetcher::Request(GURL( |
| 188 "http://yahoo.com/resource4.png"))); | 188 "http://yahoo.com/resource4.png"))); |
| 189 requests->push_back(new ResourcePrefetcher::Request(GURL( | 189 requests->push_back(new ResourcePrefetcher::Request(GURL( |
| 190 "http://yahoo.com/resource5.png"))); | 190 "http://yahoo.com/resource5.png"))); |
| 191 | 191 |
| 192 NavigationID navigation_id; | 192 NavigationID navigation_id(1, 2, GURL("http://www.google.com")); |
| 193 navigation_id.render_process_id = 1; | |
| 194 navigation_id.render_frame_id = 2; | |
| 195 navigation_id.main_frame_url = GURL("http://www.google.com"); | |
| 196 | 193 |
| 197 // Needed later for comparison. | 194 // Needed later for comparison. |
| 198 ResourcePrefetcher::RequestVector* requests_ptr = requests.get(); | 195 ResourcePrefetcher::RequestVector* requests_ptr = requests.get(); |
| 199 | 196 |
| 200 prefetcher_.reset( | 197 prefetcher_.reset( |
| 201 new TestResourcePrefetcher(&prefetcher_delegate_, config_, navigation_id, | 198 new TestResourcePrefetcher(&prefetcher_delegate_, config_, navigation_id, |
| 202 PREFETCH_KEY_TYPE_URL, std::move(requests))); | 199 PREFETCH_KEY_TYPE_URL, std::move(requests))); |
| 203 | 200 |
| 204 // Starting the prefetcher maxes out the number of possible requests. | 201 // Starting the prefetcher maxes out the number of possible requests. |
| 205 AddStartUrlRequestExpectation("http://www.google.com/resource1.html"); | 202 AddStartUrlRequestExpectation("http://www.google.com/resource1.html"); |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 303 "http://www.google.com/resource2.png"))); | 300 "http://www.google.com/resource2.png"))); |
| 304 requests->push_back(new ResourcePrefetcher::Request(GURL( | 301 requests->push_back(new ResourcePrefetcher::Request(GURL( |
| 305 "http://yahoo.com/resource1.png"))); | 302 "http://yahoo.com/resource1.png"))); |
| 306 requests->push_back(new ResourcePrefetcher::Request(GURL( | 303 requests->push_back(new ResourcePrefetcher::Request(GURL( |
| 307 "http://yahoo.com/resource2.png"))); | 304 "http://yahoo.com/resource2.png"))); |
| 308 requests->push_back(new ResourcePrefetcher::Request(GURL( | 305 requests->push_back(new ResourcePrefetcher::Request(GURL( |
| 309 "http://yahoo.com/resource3.png"))); | 306 "http://yahoo.com/resource3.png"))); |
| 310 requests->push_back(new ResourcePrefetcher::Request(GURL( | 307 requests->push_back(new ResourcePrefetcher::Request(GURL( |
| 311 "http://m.google.com/resource1.jpg"))); | 308 "http://m.google.com/resource1.jpg"))); |
| 312 | 309 |
| 313 NavigationID navigation_id; | 310 NavigationID navigation_id(1, 2, GURL("http://www.google.com")); |
| 314 navigation_id.render_process_id = 1; | |
| 315 navigation_id.render_frame_id = 2; | |
| 316 navigation_id.main_frame_url = GURL("http://www.google.com"); | |
| 317 | 311 |
| 318 // Needed later for comparison. | 312 // Needed later for comparison. |
| 319 ResourcePrefetcher::RequestVector* requests_ptr = requests.get(); | 313 ResourcePrefetcher::RequestVector* requests_ptr = requests.get(); |
| 320 | 314 |
| 321 prefetcher_.reset( | 315 prefetcher_.reset( |
| 322 new TestResourcePrefetcher(&prefetcher_delegate_, config_, navigation_id, | 316 new TestResourcePrefetcher(&prefetcher_delegate_, config_, navigation_id, |
| 323 PREFETCH_KEY_TYPE_HOST, std::move(requests))); | 317 PREFETCH_KEY_TYPE_HOST, std::move(requests))); |
| 324 | 318 |
| 325 // Starting the prefetcher maxes out the number of possible requests. | 319 // Starting the prefetcher maxes out the number of possible requests. |
| 326 AddStartUrlRequestExpectation("http://www.google.com/resource1.html"); | 320 AddStartUrlRequestExpectation("http://www.google.com/resource1.html"); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 357 // We need to delete requests_ptr here, though it looks to be managed by the | 351 // We need to delete requests_ptr here, though it looks to be managed by the |
| 358 // scoped_ptr requests. The scoped_ptr requests releases itself and the raw | 352 // scoped_ptr requests. The scoped_ptr requests releases itself and the raw |
| 359 // pointer requests_ptr is passed to ResourcePrefetcherFinished(). In the | 353 // pointer requests_ptr is passed to ResourcePrefetcherFinished(). In the |
| 360 // test, ResourcePrefetcherFinished() is a mock function and does not handle | 354 // test, ResourcePrefetcherFinished() is a mock function and does not handle |
| 361 // the raw pointer properly. In the real code, requests_ptr will eventually be | 355 // the raw pointer properly. In the real code, requests_ptr will eventually be |
| 362 // passed to and managed by ResourcePrefetchPredictor::Result::Result. | 356 // passed to and managed by ResourcePrefetchPredictor::Result::Result. |
| 363 delete requests_ptr; | 357 delete requests_ptr; |
| 364 } | 358 } |
| 365 | 359 |
| 366 } // namespace predictors | 360 } // namespace predictors |
| OLD | NEW |