summaryrefslogtreecommitdiffstats
path: root/net/base/dns_util.cc
diff options
context:
space:
mode:
authorszym@chromium.org <szym@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-12-06 23:32:58 +0000
committerszym@chromium.org <szym@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-12-06 23:32:58 +0000
commitad24b1827fe58c4a22c0cddb5791a95f2ab1b21b (patch)
tree7e5e4727d7ab5e3a96bc95ee890aebb1b6c2d608 /net/base/dns_util.cc
parentd7de57877613a63e36facbd485245918c1131f61 (diff)
downloadchromium_src-ad24b1827fe58c4a22c0cddb5791a95f2ab1b21b.zip
chromium_src-ad24b1827fe58c4a22c0cddb5791a95f2ab1b21b.tar.gz
chromium_src-ad24b1827fe58c4a22c0cddb5791a95f2ab1b21b.tar.bz2
Isolates generic DnsClient from AsyncHostResolver.
DnsClient provides a generic DNS client that allows fetching resource records. DnsClient is very lightweight and does not support aggregation, queuing or prioritization of requests. This is the first CL in a series to merge AsyncHostResolver into HostResolverImpl. Also introduces general-purpose BigEndianReader/Writer. BUG=90881 TEST=./net_unittests Review URL: http://codereview.chromium.org/8762001 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@113282 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/base/dns_util.cc')
-rw-r--r--net/base/dns_util.cc17
1 files changed, 9 insertions, 8 deletions
diff --git a/net/base/dns_util.cc b/net/base/dns_util.cc
index 93d789e..a49ada8 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) {