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

Side by Side Diff: components/domain_reliability/util.cc

Issue 2613223002: Remove ScopedVector from base::JSONValueConverter (Closed)
Patch Set: Rebase and address comments from mmenke@ Created 3 years, 11 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "components/domain_reliability/util.h" 5 #include "components/domain_reliability/util.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/callback.h" 9 #include "base/callback.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 !retry_after.is_zero()) { 163 !retry_after.is_zero()) {
164 result->status = DomainReliabilityUploader::UploadResult::RETRY_AFTER; 164 result->status = DomainReliabilityUploader::UploadResult::RETRY_AFTER;
165 result->retry_after = retry_after; 165 result->retry_after = retry_after;
166 return; 166 return;
167 } 167 }
168 168
169 result->status = DomainReliabilityUploader::UploadResult::FAILURE; 169 result->status = DomainReliabilityUploader::UploadResult::FAILURE;
170 return; 170 return;
171 } 171 }
172 172
173 // N.B. This uses a ScopedVector because that's what JSONValueConverter uses 173 // N.B. This uses a std::vector<std::unique_ptr<>> because that's what
174 // for repeated fields of any type, and Config uses JSONValueConverter to parse 174 // JSONValueConverter uses for repeated fields of any type, and Config uses
175 // JSON configs. 175 // JSONValueConverter to parse JSON configs.
176 GURL SanitizeURLForReport(const GURL& beacon_url, 176 GURL SanitizeURLForReport(
177 const GURL& collector_url, 177 const GURL& beacon_url,
178 const ScopedVector<std::string>& path_prefixes) { 178 const GURL& collector_url,
179 const std::vector<std::unique_ptr<std::string>>& path_prefixes) {
179 if (CanReportFullBeaconURLToCollector(beacon_url, collector_url)) 180 if (CanReportFullBeaconURLToCollector(beacon_url, collector_url))
180 return beacon_url.GetAsReferrer(); 181 return beacon_url.GetAsReferrer();
181 182
182 std::string path = beacon_url.path(); 183 std::string path = beacon_url.path();
183 const std::string empty_path; 184 const std::string empty_path;
184 const std::string* longest_path_prefix = &empty_path; 185 const std::string* longest_path_prefix = &empty_path;
185 for (const std::string* path_prefix : path_prefixes) { 186 for (const auto& path_prefix : path_prefixes) {
186 if (path.substr(0, path_prefix->length()) == *path_prefix && 187 if (path.substr(0, path_prefix->length()) == *path_prefix &&
187 path_prefix->length() > longest_path_prefix->length()) { 188 path_prefix->length() > longest_path_prefix->length()) {
188 longest_path_prefix = path_prefix; 189 longest_path_prefix = path_prefix.get();
189 } 190 }
190 } 191 }
191 192
192 GURL::Replacements replacements; 193 GURL::Replacements replacements;
193 replacements.ClearUsername(); 194 replacements.ClearUsername();
194 replacements.ClearPassword(); 195 replacements.ClearPassword();
195 replacements.SetPathStr(*longest_path_prefix); 196 replacements.SetPathStr(*longest_path_prefix);
196 replacements.ClearQuery(); 197 replacements.ClearQuery();
197 replacements.ClearRef(); 198 replacements.ClearRef();
198 return beacon_url.ReplaceComponents(replacements); 199 return beacon_url.ReplaceComponents(replacements);
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 ActualTime::~ActualTime() {} 235 ActualTime::~ActualTime() {}
235 236
236 base::Time ActualTime::Now() { return base::Time::Now(); } 237 base::Time ActualTime::Now() { return base::Time::Now(); }
237 base::TimeTicks ActualTime::NowTicks() { return base::TimeTicks::Now(); } 238 base::TimeTicks ActualTime::NowTicks() { return base::TimeTicks::Now(); }
238 239
239 std::unique_ptr<MockableTime::Timer> ActualTime::CreateTimer() { 240 std::unique_ptr<MockableTime::Timer> ActualTime::CreateTimer() {
240 return std::unique_ptr<MockableTime::Timer>(new ActualTimer()); 241 return std::unique_ptr<MockableTime::Timer>(new ActualTimer());
241 } 242 }
242 243
243 } // namespace domain_reliability 244 } // namespace domain_reliability
OLDNEW
« no previous file with comments | « components/domain_reliability/util.h ('k') | components/drive/chromeos/change_list_processor.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698