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

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

Issue 2058233002: Rewrite simple uses of base::ListValue::Append() taking a raw pointer var. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: less comments more ownership Created 4 years, 6 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
« no previous file with comments | « chrome/browser/net/predictor.cc ('k') | chrome/browser/plugins/plugin_prefs.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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>
11 #include <utility>
12
10 #include "base/compiler_specific.h" 13 #include "base/compiler_specific.h"
11 #include "base/logging.h" 14 #include "base/logging.h"
12 #include "base/message_loop/message_loop.h" 15 #include "base/message_loop/message_loop.h"
13 #include "base/values.h" 16 #include "base/values.h"
14 #include "chrome/browser/net/predictor.h" 17 #include "chrome/browser/net/predictor.h"
15 18
16 namespace chrome_browser_net { 19 namespace chrome_browser_net {
17 20
18 //------------------------------------------------------------------------------ 21 //------------------------------------------------------------------------------
19 // Smoothing parameter for updating subresource_use_rate_. 22 // Smoothing parameter for updating subresource_use_rate_.
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 // level, so for now, we just suggest subresources, which leaves them all 145 // level, so for now, we just suggest subresources, which leaves them all
143 // with the same birth date (typically start of process). 146 // with the same birth date (typically start of process).
144 SuggestHost(url); 147 SuggestHost(url);
145 (*this)[url].SetSubresourceUseRate(rate); 148 (*this)[url].SetSubresourceUseRate(rate);
146 } 149 }
147 } 150 }
148 151
149 base::Value* Referrer::Serialize() const { 152 base::Value* Referrer::Serialize() const {
150 base::ListValue* subresource_list(new base::ListValue); 153 base::ListValue* subresource_list(new base::ListValue);
151 for (const_iterator it = begin(); it != end(); ++it) { 154 for (const_iterator it = begin(); it != end(); ++it) {
152 base::StringValue* url_spec(new base::StringValue(it->first.spec())); 155 std::unique_ptr<base::StringValue> url_spec(
153 base::FundamentalValue* rate(new base::FundamentalValue( 156 new base::StringValue(it->first.spec()));
154 it->second.subresource_use_rate())); 157 std::unique_ptr<base::FundamentalValue> rate(
158 new base::FundamentalValue(it->second.subresource_use_rate()));
155 159
156 subresource_list->Append(url_spec); 160 subresource_list->Append(std::move(url_spec));
157 subresource_list->Append(rate); 161 subresource_list->Append(std::move(rate));
158 } 162 }
159 return subresource_list; 163 return subresource_list;
160 } 164 }
161 165
162 //------------------------------------------------------------------------------ 166 //------------------------------------------------------------------------------
163 167
164 ReferrerValue::ReferrerValue() 168 ReferrerValue::ReferrerValue()
165 : birth_time_(base::Time::Now()), 169 : birth_time_(base::Time::Now()),
166 navigation_count_(0), 170 navigation_count_(0),
167 preconnection_count_(0), 171 preconnection_count_(0),
(...skipping 10 matching lines...) Expand all
178 182
179 void ReferrerValue::ReferrerWasObserved() { 183 void ReferrerValue::ReferrerWasObserved() {
180 subresource_use_rate_ *= kWeightingForOldConnectsExpectedValue; 184 subresource_use_rate_ *= kWeightingForOldConnectsExpectedValue;
181 // Note: the use rate is temporarilly possibly incorect, as we need to find 185 // Note: the use rate is temporarilly possibly incorect, as we need to find
182 // out if we really end up connecting. This will happen in a few hundred 186 // out if we really end up connecting. This will happen in a few hundred
183 // milliseconds (when content arrives, etc.). 187 // milliseconds (when content arrives, etc.).
184 // Value of subresource_use_rate_ should be sampled before this call. 188 // Value of subresource_use_rate_ should be sampled before this call.
185 } 189 }
186 190
187 } // namespace chrome_browser_net 191 } // namespace chrome_browser_net
OLDNEW
« no previous file with comments | « chrome/browser/net/predictor.cc ('k') | chrome/browser/plugins/plugin_prefs.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698