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

Side by Side Diff: chrome/browser/net/predictor.cc

Issue 644123002: Componentize renderer side of DNS prefetching. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: LOG(ERROR) --> LOG(DFATAL) for IPC checks Created 6 years, 1 month 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
« no previous file with comments | « chrome/browser/net/predictor.h ('k') | chrome/browser/net/predictor_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "chrome/browser/net/predictor.h" 5 #include "chrome/browser/net/predictor.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cmath> 8 #include <cmath>
9 #include <set> 9 #include <set>
10 #include <sstream> 10 #include <sstream>
(...skipping 15 matching lines...) Expand all
26 #include "base/time/time.h" 26 #include "base/time/time.h"
27 #include "base/values.h" 27 #include "base/values.h"
28 #include "chrome/browser/io_thread.h" 28 #include "chrome/browser/io_thread.h"
29 #include "chrome/browser/net/preconnect.h" 29 #include "chrome/browser/net/preconnect.h"
30 #include "chrome/browser/net/spdyproxy/proxy_advisor.h" 30 #include "chrome/browser/net/spdyproxy/proxy_advisor.h"
31 #include "chrome/browser/prefs/session_startup_pref.h" 31 #include "chrome/browser/prefs/session_startup_pref.h"
32 #include "chrome/browser/profiles/profile_io_data.h" 32 #include "chrome/browser/profiles/profile_io_data.h"
33 #include "chrome/common/chrome_switches.h" 33 #include "chrome/common/chrome_switches.h"
34 #include "chrome/common/pref_names.h" 34 #include "chrome/common/pref_names.h"
35 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_sett ings.h" 35 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_sett ings.h"
36 #include "components/dns_prefetch/common/prefetch_common.h"
36 #include "components/pref_registry/pref_registry_syncable.h" 37 #include "components/pref_registry/pref_registry_syncable.h"
37 #include "content/public/browser/browser_thread.h" 38 #include "content/public/browser/browser_thread.h"
38 #include "net/base/address_list.h" 39 #include "net/base/address_list.h"
39 #include "net/base/completion_callback.h" 40 #include "net/base/completion_callback.h"
40 #include "net/base/host_port_pair.h" 41 #include "net/base/host_port_pair.h"
41 #include "net/base/load_flags.h" 42 #include "net/base/load_flags.h"
42 #include "net/base/net_errors.h" 43 #include "net/base/net_errors.h"
43 #include "net/base/net_log.h" 44 #include "net/base/net_log.h"
44 #include "net/dns/host_resolver.h" 45 #include "net/dns/host_resolver.h"
45 #include "net/dns/single_request_host_resolver.h" 46 #include "net/dns/single_request_host_resolver.h"
(...skipping 683 matching lines...) Expand 10 before | Expand all | Expand 10 after
729 return; 730 return;
730 } 731 }
731 initial_observer_->Append(url, this); 732 initial_observer_->Append(url, this);
732 } 733 }
733 734
734 // This API is only used in the browser process. 735 // This API is only used in the browser process.
735 // It is called from an IPC message originating in the renderer. It currently 736 // It is called from an IPC message originating in the renderer. It currently
736 // includes both Page-Scan, and Link-Hover prefetching. 737 // includes both Page-Scan, and Link-Hover prefetching.
737 // TODO(jar): Separate out link-hover prefetching, and page-scan results. 738 // TODO(jar): Separate out link-hover prefetching, and page-scan results.
738 void Predictor::DnsPrefetchList(const NameList& hostnames) { 739 void Predictor::DnsPrefetchList(const NameList& hostnames) {
740 if (hostnames.size() > dns_prefetch::kMaxDnsHostnamesPerRequest) {
741 LOG(DFATAL) << "Refusing to prefetch too many hostnames: "
jar (doing other things) 2014/10/28 22:49:32 nit: Please use DLOG. No one will look at this...
gunsch 2014/10/29 23:58:29 Covered by removing this and doing validation with
742 << hostnames.size();
743 return;
744 }
745
739 // TODO(jar): Push GURL transport further back into renderer, but this will 746 // TODO(jar): Push GURL transport further back into renderer, but this will
740 // require a Webkit change in the observer :-/. 747 // require a Webkit change in the observer :-/.
741 UrlList urls; 748 UrlList urls;
742 for (NameList::const_iterator it = hostnames.begin(); 749 for (NameList::const_iterator it = hostnames.begin();
743 it < hostnames.end(); 750 it < hostnames.end();
744 ++it) { 751 ++it) {
752 if (it->length() > dns_prefetch::kMaxDnsHostnameLength) {
753 LOG(DFATAL) << "Refusing to prefetch hostname with length: "
jar (doing other things) 2014/10/28 22:49:32 nit: DLOG
gunsch 2014/10/29 23:58:29 ditto
754 << it->length();
755 continue;
756 }
745 urls.push_back(GURL("http://" + *it + ":80")); 757 urls.push_back(GURL("http://" + *it + ":80"));
746 } 758 }
747 759
748 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 760 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
749 DnsPrefetchMotivatedList(urls, UrlInfo::PAGE_SCAN_MOTIVATED); 761 DnsPrefetchMotivatedList(urls, UrlInfo::PAGE_SCAN_MOTIVATED);
750 } 762 }
751 763
752 void Predictor::DnsPrefetchMotivatedList( 764 void Predictor::DnsPrefetchMotivatedList(
753 const UrlList& urls, 765 const UrlList& urls,
754 UrlInfo::ResolutionMotivation motivation) { 766 UrlInfo::ResolutionMotivation motivation) {
(...skipping 587 matching lines...) Expand 10 before | Expand all | Expand 10 after
1342 } 1354 }
1343 1355
1344 void SimplePredictor::ShutdownOnUIThread() { 1356 void SimplePredictor::ShutdownOnUIThread() {
1345 SetShutdown(true); 1357 SetShutdown(true);
1346 } 1358 }
1347 1359
1348 bool SimplePredictor::CanPrefetchAndPrerender() const { return true; } 1360 bool SimplePredictor::CanPrefetchAndPrerender() const { return true; }
1349 bool SimplePredictor::CanPreresolveAndPreconnect() const { return true; } 1361 bool SimplePredictor::CanPreresolveAndPreconnect() const { return true; }
1350 1362
1351 } // namespace chrome_browser_net 1363 } // namespace chrome_browser_net
OLDNEW
« no previous file with comments | « chrome/browser/net/predictor.h ('k') | chrome/browser/net/predictor_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698