Chromium Code Reviews| 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 RendererNetPredictor class | 5 // See header file for description of RendererNetPredictor class |
| 6 | 6 |
| 7 #include "chrome/renderer/net/renderer_net_predictor.h" | 7 #include "components/predictor/renderer/renderer_net_predictor.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/logging.h" | 12 #include "base/logging.h" |
| 13 #include "base/message_loop/message_loop.h" | 13 #include "base/message_loop/message_loop.h" |
| 14 #include "chrome/common/net/predictor_common.h" | 14 #include "components/predictor/common/predictor_common.h" |
| 15 #include "chrome/common/render_messages.h" | 15 #include "components/predictor/common/predictor_messages.h" |
| 16 #include "chrome/renderer/net/predictor_queue.h" | 16 #include "components/predictor/renderer/predictor_queue.h" |
| 17 #include "content/public/renderer/render_thread.h" | 17 #include "content/public/renderer/render_thread.h" |
| 18 | 18 |
| 19 using content::RenderThread; | 19 using content::RenderThread; |
| 20 | 20 |
| 21 // The number of hostnames submitted to Browser DNS resolver per call to | 21 // The number of hostnames submitted to Browser DNS resolver per call to |
| 22 // SubmitHostsnames() (which reads names from our queue). | 22 // SubmitHostsnames() (which reads names from our queue). |
| 23 static const size_t kMAX_SUBMISSION_PER_TASK = 30; | 23 static const size_t kMAX_SUBMISSION_PER_TASK = 30; |
| 24 | 24 |
| 25 RendererNetPredictor::RendererNetPredictor() | 25 RendererNetPredictor::RendererNetPredictor() |
| 26 : c_string_queue_(1000), | 26 : c_string_queue_(1000), |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 123 DCHECK_GT(count, 1u); | 123 DCHECK_GT(count, 1u); |
| 124 --count; | 124 --count; |
| 125 } else { | 125 } else { |
| 126 DCHECK(kPending == it->second || kLookupRequested == it->second); | 126 DCHECK(kPending == it->second || kLookupRequested == it->second); |
| 127 } | 127 } |
| 128 } | 128 } |
| 129 } | 129 } |
| 130 | 130 |
| 131 void RendererNetPredictor::DnsPrefetchNames(size_t max_count) { | 131 void RendererNetPredictor::DnsPrefetchNames(size_t max_count) { |
| 132 // We are on the renderer thread, and just need to send things to the browser. | 132 // We are on the renderer thread, and just need to send things to the browser. |
| 133 chrome_common_net::NameList names; | 133 predictor::NameList names; |
|
blundell
2014/10/15 09:15:33
everything in this component should be in the pred
gunsch
2014/10/28 19:55:31
Done.
| |
| 134 for (DomainUseMap::iterator it = domain_map_.begin(); | 134 for (DomainUseMap::iterator it = domain_map_.begin(); |
| 135 it != domain_map_.end(); | 135 it != domain_map_.end(); |
| 136 ++it) { | 136 ++it) { |
| 137 if (0 == (it->second & kLookupRequested)) { | 137 if (0 == (it->second & kLookupRequested)) { |
| 138 it->second |= kLookupRequested; | 138 it->second |= kLookupRequested; |
| 139 names.push_back(it->first); | 139 names.push_back(it->first); |
| 140 if (0 == max_count) continue; // Get all, independent of count. | 140 if (0 == max_count) continue; // Get all, independent of count. |
| 141 if (1 == max_count) break; | 141 if (1 == max_count) break; |
| 142 --max_count; | 142 --max_count; |
| 143 DCHECK_GE(max_count, 1u); | 143 DCHECK_GE(max_count, 1u); |
| 144 } | 144 } |
| 145 } | 145 } |
| 146 DCHECK_GE(new_name_count_, names.size()); | 146 DCHECK_GE(new_name_count_, names.size()); |
| 147 new_name_count_ -= names.size(); | 147 new_name_count_ -= names.size(); |
| 148 | 148 |
| 149 RenderThread::Get()->Send(new ChromeViewHostMsg_DnsPrefetch(names)); | 149 RenderThread::Get()->Send(new DnsPredictorMsg_RequestPrefetch(names)); |
| 150 } | 150 } |
| 151 | 151 |
| 152 // is_numeric_ip() checks to see if all characters in name are either numeric, | 152 // 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 | 153 // or dots. Such a name will not actually be passed to DNS, as it is an IP |
| 154 // address. | 154 // address. |
| 155 bool RendererNetPredictor::is_numeric_ip(const char* name, size_t length) { | 155 bool RendererNetPredictor::is_numeric_ip(const char* name, size_t length) { |
| 156 // Scan for a character outside our lookup list. | 156 // Scan for a character outside our lookup list. |
| 157 while (length-- > 0) { | 157 while (length-- > 0) { |
| 158 if (!isdigit(*name) && '.' != *name) | 158 if (!isdigit(*name) && '.' != *name) |
| 159 return false; | 159 return false; |
| 160 ++name; | 160 ++name; |
| 161 } | 161 } |
| 162 return true; | 162 return true; |
| 163 } | 163 } |
| OLD | NEW |