Cleanup: use base::StringPrintf instead of snprintf in WebTestProxy.
BUG=none
Review URL: https://codereview.chromium.org/408163002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@284810 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/content/shell/renderer/test_runner/web_test_proxy.cc b/content/shell/renderer/test_runner/web_test_proxy.cc
index 6a50df3..989502b 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 @@
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 @@
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 @@
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 @@
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 @@
}
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;