OLD | NEW |
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 |
11 #include "base/bind.h" | 11 #include "base/bind.h" |
| 12 #include "base/location.h" |
12 #include "base/logging.h" | 13 #include "base/logging.h" |
13 #include "base/message_loop/message_loop.h" | 14 #include "base/message_loop/message_loop.h" |
14 #include "components/network_hints/common/network_hints_common.h" | 15 #include "components/network_hints/common/network_hints_common.h" |
15 #include "components/network_hints/common/network_hints_messages.h" | 16 #include "components/network_hints/common/network_hints_messages.h" |
16 #include "components/network_hints/renderer/dns_prefetch_queue.h" | 17 #include "components/network_hints/renderer/dns_prefetch_queue.h" |
17 #include "content/public/renderer/render_thread.h" | 18 #include "content/public/renderer/render_thread.h" |
18 | 19 |
19 using content::RenderThread; | 20 using content::RenderThread; |
20 | 21 |
21 namespace network_hints { | 22 namespace network_hints { |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
139 if (1 == max_count) break; | 140 if (1 == max_count) break; |
140 --max_count; | 141 --max_count; |
141 DCHECK_GE(max_count, 1u); | 142 DCHECK_GE(max_count, 1u); |
142 } | 143 } |
143 } | 144 } |
144 DCHECK_GE(new_name_count_, names.size()); | 145 DCHECK_GE(new_name_count_, names.size()); |
145 new_name_count_ -= names.size(); | 146 new_name_count_ -= names.size(); |
146 | 147 |
147 network_hints::LookupRequest request; | 148 network_hints::LookupRequest request; |
148 request.hostname_list = names; | 149 request.hostname_list = names; |
149 RenderThread::Get()->Send(new DnsPrefetchMsg_RequestPrefetch(request)); | 150 RenderThread::Get()->Send(new NetworkHintsMsg_DNSPrefetch(request)); |
150 } | 151 } |
151 | 152 |
152 // 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, |
153 // 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 |
154 // address. | 155 // address. |
155 bool RendererDnsPrefetch::is_numeric_ip(const char* name, size_t length) { | 156 bool RendererDnsPrefetch::is_numeric_ip(const char* name, size_t length) { |
156 // Scan for a character outside our lookup list. | 157 // Scan for a character outside our lookup list. |
157 while (length-- > 0) { | 158 while (length-- > 0) { |
158 if (!isdigit(*name) && '.' != *name) | 159 if (!isdigit(*name) && '.' != *name) |
159 return false; | 160 return false; |
160 ++name; | 161 ++name; |
161 } | 162 } |
162 return true; | 163 return true; |
163 } | 164 } |
164 | 165 |
165 } // namespcae predictor | 166 } // namespace predictor |
OLD | NEW |