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

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

Issue 2014103002: Remove deprecated ListValue::Append(Value*) overload on Linux. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: ADL fail Created 4 years, 3 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 #include <stddef.h>
9 9
10 #include <memory> 10 #include <memory>
11 #include <utility> 11 #include <utility>
12 12
13 #include "base/compiler_specific.h" 13 #include "base/compiler_specific.h"
14 #include "base/logging.h" 14 #include "base/logging.h"
15 #include "base/memory/ptr_util.h"
15 #include "base/message_loop/message_loop.h" 16 #include "base/message_loop/message_loop.h"
16 #include "base/values.h" 17 #include "base/values.h"
17 #include "chrome/browser/net/predictor.h" 18 #include "chrome/browser/net/predictor.h"
18 19
19 namespace chrome_browser_net { 20 namespace chrome_browser_net {
20 21
21 //------------------------------------------------------------------------------ 22 //------------------------------------------------------------------------------
22 // Smoothing parameter for updating subresource_use_rate_. 23 // Smoothing parameter for updating subresource_use_rate_.
23 24
24 // We always combine our old expected value, weighted by some factor W (we use 25 // We always combine our old expected value, weighted by some factor W (we use
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 // TODO(jar): We could be more direct, and change birth date or similar to 126 // TODO(jar): We could be more direct, and change birth date or similar to
126 // show that this is a resurrected value we're adding in. I'm not yet sure 127 // show that this is a resurrected value we're adding in. I'm not yet sure
127 // of how best to optimize the learning and pruning (Trim) algorithm at this 128 // of how best to optimize the learning and pruning (Trim) algorithm at this
128 // level, so for now, we just suggest subresources, which leaves them all 129 // level, so for now, we just suggest subresources, which leaves them all
129 // with the same birth date (typically start of process). 130 // with the same birth date (typically start of process).
130 SuggestHost(url); 131 SuggestHost(url);
131 (*this)[url].SetSubresourceUseRate(rate); 132 (*this)[url].SetSubresourceUseRate(rate);
132 } 133 }
133 } 134 }
134 135
135 base::Value* Referrer::Serialize() const { 136 std::unique_ptr<base::ListValue> Referrer::Serialize() const {
136 base::ListValue* subresource_list(new base::ListValue); 137 auto subresource_list = base::MakeUnique<base::ListValue>();
137 for (const_iterator it = begin(); it != end(); ++it) { 138 for (const_iterator it = begin(); it != end(); ++it) {
138 std::unique_ptr<base::StringValue> url_spec( 139 subresource_list->AppendString(it->first.spec());
139 new base::StringValue(it->first.spec())); 140 subresource_list->AppendDouble(it->second.subresource_use_rate());
140 std::unique_ptr<base::FundamentalValue> rate(
141 new base::FundamentalValue(it->second.subresource_use_rate()));
142
143 subresource_list->Append(std::move(url_spec));
144 subresource_list->Append(std::move(rate));
145 } 141 }
146 return subresource_list; 142 return subresource_list;
147 } 143 }
148 144
149 //------------------------------------------------------------------------------ 145 //------------------------------------------------------------------------------
150 146
151 ReferrerValue::ReferrerValue() 147 ReferrerValue::ReferrerValue()
152 : birth_time_(base::Time::Now()), 148 : birth_time_(base::Time::Now()),
153 navigation_count_(0), 149 navigation_count_(0),
154 preconnection_count_(0), 150 preconnection_count_(0),
(...skipping 10 matching lines...) Expand all
165 161
166 void ReferrerValue::ReferrerWasObserved() { 162 void ReferrerValue::ReferrerWasObserved() {
167 subresource_use_rate_ *= kWeightingForOldConnectsExpectedValue; 163 subresource_use_rate_ *= kWeightingForOldConnectsExpectedValue;
168 // 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
169 // 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
170 // milliseconds (when content arrives, etc.). 166 // milliseconds (when content arrives, etc.).
171 // Value of subresource_use_rate_ should be sampled before this call. 167 // Value of subresource_use_rate_ should be sampled before this call.
172 } 168 }
173 169
174 } // namespace chrome_browser_net 170 } // namespace chrome_browser_net
OLDNEW
« no previous file with comments | « chrome/browser/net/referrer.h ('k') | chrome/browser/signin/mutable_profile_oauth2_token_service_delegate_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698