shill: Prepare DNSClient and HTTPRequest for destroy-on-callback

Refactor both classes so that it's okay for the callback to destroy
the object (i.e., do nothing to the object after the callback is
called).  As a part of this, clean up some of the callback semantics,
so, for example, DNSClient callbacks are passed an Error reference
and an IP Address instead of having to use a getter.  Additionally
remove the blemish where an immediate timeout in Start() both returned
failure and called the callback.

BUG=chromium-os:23318
TEST=Fixed unit tests, manual

Change-Id: Ib7787a7aa6f7f3d00caa539d6b0221ff5f3d60b3
Reviewed-on: https://gerrit.chromium.org/gerrit/16435
Commit-Ready: Paul Stewart <pstew@chromium.org>
Reviewed-by: Paul Stewart <pstew@chromium.org>
Tested-by: Paul Stewart <pstew@chromium.org>
diff --git a/http_proxy.cc b/http_proxy.cc
index 2075c65..9e5e83e 100644
--- a/http_proxy.cc
+++ b/http_proxy.cc
@@ -190,13 +190,13 @@
 }
 
 // DNSClient callback that fires when the DNS request completes.
-void HTTPProxy::GetDNSResult(bool result) {
-  if (!result) {
+void HTTPProxy::GetDNSResult(const Error &error, const IPAddress &address) {
+  if (!error.IsSuccess()) {
     SendClientError(502, string("Could not resolve hostname: ") +
-                    dns_client_->error());
+                    error.message());
     return;
   }
-  ConnectServer(dns_client_->address(), server_port_);
+  ConnectServer(address, server_port_);
 }
 
 // IOReadyHandler callback routine which fires when the asynchronous Connect()
@@ -301,8 +301,9 @@
     }
   } else {
     VLOG(3) << "Looking up host: " << server_hostname_;
-    if (!dns_client_->Start(server_hostname_)) {
-      SendClientError(502, "Could not resolve hostname");
+    Error error;
+    if (!dns_client_->Start(server_hostname_, &error)) {
+      SendClientError(502, "Could not resolve hostname: " + error.message());
       return false;
     }
     state_ = kStateLookupServer;