Chromium Code Reviews| Index: chrome/browser/extensions/api/dns/dns_api.cc |
| diff --git a/chrome/browser/extensions/api/dns/dns_api.cc b/chrome/browser/extensions/api/dns/dns_api.cc |
| index 5a867524a98299ae34b70571bf462d3a9c2c5751..44c4064130f792f3c5f133cbbd9b2ee6021ff8a8 100644 |
| --- a/chrome/browser/extensions/api/dns/dns_api.cc |
| +++ b/chrome/browser/extensions/api/dns/dns_api.cc |
| @@ -21,8 +21,14 @@ namespace Resolve = extensions::api::experimental_dns::Resolve; |
| namespace extensions { |
| -// static |
| -net::HostResolver* DnsResolveFunction::host_resolver_for_testing; |
| +namespace { |
| + |
| +// If null, then we'll use io_thread_ to obtain the real HostResolver. We use |
| +// a plain pointer for to be consistent with the ownership model of the real |
| +// one. |
| +net::HostResolver* g_host_resolver_for_testing = NULL; |
|
Ryan Sleevi
2012/04/25 03:35:42
One less publicly exposed static. This was an oppo
Aaron Boodman
2012/04/27 03:52:04
It wasn't "publicly exposed" was it? Its access mo
|
| + |
| +} // namespace |
| DnsResolveFunction::DnsResolveFunction() |
| : response_(false), |
| @@ -33,15 +39,14 @@ DnsResolveFunction::DnsResolveFunction() |
| addresses_(new net::AddressList) { |
| } |
| -DnsResolveFunction::~DnsResolveFunction() { |
| -} |
| - |
| // static |
| void DnsResolveFunction::set_host_resolver_for_testing( |
| net::HostResolver* host_resolver_for_testing_param) { |
| - host_resolver_for_testing = host_resolver_for_testing_param; |
| + g_host_resolver_for_testing = host_resolver_for_testing_param; |
| } |
| +DnsResolveFunction::~DnsResolveFunction() {} |
| + |
| bool DnsResolveFunction::RunImpl() { |
| scoped_ptr<Resolve::Params> params(Resolve::Params::Create(*args_)); |
| EXTENSION_FUNCTION_VALIDATE(params.get()); |
| @@ -58,8 +63,8 @@ bool DnsResolveFunction::RunImpl() { |
| void DnsResolveFunction::WorkOnIOThread() { |
| DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| - net::HostResolver* host_resolver = host_resolver_for_testing ? |
| - host_resolver_for_testing : io_thread_->globals()->host_resolver.get(); |
| + net::HostResolver* host_resolver = g_host_resolver_for_testing ? |
| + g_host_resolver_for_testing : io_thread_->globals()->host_resolver.get(); |
| DCHECK(host_resolver); |
| // Yes, we are passing zero as the port. There are some interesting but not |
| @@ -81,8 +86,12 @@ void DnsResolveFunction::WorkOnIOThread() { |
| OnLookupFinished(resolve_result); |
| } |
| -void DnsResolveFunction::OnLookupFinished(int resolve_result) { |
| +void DnsResolveFunction::RespondOnUIThread() { |
| + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| + SendResponse(response_); |
| +} |
| +void DnsResolveFunction::OnLookupFinished(int resolve_result) { |
| scoped_ptr<ResolveCallbackResolveInfo> resolve_info( |
| new ResolveCallbackResolveInfo()); |
| resolve_info->result_code = resolve_result; |
| @@ -103,9 +112,4 @@ void DnsResolveFunction::OnLookupFinished(int resolve_result) { |
| Release(); // Added in WorkOnIOThread(). |
| } |
| -void DnsResolveFunction::RespondOnUIThread() { |
| - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| - SendResponse(response_); |
| -} |
| - |
| } // namespace extensions |