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

Side by Side Diff: chrome/browser/predictors/resource_prefetch_predictor_browsertest.cc

Issue 2749583003: predictors: Don't record URLs with a port. (Closed)
Patch Set: Add a comment. Created 3 years, 9 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 <stddef.h> 5 #include <stddef.h>
6 6
7 #include <set> 7 #include <set>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after
323 embedded_test_server()->RegisterRequestHandler( 323 embedded_test_server()->RegisterRequestHandler(
324 base::Bind(&ResourcePrefetchPredictorBrowserTest::HandleResourceRequest, 324 base::Bind(&ResourcePrefetchPredictorBrowserTest::HandleResourceRequest,
325 base::Unretained(this))); 325 base::Unretained(this)));
326 embedded_test_server()->RegisterRequestMonitor(base::Bind( 326 embedded_test_server()->RegisterRequestMonitor(base::Bind(
327 &ResourcePrefetchPredictorBrowserTest::MonitorResourceRequest, 327 &ResourcePrefetchPredictorBrowserTest::MonitorResourceRequest,
328 base::Unretained(this))); 328 base::Unretained(this)));
329 ASSERT_TRUE(embedded_test_server()->Start()); 329 ASSERT_TRUE(embedded_test_server()->Start());
330 predictor_ = 330 predictor_ =
331 ResourcePrefetchPredictorFactory::GetForProfile(browser()->profile()); 331 ResourcePrefetchPredictorFactory::GetForProfile(browser()->profile());
332 ASSERT_TRUE(predictor_); 332 ASSERT_TRUE(predictor_);
333 // URLs from the test server contain a port number.
334 ResourcePrefetchPredictor::SetAllowPortInUrlsForTesting(true);
333 EnsurePredictorInitialized(); 335 EnsurePredictorInitialized();
334 histogram_tester_.reset(new base::HistogramTester()); 336 histogram_tester_.reset(new base::HistogramTester());
335 } 337 }
336 338
339 void TearDownOnMainThread() override {
340 ResourcePrefetchPredictor::SetAllowPortInUrlsForTesting(false);
droger 2017/03/16 12:02:27 Nit, optional: Could we use ScopedClosureRunner to
341 }
342
337 void TestLearningAndPrefetching(const GURL& main_frame_url) { 343 void TestLearningAndPrefetching(const GURL& main_frame_url) {
338 // Navigate to |main_frame_url| and check all the expectations. 344 // Navigate to |main_frame_url| and check all the expectations.
339 NavigateToURLAndCheckSubresources(main_frame_url); 345 NavigateToURLAndCheckSubresources(main_frame_url);
340 ClearCache(); 346 ClearCache();
341 // It is needed to have at least two resource hits to trigger prefetch. 347 // It is needed to have at least two resource hits to trigger prefetch.
342 NavigateToURLAndCheckSubresources(main_frame_url); 348 NavigateToURLAndCheckSubresources(main_frame_url);
343 ClearCache(); 349 ClearCache();
344 // Prefetch all needed resources and change expectations so that all 350 // Prefetch all needed resources and change expectations so that all
345 // cacheable resources should be served from cache next navigation. 351 // cacheable resources should be served from cache next navigation.
346 PrefetchURL(main_frame_url); 352 PrefetchURL(main_frame_url);
(...skipping 624 matching lines...) Expand 10 before | Expand all | Expand 10 after
971 net::HIGHEST); 977 net::HIGHEST);
972 978
973 NavigateToURLAndCheckSubresources(initial_url); 979 NavigateToURLAndCheckSubresources(initial_url);
974 ClearCache(); 980 ClearCache();
975 NavigateToURLAndCheckSubresources(initial_url); 981 NavigateToURLAndCheckSubresources(initial_url);
976 ClearCache(); 982 ClearCache();
977 NavigateToURLAndCheckPrefetching(initial_url); 983 NavigateToURLAndCheckPrefetching(initial_url);
978 } 984 }
979 985
980 } // namespace predictors 986 } // namespace predictors
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698