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

Unified Diff: net/dns/host_resolver_impl.cc

Issue 1135373002: Updated NetLog::ParametersCallback & all related calbacks returning value as scoped_ptr<base::Value… Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 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
« no previous file with comments | « net/dns/host_resolver_impl.h ('k') | net/dns/mapped_host_resolver.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/dns/host_resolver_impl.cc
diff --git a/net/dns/host_resolver_impl.cc b/net/dns/host_resolver_impl.cc
index bd6e43198dca94319fe32227f5bc89475634f90a..cd04c2c0c169e3aae692516e2829b0b04b647809 100644
--- a/net/dns/host_resolver_impl.cc
+++ b/net/dns/host_resolver_impl.cc
@@ -302,12 +302,12 @@ bool IsAllIPv4Loopback(const AddressList& addresses) {
}
// Creates NetLog parameters when the resolve failed.
-base::Value* NetLogProcTaskFailedCallback(
+scoped_ptr<base::Value> NetLogProcTaskFailedCallback(
uint32 attempt_number,
int net_error,
int os_error,
NetLogCaptureMode /* capture_mode */) {
- base::DictionaryValue* dict = new base::DictionaryValue();
+ scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue());
if (attempt_number)
dict->SetInteger("attempt_number", attempt_number);
@@ -332,57 +332,62 @@ base::Value* NetLogProcTaskFailedCallback(
#endif
}
- return dict;
+ return dict.Pass();
}
// Creates NetLog parameters when the DnsTask failed.
-base::Value* NetLogDnsTaskFailedCallback(int net_error,
- int dns_error,
- NetLogCaptureMode /* capture_mode */) {
- base::DictionaryValue* dict = new base::DictionaryValue();
+scoped_ptr<base::Value> NetLogDnsTaskFailedCallback(
+ int net_error,
+ int dns_error,
+ NetLogCaptureMode /* capture_mode */) {
+ scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue());
dict->SetInteger("net_error", net_error);
if (dns_error)
dict->SetInteger("dns_error", dns_error);
- return dict;
+ return dict.Pass();
};
// Creates NetLog parameters containing the information in a RequestInfo object,
// along with the associated NetLog::Source.
-base::Value* NetLogRequestInfoCallback(const HostResolver::RequestInfo* info,
- NetLogCaptureMode /* capture_mode */) {
- base::DictionaryValue* dict = new base::DictionaryValue();
+scoped_ptr<base::Value> NetLogRequestInfoCallback(
+ const HostResolver::RequestInfo* info,
+ NetLogCaptureMode /* capture_mode */) {
+ scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue());
dict->SetString("host", info->host_port_pair().ToString());
dict->SetInteger("address_family",
static_cast<int>(info->address_family()));
dict->SetBoolean("allow_cached_response", info->allow_cached_response());
dict->SetBoolean("is_speculative", info->is_speculative());
- return dict;
+ return dict.Pass();
}
// Creates NetLog parameters for the creation of a HostResolverImpl::Job.
-base::Value* NetLogJobCreationCallback(const NetLog::Source& source,
- const std::string* host,
- NetLogCaptureMode /* capture_mode */) {
- base::DictionaryValue* dict = new base::DictionaryValue();
- source.AddToEventParameters(dict);
+scoped_ptr<base::Value> NetLogJobCreationCallback(
+ const NetLog::Source& source,
+ const std::string* host,
+ NetLogCaptureMode /* capture_mode */) {
+ scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue());
+ source.AddToEventParameters(dict.release());
dict->SetString("host", *host);
- return dict;
+ return dict.Pass();
}
// Creates NetLog parameters for HOST_RESOLVER_IMPL_JOB_ATTACH/DETACH events.
-base::Value* NetLogJobAttachCallback(const NetLog::Source& source,
- RequestPriority priority,
- NetLogCaptureMode /* capture_mode */) {
- base::DictionaryValue* dict = new base::DictionaryValue();
- source.AddToEventParameters(dict);
+scoped_ptr<base::Value> NetLogJobAttachCallback(
+ const NetLog::Source& source,
+ RequestPriority priority,
+ NetLogCaptureMode /* capture_mode */) {
+ scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue());
+ source.AddToEventParameters(dict.release());
dict->SetString("priority", RequestPriorityToString(priority));
- return dict;
+ return dict.Pass();
}
// Creates NetLog parameters for the DNS_CONFIG_CHANGED event.
-base::Value* NetLogDnsConfigCallback(const DnsConfig* config,
- NetLogCaptureMode /* capture_mode */) {
+scoped_ptr<base::Value> NetLogDnsConfigCallback(
+ const DnsConfig* config,
+ NetLogCaptureMode /* capture_mode */) {
return config->ToValue();
}
@@ -392,9 +397,8 @@ base::Value* NetLogDnsConfigCallback(const DnsConfig* config,
// Logs when a request has just been started.
void LogStartRequest(const BoundNetLog& source_net_log,
const HostResolver::RequestInfo& info) {
- source_net_log.BeginEvent(
- NetLog::TYPE_HOST_RESOLVER_IMPL_REQUEST,
- base::Bind(&NetLogRequestInfoCallback, &info));
+ source_net_log.BeginEvent(NetLog::TYPE_HOST_RESOLVER_IMPL_REQUEST,
+ base::Bind(NetLogRequestInfoCallback, &info));
}
// Logs when a request has just completed (before its callback is run).
@@ -737,10 +741,8 @@ class HostResolverImpl::ProcTask
NetLog::ParametersCallback net_log_callback;
if (error != OK) {
- net_log_callback = base::Bind(&NetLogProcTaskFailedCallback,
- attempt_number,
- error,
- os_error);
+ net_log_callback = base::Bind(NetLogProcTaskFailedCallback,
+ attempt_number, error, os_error);
} else {
net_log_callback = NetLog::IntegerCallback("attempt_number",
attempt_number);
@@ -763,8 +765,8 @@ class HostResolverImpl::ProcTask
}
if (error != OK) {
- net_log_callback = base::Bind(&NetLogProcTaskFailedCallback,
- 0, error, os_error);
+ net_log_callback =
+ base::Bind(NetLogProcTaskFailedCallback, 0, error, os_error);
} else {
net_log_callback = results_.CreateNetLogCallback();
}
@@ -1167,7 +1169,7 @@ class HostResolverImpl::DnsTask : public base::SupportsWeakPtr<DnsTask> {
DCHECK_NE(OK, net_error);
net_log_.EndEvent(
NetLog::TYPE_HOST_RESOLVER_IMPL_DNS_TASK,
- base::Bind(&NetLogDnsTaskFailedCallback, net_error, result));
+ base::Bind(NetLogDnsTaskFailedCallback, net_error, result));
delegate_->OnDnsTaskComplete(task_start_time_, net_error, AddressList(),
base::TimeDelta());
}
@@ -1225,11 +1227,9 @@ class HostResolverImpl::Job : public PrioritizedDispatcher::Job,
NetLog::SOURCE_HOST_RESOLVER_IMPL_JOB)) {
source_net_log.AddEvent(NetLog::TYPE_HOST_RESOLVER_IMPL_CREATE_JOB);
- net_log_.BeginEvent(
- NetLog::TYPE_HOST_RESOLVER_IMPL_JOB,
- base::Bind(&NetLogJobCreationCallback,
- source_net_log.source(),
- &key_.hostname));
+ net_log_.BeginEvent(NetLog::TYPE_HOST_RESOLVER_IMPL_JOB,
+ base::Bind(NetLogJobCreationCallback,
+ source_net_log.source(), &key_.hostname));
}
~Job() override {
@@ -1298,11 +1298,9 @@ class HostResolverImpl::Job : public PrioritizedDispatcher::Job,
NetLog::TYPE_HOST_RESOLVER_IMPL_JOB_ATTACH,
net_log_.source().ToEventParametersCallback());
- net_log_.AddEvent(
- NetLog::TYPE_HOST_RESOLVER_IMPL_JOB_REQUEST_ATTACH,
- base::Bind(&NetLogJobAttachCallback,
- req->source_net_log().source(),
- priority()));
+ net_log_.AddEvent(NetLog::TYPE_HOST_RESOLVER_IMPL_JOB_REQUEST_ATTACH,
+ base::Bind(NetLogJobAttachCallback,
+ req->source_net_log().source(), priority()));
// TODO(szym): Check if this is still needed.
if (!req->info().is_speculative()) {
@@ -1328,9 +1326,8 @@ class HostResolverImpl::Job : public PrioritizedDispatcher::Job,
priority_tracker_.Remove(req->priority());
net_log_.AddEvent(NetLog::TYPE_HOST_RESOLVER_IMPL_JOB_REQUEST_DETACH,
- base::Bind(&NetLogJobAttachCallback,
- req->source_net_log().source(),
- priority()));
+ base::Bind(NetLogJobAttachCallback,
+ req->source_net_log().source(), priority()));
if (num_active_requests() > 0) {
UpdatePriority();
@@ -2022,7 +2019,7 @@ HostCache* HostResolverImpl::GetHostCache() {
return cache_.get();
}
-base::Value* HostResolverImpl::GetDnsConfigAsValue() const {
+scoped_ptr<base::Value> HostResolverImpl::GetDnsConfigAsValue() const {
// Check if async DNS is disabled.
if (!dns_client_.get())
return NULL;
@@ -2030,8 +2027,10 @@ base::Value* HostResolverImpl::GetDnsConfigAsValue() const {
// Check if async DNS is enabled, but we currently have no configuration
// for it.
const DnsConfig* dns_config = dns_client_->GetConfig();
- if (dns_config == NULL)
- return new base::DictionaryValue();
+ if (dns_config == NULL) {
+ scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue());
+ return dict.Pass();
+ }
return dns_config->ToValue();
}
@@ -2303,9 +2302,8 @@ void HostResolverImpl::UpdateDNSConfig(bool config_changed) {
NetworkChangeNotifier::GetDnsConfig(&dns_config);
if (net_log_) {
- net_log_->AddGlobalEntry(
- NetLog::TYPE_DNS_CONFIG_CHANGED,
- base::Bind(&NetLogDnsConfigCallback, &dns_config));
+ net_log_->AddGlobalEntry(NetLog::TYPE_DNS_CONFIG_CHANGED,
+ base::Bind(NetLogDnsConfigCallback, &dns_config));
}
// TODO(szym): Remove once http://crbug.com/137914 is resolved.
« no previous file with comments | « net/dns/host_resolver_impl.h ('k') | net/dns/mapped_host_resolver.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698