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/portal_detector.cc b/portal_detector.cc
index 35228d1..7bbb965 100644
--- a/portal_detector.cc
+++ b/portal_detector.cc
@@ -162,9 +162,8 @@
}
}
-void PortalDetector::RequestReadCallback(int /*read_length*/) {
+void PortalDetector::RequestReadCallback(const ByteString &response_data) {
const string response_expected(kResponseExpected);
- const ByteString &response_data = request_->response_data();
bool expected_length_received = false;
int compare_length = 0;
if (response_data.GetLength() < response_expected.length()) {
@@ -188,7 +187,8 @@
}
}
-void PortalDetector::RequestResultCallback(HTTPRequest::Result result) {
+void PortalDetector::RequestResultCallback(
+ HTTPRequest::Result result, const ByteString &/*response_data*/) {
CompleteAttempt(GetPortalResultForRequestResult(result));
}