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

Unified Diff: net/base/dns_query.cc

Issue 7276014: DnsQuery: changed raw function pointer to callback. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed header ordering. Created 9 years, 6 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
Index: net/base/dns_query.cc
diff --git a/net/base/dns_query.cc b/net/base/dns_query.cc
index 7ccf32a336a3f6cd6ddbf595ed6c62f7179d6ac7..f32282e78f7f150422c75073e0f7ef64c96c9fef 100644
--- a/net/base/dns_query.cc
+++ b/net/base/dns_query.cc
@@ -4,6 +4,7 @@
#include "net/base/dns_query.h"
+#include <limits>
#include <string>
#include "base/rand_util.h"
@@ -35,9 +36,11 @@ static const char kHeader[] = {0x00, 0x00, 0x01, 0x00, 0x00, 0x01,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
static const size_t kHeaderSize = arraysize(kHeader);
-DnsQuery::DnsQuery(const std::string& dns_name, uint16 qtype, uint64 (*prng)())
+DnsQuery::DnsQuery(const std::string& dns_name,
+ uint16 qtype,
+ const RandIntCallback& rand_int)
: dns_name_size_(dns_name.size()),
- prng_(prng) {
+ rand_int_(rand_int) {
DCHECK(DnsResponseBuffer(reinterpret_cast<const uint8*>(dns_name.c_str()),
dns_name.size()).DNSName(NULL));
DCHECK(qtype == kDNS_A || qtype == kDNS_AAAA);
@@ -58,7 +61,7 @@ DnsQuery::DnsQuery(const std::string& dns_name, uint16 qtype, uint64 (*prng)())
DnsQuery::DnsQuery(const DnsQuery& rhs)
willchan no longer on Chromium 2011/06/28 19:10:47 I just happened to notice this. Copy constructors
agayev 2011/06/28 19:49:55 I wasn't aware of that, although this copy constru
willchan no longer on Chromium 2011/06/28 20:06:42 Yeah, a followup CL would be great. No need to blo
: dns_name_size_(rhs.dns_name_size_),
- prng_(rhs.prng_) {
+ rand_int_(rhs.rand_int_) {
io_buffer_ = new IOBufferWithSize(rhs.io_buffer()->size());
memcpy(io_buffer_->data(), rhs.io_buffer()->data(), rhs.io_buffer()->size());
RandomizeId();
@@ -90,7 +93,9 @@ const char* DnsQuery::question_data() const {
}
void DnsQuery::RandomizeId() {
- PackUint16BE(&io_buffer_->data()[0], (*prng_)() & 0xffff);
+ PackUint16BE(&io_buffer_->data()[0], rand_int_.Run(
+ std::numeric_limits<uint16>::min(),
+ std::numeric_limits<uint16>::max()));
}
} // namespace net
« net/base/dns_query.h ('K') | « net/base/dns_query.h ('k') | net/base/dns_query_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698