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.h b/http_proxy.h
index 1541917..b2d4b83 100644
--- a/http_proxy.h
+++ b/http_proxy.h
@@ -19,8 +19,9 @@
namespace shill {
class AsyncConnection;
-class EventDispatcher;
class DNSClient;
+class Error;
+class EventDispatcher;
class InputData;
class IOHandler;
class IPAddress;
@@ -93,7 +94,7 @@
void AcceptClient(int fd);
bool ConnectServer(const IPAddress &address, int port);
- void GetDNSResult(bool result);
+ void GetDNSResult(const Error &error, const IPAddress &address);
void OnConnectCompletion(bool success, int fd);
bool ParseClientRequest();
bool ProcessLastHeaderLine();
@@ -119,7 +120,8 @@
ConnectionRefPtr connection_;
scoped_ptr<Callback1<int>::Type> accept_callback_;
scoped_ptr<Callback2<bool, int>::Type> connect_completion_callback_;
- scoped_ptr<Callback1<bool>::Type> dns_client_callback_;
+ scoped_ptr<Callback2<const Error &, const IPAddress &>::Type>
+ dns_client_callback_;
scoped_ptr<Callback1<InputData *>::Type> read_client_callback_;
scoped_ptr<Callback1<InputData *>::Type> read_server_callback_;
scoped_ptr<Callback1<int>::Type> write_client_callback_;