OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 <limits.h> | 7 #include <limits.h> |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 | 9 |
10 #include <memory> | 10 #include <memory> |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 } | 102 } |
103 least_useful_url = it->first; | 103 least_useful_url = it->first; |
104 lowest_rate_seen = rate; | 104 lowest_rate_seen = rate; |
105 least_useful_lifetime = lifetime; | 105 least_useful_lifetime = lifetime; |
106 } | 106 } |
107 if (least_useful_url.has_host()) | 107 if (least_useful_url.has_host()) |
108 erase(least_useful_url); | 108 erase(least_useful_url); |
109 } | 109 } |
110 | 110 |
111 void Referrer::Deserialize(const base::Value& value) { | 111 void Referrer::Deserialize(const base::Value& value) { |
112 if (value.GetType() != base::Value::TYPE_LIST) | 112 if (value.GetType() != base::Value::Type::LIST) |
113 return; | 113 return; |
114 const base::ListValue* subresource_list( | 114 const base::ListValue* subresource_list( |
115 static_cast<const base::ListValue*>(&value)); | 115 static_cast<const base::ListValue*>(&value)); |
116 size_t index = 0; // Bounds checking is done by subresource_list->Get*(). | 116 size_t index = 0; // Bounds checking is done by subresource_list->Get*(). |
117 while (true) { | 117 while (true) { |
118 std::string url_spec; | 118 std::string url_spec; |
119 if (!subresource_list->GetString(index++, &url_spec)) | 119 if (!subresource_list->GetString(index++, &url_spec)) |
120 return; | 120 return; |
121 double rate; | 121 double rate; |
122 if (!subresource_list->GetDouble(index++, &rate)) | 122 if (!subresource_list->GetDouble(index++, &rate)) |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 | 161 |
162 void ReferrerValue::ReferrerWasObserved() { | 162 void ReferrerValue::ReferrerWasObserved() { |
163 subresource_use_rate_ *= kWeightingForOldConnectsExpectedValue; | 163 subresource_use_rate_ *= kWeightingForOldConnectsExpectedValue; |
164 // Note: the use rate is temporarilly possibly incorect, as we need to find | 164 // Note: the use rate is temporarilly possibly incorect, as we need to find |
165 // out if we really end up connecting. This will happen in a few hundred | 165 // out if we really end up connecting. This will happen in a few hundred |
166 // milliseconds (when content arrives, etc.). | 166 // milliseconds (when content arrives, etc.). |
167 // Value of subresource_use_rate_ should be sampled before this call. | 167 // Value of subresource_use_rate_ should be sampled before this call. |
168 } | 168 } |
169 | 169 |
170 } // namespace chrome_browser_net | 170 } // namespace chrome_browser_net |
OLD | NEW |