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

Unified Diff: content/shell/renderer/test_runner/web_test_proxy.cc

Issue 408163002: Cleanup: use base::StringPrintf instead of snprintf in WebTestProxy. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 6 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/shell/renderer/test_runner/web_test_proxy.cc
diff --git a/content/shell/renderer/test_runner/web_test_proxy.cc b/content/shell/renderer/test_runner/web_test_proxy.cc
index 6a50df30ca437fdfaacefe2adc9b1221e02bb1a1..989502b0100b59505e44d91b009e805486c0e7c3 100644
--- a/content/shell/renderer/test_runner/web_test_proxy.cc
+++ b/content/shell/renderer/test_runner/web_test_proxy.cc
@@ -9,6 +9,7 @@
#include "base/callback_helpers.h"
#include "base/debug/trace_event.h"
#include "base/logging.h"
+#include "base/strings/stringprintf.h"
#include "content/shell/renderer/test_runner/MockWebSpeechRecognizer.h"
#include "content/shell/renderer/test_runner/SpellCheckClient.h"
#include "content/shell/renderer/test_runner/TestCommon.h"
@@ -114,12 +115,10 @@ void PrintResponseDescription(WebTestDelegate* delegate,
delegate->printMessage("(null)");
return;
}
- std::string url = response.url().spec();
- char data[100];
- snprintf(data, sizeof(data), "%d", response.httpStatusCode());
- delegate->printMessage(std::string("<NSURLResponse ") +
- DescriptionSuitableForTestResult(url) +
- ", http status code " + data + ">");
+ delegate->printMessage(base::StringPrintf(
+ "<NSURLResponse %s, http status code %d>",
+ DescriptionSuitableForTestResult(response.url().spec()).c_str(),
+ response.httpStatusCode()));
}
std::string URLDescription(const GURL& url) {
@@ -286,10 +285,8 @@ std::string DumpFrameScrollPosition(blink::WebFrame* frame, bool recursive) {
result =
std::string("frame '") + frame->uniqueName().utf8().data() + "' ";
}
- char data[100];
- snprintf(
- data, sizeof(data), "scrolled to %d,%d\n", offset.width, offset.height);
- result += data;
+ base::StringAppendF(
+ &result, "scrolled to %d,%d\n", offset.width, offset.height);
}
if (!recursive)
@@ -964,12 +961,8 @@ void WebTestProxyBase::DidFinishDocumentLoad(blink::WebLocalFrame* frame) {
unsigned pendingUnloadEvents = frame->unloadListenerCount();
if (pendingUnloadEvents) {
PrintFrameDescription(delegate_, frame);
- char buffer[100];
- snprintf(buffer,
- sizeof(buffer),
- " - has %u onunload handler(s)\n",
- pendingUnloadEvents);
- delegate_->printMessage(buffer);
+ delegate_->printMessage(base::StringPrintf(
+ " - has %u onunload handler(s)\n", pendingUnloadEvents));
}
}
}
@@ -1136,13 +1129,10 @@ void WebTestProxyBase::DidChangeResourcePriority(
delegate_->printMessage("<unknown>");
else
delegate_->printMessage(resource_identifier_map_[identifier]);
- delegate_->printMessage(" changed priority to ");
- delegate_->printMessage(PriorityDescription(priority));
- char buffer[64];
- snprintf(
- buffer, sizeof(buffer), ", intra_priority %d", intra_priority_value);
- delegate_->printMessage(buffer);
- delegate_->printMessage("\n");
+ delegate_->printMessage(
+ base::StringPrintf(" changed priority to %s, intra_priority %d\n",
+ PriorityDescription(priority).c_str(),
+ intra_priority_value));
}
}
@@ -1186,9 +1176,7 @@ void WebTestProxyBase::DidAddMessageToConsole(
}
delegate_->printMessage(std::string("CONSOLE ") + level + ": ");
if (source_line) {
- char buffer[40];
- snprintf(buffer, sizeof(buffer), "line %d: ", source_line);
- delegate_->printMessage(buffer);
+ delegate_->printMessage(base::StringPrintf("line %d: ", source_line));
}
if (!message.text.isEmpty()) {
std::string new_message;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698