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

Side by Side Diff: chrome/browser/net/referrer.cc

Issue 1550593002: Switch to standard integer types in chrome/browser/, part 2 of 4. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 12 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
OLDNEW
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 9
9 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
10 #include "base/logging.h" 11 #include "base/logging.h"
11 #include "base/message_loop/message_loop.h" 12 #include "base/message_loop/message_loop.h"
12 #include "base/values.h" 13 #include "base/values.h"
13 #include "chrome/browser/net/predictor.h" 14 #include "chrome/browser/net/predictor.h"
14 15
15 namespace chrome_browser_net { 16 namespace chrome_browser_net {
16 17
17 //------------------------------------------------------------------------------ 18 //------------------------------------------------------------------------------
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 } 77 }
77 (*this)[url].SubresourceIsNeeded(); 78 (*this)[url].SubresourceIsNeeded();
78 } 79 }
79 80
80 void Referrer::DeleteLeastUseful() { 81 void Referrer::DeleteLeastUseful() {
81 // Find the item with the lowest value. Most important is preconnection_rate, 82 // Find the item with the lowest value. Most important is preconnection_rate,
82 // and least is lifetime (age). 83 // and least is lifetime (age).
83 GURL least_useful_url; 84 GURL least_useful_url;
84 double lowest_rate_seen = 0.0; 85 double lowest_rate_seen = 0.0;
85 // We use longs for durations because we will use multiplication on them. 86 // We use longs for durations because we will use multiplication on them.
86 int64 least_useful_lifetime = 0; // Duration in milliseconds. 87 int64_t least_useful_lifetime = 0; // Duration in milliseconds.
87 88
88 const base::Time kNow(base::Time::Now()); // Avoid multiple calls. 89 const base::Time kNow(base::Time::Now()); // Avoid multiple calls.
89 for (SubresourceMap::iterator it = begin(); it != end(); ++it) { 90 for (SubresourceMap::iterator it = begin(); it != end(); ++it) {
90 int64 lifetime = (kNow - it->second.birth_time()).InMilliseconds(); 91 int64_t lifetime = (kNow - it->second.birth_time()).InMilliseconds();
91 double rate = it->second.subresource_use_rate(); 92 double rate = it->second.subresource_use_rate();
92 if (least_useful_url.has_host()) { 93 if (least_useful_url.has_host()) {
93 if (rate > lowest_rate_seen) 94 if (rate > lowest_rate_seen)
94 continue; 95 continue;
95 if (lifetime <= least_useful_lifetime) 96 if (lifetime <= least_useful_lifetime)
96 continue; 97 continue;
97 } 98 }
98 least_useful_url = it->first; 99 least_useful_url = it->first;
99 lowest_rate_seen = rate; 100 lowest_rate_seen = rate;
100 least_useful_lifetime = lifetime; 101 least_useful_lifetime = lifetime;
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 178
178 void ReferrerValue::ReferrerWasObserved() { 179 void ReferrerValue::ReferrerWasObserved() {
179 subresource_use_rate_ *= kWeightingForOldConnectsExpectedValue; 180 subresource_use_rate_ *= kWeightingForOldConnectsExpectedValue;
180 // Note: the use rate is temporarilly possibly incorect, as we need to find 181 // Note: the use rate is temporarilly possibly incorect, as we need to find
181 // out if we really end up connecting. This will happen in a few hundred 182 // out if we really end up connecting. This will happen in a few hundred
182 // milliseconds (when content arrives, etc.). 183 // milliseconds (when content arrives, etc.).
183 // Value of subresource_use_rate_ should be sampled before this call. 184 // Value of subresource_use_rate_ should be sampled before this call.
184 } 185 }
185 186
186 } // namespace chrome_browser_net 187 } // namespace chrome_browser_net
OLDNEW
« no previous file with comments | « chrome/browser/net/referrer.h ('k') | chrome/browser/net/request_source_bandwidth_histograms.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698