Index: net/dns/dns_transaction.cc |
diff --git a/net/dns/dns_transaction.cc b/net/dns/dns_transaction.cc |
index 130922c6025620f821e6662d5ebfb318da00fb89..d74a9ff31b955721a26aea4222e12344c54b84c3 100644 |
--- a/net/dns/dns_transaction.cc |
+++ b/net/dns/dns_transaction.cc |
@@ -41,8 +41,12 @@ namespace { |
// Provide a common macro to simplify code and readability. We must use a |
// macro as the underlying HISTOGRAM macro creates static variables. |
-#define DNS_HISTOGRAM(name, time) UMA_HISTOGRAM_CUSTOM_TIMES(name, time, \ |
- base::TimeDelta::FromMilliseconds(1), base::TimeDelta::FromHours(1), 100) |
+#define DNS_HISTOGRAM(name, time) \ |
+ UMA_HISTOGRAM_CUSTOM_TIMES(name, \ |
+ time, \ |
+ base::TimeDelta::FromMilliseconds(1), \ |
+ base::TimeDelta::FromHours(1), \ |
+ 100) |
// Count labels in the fully-qualified name in DNS format. |
int CountLabels(const std::string& name) { |
@@ -58,8 +62,8 @@ bool IsIPLiteral(const std::string& hostname) { |
} |
base::Value* NetLogStartCallback(const std::string* hostname, |
- uint16 qtype, |
- NetLog::LogLevel /* log_level */) { |
+ uint16 qtype, |
+ NetLog::LogLevel /* log_level */) { |
base::DictionaryValue* dict = new base::DictionaryValue(); |
dict->SetString("hostname", *hostname); |
dict->SetInteger("query_type", qtype); |
@@ -107,19 +111,15 @@ class DnsAttempt { |
return dict; |
} |
- void set_result(int result) { |
- result_ = result; |
- } |
+ void set_result(int result) { result_ = result; } |
// True if current attempt is pending (waiting for server response). |
- bool is_pending() const { |
- return result_ == ERR_IO_PENDING; |
- } |
+ bool is_pending() const { return result_ == ERR_IO_PENDING; } |
// True if attempt is completed (received server response). |
bool is_completed() const { |
return (result_ == OK) || (result_ == ERR_NAME_NOT_RESOLVED) || |
- (result_ == ERR_DNS_SERVER_REQUIRES_TCP); |
+ (result_ == ERR_DNS_SERVER_REQUIRES_TCP); |
} |
private: |
@@ -149,9 +149,7 @@ class DnsUDPAttempt : public DnsAttempt { |
return DoLoop(OK); |
} |
- virtual const DnsQuery* GetQuery() const OVERRIDE { |
- return query_.get(); |
- } |
+ virtual const DnsQuery* GetQuery() const OVERRIDE { return query_.get(); } |
virtual const DnsResponse* GetResponse() const OVERRIDE { |
const DnsResponse* resp = response_.get(); |
@@ -171,9 +169,7 @@ class DnsUDPAttempt : public DnsAttempt { |
STATE_NONE, |
}; |
- DatagramClientSocket* socket() { |
- return socket_lease_->socket(); |
- } |
+ DatagramClientSocket* socket() { return socket_lease_->socket(); } |
int DoLoop(int result) { |
CHECK_NE(STATE_NONE, next_state_); |
@@ -218,10 +214,10 @@ class DnsUDPAttempt : public DnsAttempt { |
int DoSendQuery() { |
next_state_ = STATE_SEND_QUERY_COMPLETE; |
- return socket()->Write(query_->io_buffer(), |
- query_->io_buffer()->size(), |
- base::Bind(&DnsUDPAttempt::OnIOComplete, |
- base::Unretained(this))); |
+ return socket()->Write( |
+ query_->io_buffer(), |
+ query_->io_buffer()->size(), |
+ base::Bind(&DnsUDPAttempt::OnIOComplete, base::Unretained(this))); |
} |
int DoSendQueryComplete(int rv) { |
@@ -240,10 +236,10 @@ class DnsUDPAttempt : public DnsAttempt { |
int DoReadResponse() { |
next_state_ = STATE_READ_RESPONSE_COMPLETE; |
response_.reset(new DnsResponse()); |
- return socket()->Read(response_->io_buffer(), |
- response_->io_buffer()->size(), |
- base::Bind(&DnsUDPAttempt::OnIOComplete, |
- base::Unretained(this))); |
+ return socket()->Read( |
+ response_->io_buffer(), |
+ response_->io_buffer()->size(), |
+ base::Bind(&DnsUDPAttempt::OnIOComplete, base::Unretained(this))); |
} |
int DoReadResponseComplete(int rv) { |
@@ -311,8 +307,8 @@ class DnsTCPAttempt : public DnsAttempt { |
callback_ = callback; |
start_time_ = base::TimeTicks::Now(); |
next_state_ = STATE_CONNECT_COMPLETE; |
- int rv = socket_->Connect(base::Bind(&DnsTCPAttempt::OnIOComplete, |
- base::Unretained(this))); |
+ int rv = socket_->Connect( |
+ base::Bind(&DnsTCPAttempt::OnIOComplete, base::Unretained(this))); |
if (rv == ERR_IO_PENDING) { |
set_result(rv); |
return rv; |
@@ -320,9 +316,7 @@ class DnsTCPAttempt : public DnsAttempt { |
return DoLoop(rv); |
} |
- virtual const DnsQuery* GetQuery() const OVERRIDE { |
- return query_.get(); |
- } |
+ virtual const DnsQuery* GetQuery() const OVERRIDE { return query_.get(); } |
virtual const DnsResponse* GetResponse() const OVERRIDE { |
const DnsResponse* resp = response_.get(); |
@@ -409,8 +403,8 @@ class DnsTCPAttempt : public DnsAttempt { |
buffer_->BytesRemaining(), |
base::Bind(&DnsTCPAttempt::OnIOComplete, base::Unretained(this))); |
} |
- buffer_ = new DrainableIOBuffer(query_->io_buffer(), |
- query_->io_buffer()->size()); |
+ buffer_ = |
+ new DrainableIOBuffer(query_->io_buffer(), query_->io_buffer()->size()); |
next_state_ = STATE_SEND_QUERY; |
return OK; |
} |
@@ -523,15 +517,15 @@ class DnsTransactionImpl : public DnsTransaction, |
uint16 qtype, |
const DnsTransactionFactory::CallbackType& callback, |
const BoundNetLog& net_log) |
- : session_(session), |
- hostname_(hostname), |
- qtype_(qtype), |
- callback_(callback), |
- net_log_(net_log), |
- qnames_initial_size_(0), |
- attempts_count_(0), |
- had_tcp_attempt_(false), |
- first_server_index_(0) { |
+ : session_(session), |
+ hostname_(hostname), |
+ qtype_(qtype), |
+ callback_(callback), |
+ net_log_(net_log), |
+ qnames_initial_size_(0), |
+ attempts_count_(0), |
+ had_tcp_attempt_(false), |
+ first_server_index_(0) { |
DCHECK(session_.get()); |
DCHECK(!hostname_.empty()); |
DCHECK(!callback_.is_null()); |
@@ -637,8 +631,8 @@ class DnsTransactionImpl : public DnsTransaction, |
void DoCallback(AttemptResult result) { |
DCHECK(!callback_.is_null()); |
DCHECK_NE(ERR_IO_PENDING, result.rv); |
- const DnsResponse* response = result.attempt ? |
- result.attempt->GetResponse() : NULL; |
+ const DnsResponse* response = |
+ result.attempt ? result.attempt->GetResponse() : NULL; |
CHECK(result.rv != OK || response != NULL); |
timer_.Stop(); |
@@ -699,13 +693,14 @@ class DnsTransactionImpl : public DnsTransaction, |
NetLog::TYPE_DNS_TRANSACTION_ATTEMPT, |
attempt->GetSocketNetLog().source().ToEventParametersCallback()); |
- int rv = attempt->Start( |
- base::Bind(&DnsTransactionImpl::OnUdpAttemptComplete, |
- base::Unretained(this), attempt_number, |
- base::TimeTicks::Now())); |
+ int rv = |
+ attempt->Start(base::Bind(&DnsTransactionImpl::OnUdpAttemptComplete, |
+ base::Unretained(this), |
+ attempt_number, |
+ base::TimeTicks::Now())); |
if (rv == ERR_IO_PENDING) { |
- base::TimeDelta timeout = session_->NextTimeout(server_index, |
- attempt_number); |
+ base::TimeDelta timeout = |
+ session_->NextTimeout(server_index, attempt_number); |
timer_.Start(FROM_HERE, timeout, this, &DnsTransactionImpl::OnTimeout); |
} |
return AttemptResult(rv, attempt); |
@@ -731,8 +726,8 @@ class DnsTransactionImpl : public DnsTransaction, |
unsigned attempt_number = attempts_.size(); |
- DnsTCPAttempt* attempt = new DnsTCPAttempt(server_index, socket.Pass(), |
- query.Pass()); |
+ DnsTCPAttempt* attempt = |
+ new DnsTCPAttempt(server_index, socket.Pass(), query.Pass()); |
attempts_.push_back(attempt); |
++attempts_count_; |
@@ -793,7 +788,7 @@ class DnsTransactionImpl : public DnsTransaction, |
// Loop through attempts until we find first that is completed |
size_t first_completed = 0; |
for (first_completed = 0; first_completed < attempts_.size(); |
- ++first_completed) { |
+ ++first_completed) { |
if (attempts_[first_completed]->is_completed()) |
break; |
} |
@@ -816,10 +811,9 @@ class DnsTransactionImpl : public DnsTransaction, |
void LogResponse(const DnsAttempt* attempt) { |
if (attempt && attempt->GetResponse()) { |
- net_log_.AddEvent( |
- NetLog::TYPE_DNS_TRANSACTION_RESPONSE, |
- base::Bind(&DnsAttempt::NetLogResponseCallback, |
- base::Unretained(attempt))); |
+ net_log_.AddEvent(NetLog::TYPE_DNS_TRANSACTION_RESPONSE, |
+ base::Bind(&DnsAttempt::NetLogResponseCallback, |
+ base::Unretained(attempt))); |
} |
} |
@@ -918,7 +912,7 @@ class DnsTransactionImpl : public DnsTransaction, |
// List of attempts for the current name. |
ScopedVector<DnsAttempt> attempts_; |
// Count of attempts, not reset when |attempts_| vector is cleared. |
- int attempts_count_; |
+ int attempts_count_; |
bool had_tcp_attempt_; |
// Index of the first server to try on each search query. |