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

Unified Diff: net/base/dns_util.cc

Issue 8762001: Isolates generic DnsClient from AsyncHostResolver. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: retrying to fix status of dns_session.h Created 9 years 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 | « net/base/dns_util.h ('k') | net/dns/async_host_resolver.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/base/dns_util.cc
diff --git a/net/base/dns_util.cc b/net/base/dns_util.cc
index 93d789e31a22d17159cd81b75760f492f0336672..a49ada86ee3c854965689093b20367ad493ff1d1 100644
--- a/net/base/dns_util.cc
+++ b/net/base/dns_util.cc
@@ -9,7 +9,7 @@
namespace net {
// Based on DJB's public domain code.
-bool DNSDomainFromDot(const std::string& dotted, std::string* out) {
+bool DNSDomainFromDot(const base::StringPiece& dotted, std::string* out) {
const char* buf = dotted.data();
unsigned n = dotted.size();
char label[63];
@@ -56,7 +56,7 @@ bool DNSDomainFromDot(const std::string& dotted, std::string* out) {
return true;
}
-std::string DNSDomainToString(const std::string& domain) {
+std::string DNSDomainToString(const base::StringPiece& domain) {
std::string ret;
for (unsigned i = 0; i < domain.size() && domain[i]; i += domain[i] + 1) {
@@ -73,7 +73,7 @@ std::string DNSDomainToString(const std::string& domain) {
if (static_cast<unsigned>(domain[i]) + i + 1 > domain.size())
return "";
- ret += domain.substr(i + 1, domain[i]);
+ domain.substr(i + 1, domain[i]).AppendToString(&ret);
}
return ret;
}
@@ -92,12 +92,13 @@ bool IsSTD3ASCIIValidCharacter(char c) {
return true;
}
-std::string TrimEndingDot(const std::string& host) {
- std::string host_trimmed = host;
+std::string TrimEndingDot(const base::StringPiece& host) {
+ base::StringPiece host_trimmed = host;
size_t len = host_trimmed.length();
- if (len > 1 && host_trimmed[len - 1] == '.')
- host_trimmed.erase(len - 1);
- return host_trimmed;
+ if (len > 1 && host_trimmed[len - 1] == '.') {
+ host_trimmed.remove_suffix(1);
+ }
+ return host_trimmed.as_string();
}
bool DnsResponseBuffer::U8(uint8* v) {
« no previous file with comments | « net/base/dns_util.h ('k') | net/dns/async_host_resolver.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698