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

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

Issue 4974001: base: Get rid of 'using' declaration of StringAppendF. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: review Created 10 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/net/predictor.cc ('k') | chrome/browser/ui/views/select_file_dialog.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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/url_info.h" 5 #include "chrome/browser/net/url_info.h"
6 6
7 #include <math.h> 7 #include <math.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <string> 10 #include <string>
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 // DISALLOW_COPY_AND_ASSIGN(MinMaxAverage); 244 // DISALLOW_COPY_AND_ASSIGN(MinMaxAverage);
245 }; 245 };
246 246
247 static std::string HoursMinutesSeconds(int seconds) { 247 static std::string HoursMinutesSeconds(int seconds) {
248 std::string result; 248 std::string result;
249 int print_seconds = seconds % 60; 249 int print_seconds = seconds % 60;
250 int minutes = seconds / 60; 250 int minutes = seconds / 60;
251 int print_minutes = minutes % 60; 251 int print_minutes = minutes % 60;
252 int print_hours = minutes/60; 252 int print_hours = minutes/60;
253 if (print_hours) 253 if (print_hours)
254 StringAppendF(&result, "%.2d:", print_hours); 254 base::StringAppendF(&result, "%.2d:", print_hours);
255 if (print_hours || print_minutes) 255 if (print_hours || print_minutes)
256 StringAppendF(&result, "%2.2d:", print_minutes); 256 base::StringAppendF(&result, "%2.2d:", print_minutes);
257 StringAppendF(&result, "%2.2d", print_seconds); 257 base::StringAppendF(&result, "%2.2d", print_seconds);
258 return result; 258 return result;
259 } 259 }
260 260
261 // static 261 // static
262 void UrlInfo::GetHtmlTable(const UrlInfoTable host_infos, 262 void UrlInfo::GetHtmlTable(const UrlInfoTable host_infos,
263 const char* description, 263 const char* description,
264 const bool brief, 264 const bool brief,
265 std::string* output) { 265 std::string* output) {
266 if (0 == host_infos.size()) 266 if (0 == host_infos.size())
267 return; 267 return;
268 output->append(description); 268 output->append(description);
269 StringAppendF(output, "%" PRIuS " %s", host_infos.size(), 269 base::StringAppendF(output, "%" PRIuS " %s", host_infos.size(),
270 (1 == host_infos.size()) ? "hostname" : "hostnames"); 270 (1 == host_infos.size()) ? "hostname" : "hostnames");
271 271
272 if (brief) { 272 if (brief) {
273 output->append("<br><br>"); 273 output->append("<br><br>");
274 return; 274 return;
275 } 275 }
276 276
277 output->append("<br><table border=1>" 277 output->append("<br><table border=1>"
278 "<tr><th>Host name</th>" 278 "<tr><th>Host name</th>"
279 "<th>How long ago<br>(HH:MM:SS)</th>" 279 "<th>How long ago<br>(HH:MM:SS)</th>"
280 "<th>Motivation</th>" 280 "<th>Motivation</th>"
281 "</tr>"); 281 "</tr>");
282 282
283 const char* row_format = "<tr align=right><td>%s</td>" // Host name. 283 const char* row_format = "<tr align=right><td>%s</td>" // Host name.
284 "<td>%s</td>" // How long ago. 284 "<td>%s</td>" // How long ago.
285 "<td>%s</td>" // Motivation. 285 "<td>%s</td>" // Motivation.
286 "</tr>"; 286 "</tr>";
287 287
288 // Print bulk of table, and gather stats at same time. 288 // Print bulk of table, and gather stats at same time.
289 MinMaxAverage queue, when; 289 MinMaxAverage queue, when;
290 TimeTicks current_time = TimeTicks::Now(); 290 TimeTicks current_time = TimeTicks::Now();
291 for (UrlInfoTable::const_iterator it(host_infos.begin()); 291 for (UrlInfoTable::const_iterator it(host_infos.begin());
292 it != host_infos.end(); it++) { 292 it != host_infos.end(); it++) {
293 queue.sample((it->queue_duration_.InMilliseconds())); 293 queue.sample((it->queue_duration_.InMilliseconds()));
294 StringAppendF(output, row_format, 294 base::StringAppendF(
295 RemoveJs(it->url_.spec()).c_str(), 295 output,
296 HoursMinutesSeconds(when.sample( 296 row_format,
297 (current_time - it->time_).InSeconds())).c_str(), 297 RemoveJs(it->url_.spec()).c_str(),
298 it->GetAsciiMotivation().c_str()); 298 HoursMinutesSeconds(when.sample(
299 (current_time - it->time_).InSeconds())).c_str(),
300 it->GetAsciiMotivation().c_str());
299 } 301 }
300 output->append("</table>"); 302 output->append("</table>");
301 303
302 #ifndef NDEBUG 304 #ifndef NDEBUG
303 StringAppendF(output, 305 base::StringAppendF(
304 "Prefetch Queue Durations: min=%d, avg=%d, max=%d<br><br>", 306 output,
305 queue.minimum(), queue.average(), queue.maximum()); 307 "Prefetch Queue Durations: min=%d, avg=%d, max=%d<br><br>",
308 queue.minimum(), queue.average(), queue.maximum());
306 #endif 309 #endif
307 310
308 output->append("<br>"); 311 output->append("<br>");
309 } 312 }
310 313
311 void UrlInfo::SetMotivation(ResolutionMotivation motivation) { 314 void UrlInfo::SetMotivation(ResolutionMotivation motivation) {
312 motivation_ = motivation; 315 motivation_ = motivation;
313 if (motivation < LINKED_MAX_MOTIVATED) 316 if (motivation < LINKED_MAX_MOTIVATED)
314 was_linked_ = true; 317 was_linked_ = true;
315 } 318 }
(...skipping 20 matching lines...) Expand all
336 339
337 case LEARNED_REFERAL_MOTIVATED: 340 case LEARNED_REFERAL_MOTIVATED:
338 return RemoveJs(referring_url_.spec()); 341 return RemoveJs(referring_url_.spec());
339 342
340 default: 343 default:
341 return ""; 344 return "";
342 } 345 }
343 } 346 }
344 347
345 } // namespace chrome_browser_net 348 } // namespace chrome_browser_net
OLDNEW
« no previous file with comments | « chrome/browser/net/predictor.cc ('k') | chrome/browser/ui/views/select_file_dialog.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698