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

Side by Side Diff: components/network_hints/renderer/renderer_dns_prefetch.cc

Issue 1004223003: Revert "DNS Prefetch fix: renderer shouldn't send long hostnames to browser." (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2311
Patch Set: Created 5 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
« no previous file with comments | « chrome/test/data/predictor/dns_prefetch.html ('k') | no next file » | 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 // See header file for description of RendererDnsPrefetch class 5 // See header file for description of RendererDnsPrefetch class
6 6
7 #include "components/network_hints/renderer/renderer_dns_prefetch.h" 7 #include "components/network_hints/renderer/renderer_dns_prefetch.h"
8 8
9 #include <ctype.h> 9 #include <ctype.h>
10 10
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 --count; 123 --count;
124 } else { 124 } else {
125 DCHECK(kPending == it->second || kLookupRequested == it->second); 125 DCHECK(kPending == it->second || kLookupRequested == it->second);
126 } 126 }
127 } 127 }
128 } 128 }
129 129
130 void RendererDnsPrefetch::DnsPrefetchNames(size_t max_count) { 130 void RendererDnsPrefetch::DnsPrefetchNames(size_t max_count) {
131 // We are on the renderer thread, and just need to send things to the browser. 131 // We are on the renderer thread, and just need to send things to the browser.
132 NameList names; 132 NameList names;
133 size_t domains_handled = 0;
134 for (DomainUseMap::iterator it = domain_map_.begin(); 133 for (DomainUseMap::iterator it = domain_map_.begin();
135 it != domain_map_.end(); 134 it != domain_map_.end();
136 ++it) { 135 ++it) {
137 if (0 == (it->second & kLookupRequested)) { 136 if (0 == (it->second & kLookupRequested)) {
138 it->second |= kLookupRequested; 137 it->second |= kLookupRequested;
139 domains_handled++; 138 names.push_back(it->first);
140 if (it->first.length() <= network_hints::kMaxDnsHostnameLength)
141 names.push_back(it->first);
142 if (0 == max_count) continue; // Get all, independent of count. 139 if (0 == max_count) continue; // Get all, independent of count.
143 if (1 == max_count) break; 140 if (1 == max_count) break;
144 --max_count; 141 --max_count;
145 DCHECK_GE(max_count, 1u); 142 DCHECK_GE(max_count, 1u);
146 } 143 }
147 } 144 }
148 DCHECK_GE(new_name_count_, domains_handled); 145 DCHECK_GE(new_name_count_, names.size());
149 new_name_count_ -= domains_handled; 146 new_name_count_ -= names.size();
150 147
151 network_hints::LookupRequest request; 148 network_hints::LookupRequest request;
152 request.hostname_list = names; 149 request.hostname_list = names;
153 RenderThread::Get()->Send(new NetworkHintsMsg_DNSPrefetch(request)); 150 RenderThread::Get()->Send(new NetworkHintsMsg_DNSPrefetch(request));
154 } 151 }
155 152
156 // is_numeric_ip() checks to see if all characters in name are either numeric, 153 // is_numeric_ip() checks to see if all characters in name are either numeric,
157 // or dots. Such a name will not actually be passed to DNS, as it is an IP 154 // or dots. Such a name will not actually be passed to DNS, as it is an IP
158 // address. 155 // address.
159 bool RendererDnsPrefetch::is_numeric_ip(const char* name, size_t length) { 156 bool RendererDnsPrefetch::is_numeric_ip(const char* name, size_t length) {
160 // Scan for a character outside our lookup list. 157 // Scan for a character outside our lookup list.
161 while (length-- > 0) { 158 while (length-- > 0) {
162 if (!isdigit(*name) && '.' != *name) 159 if (!isdigit(*name) && '.' != *name)
163 return false; 160 return false;
164 ++name; 161 ++name;
165 } 162 }
166 return true; 163 return true;
167 } 164 }
168 165
169 } // namespace predictor 166 } // namespace predictor
OLDNEW
« no previous file with comments | « chrome/test/data/predictor/dns_prefetch.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698