| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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/referrer.h" | 5 #include "chrome/browser/net/referrer.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 | 8 |
| 9 namespace chrome_browser_net { | 9 namespace chrome_browser_net { |
| 10 | 10 |
| 11 void Referrer::SuggestHost(const std::string& host) { | 11 void Referrer::SuggestHost(const std::string& host) { |
| 12 // Limit how large our list can get, in case we start make mistakes about |
| 13 // what hostnames are in sub-resources (example: Some advertisments have |
| 14 // a link to the ad agency, and then provide a "surprising" redirect to |
| 15 // the advertised entity, which appears to be a subresource on the page |
| 16 // hosting the ad). |
| 17 static const size_t kMaxSuggestions = 8; |
| 18 |
| 12 if (host.empty()) | 19 if (host.empty()) |
| 13 return; | 20 return; |
| 14 if (kMaxSuggestions <= size()) { | 21 if (kMaxSuggestions <= size()) { |
| 15 DeleteLeastUseful(); | 22 DeleteLeastUseful(); |
| 16 DCHECK(kMaxSuggestions > size()); | 23 DCHECK(kMaxSuggestions > size()); |
| 17 } | 24 } |
| 18 // Add in the new suggestion. | 25 // Add in the new suggestion. |
| 19 (*this)[host]; | 26 (*this)[host]; |
| 20 } | 27 } |
| 21 | 28 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 52 erase(least_useful_name); | 59 erase(least_useful_name); |
| 53 } | 60 } |
| 54 | 61 |
| 55 void Referrer::AccrueValue(const base::TimeDelta& delta, | 62 void Referrer::AccrueValue(const base::TimeDelta& delta, |
| 56 const std::string host) { | 63 const std::string host) { |
| 57 DCHECK(this->find(host) != this->end()); | 64 DCHECK(this->find(host) != this->end()); |
| 58 (*this)[host].AccrueValue(delta); | 65 (*this)[host].AccrueValue(delta); |
| 59 } | 66 } |
| 60 | 67 |
| 61 } // namespace chrome_browser_net | 68 } // namespace chrome_browser_net |
| OLD | NEW |