shill: Perform Portal Detection in Device
When a connection completes, start a portal detection request, which
may change the state of the selected service. Bonus changes: removed
Service::kStateReady, since Service::kStateConnected maps directly
to flimflam::kStateReady. Also, move technology list parsing over
to technology.cc.
BUG=chromium-os:23318
TEST=New unit tests
Change-Id: I2fad724165af6914c8f83bc123f07db5af223a05
Reviewed-on: https://gerrit.chromium.org/gerrit/16117
Commit-Ready: Paul Stewart <pstew@chromium.org>
Reviewed-by: Paul Stewart <pstew@chromium.org>
Tested-by: Paul Stewart <pstew@chromium.org>
diff --git a/device.h b/device.h
index b92ef75..8036cd1 100644
--- a/device.h
+++ b/device.h
@@ -16,6 +16,7 @@
#include "shill/event_dispatcher.h"
#include "shill/ip_address.h"
#include "shill/ipconfig.h"
+#include "shill/portal_detector.h"
#include "shill/property_store.h"
#include "shill/refptr_types.h"
#include "shill/service.h"
@@ -136,8 +137,6 @@
FRIEND_TEST(DeviceTest, DestroyIPConfig);
FRIEND_TEST(DeviceTest, DestroyIPConfigNULL);
FRIEND_TEST(DeviceTest, GetProperties);
- FRIEND_TEST(DeviceTest, IPConfigUpdatedFailure);
- FRIEND_TEST(DeviceTest, IPConfigUpdatedSuccess);
FRIEND_TEST(DeviceTest, Save);
FRIEND_TEST(DeviceTest, SelectedService);
FRIEND_TEST(DeviceTest, Stop);
@@ -173,6 +172,21 @@
// "failure")
void SetServiceFailure(Service::ConnectFailure failure_state);
+ // Called by the Portal Detector whenever a trial completes. Device
+ // subclasses that choose unique mappings from portal results to connected
+ // states can override this method in order to do so.
+ virtual void PortalDetectorCallback(const PortalDetector::Result &result);
+
+ // Initiate portal detection, if enabled for this device type.
+ bool StartPortalDetection();
+
+ // Stop portal detection if it is running.
+ void StopPortalDetection();
+
+ // Set the state of the selected service, with checks to make sure
+ // the service is already in a connected state before doing so.
+ void SetServiceConnectedState(Service::ConnectState state);
+
void HelpRegisterDerivedString(
const std::string &name,
std::string(Device::*get)(Error *),
@@ -241,6 +255,9 @@
IPConfigRefPtr ipconfig_;
ConnectionRefPtr connection_;
scoped_ptr<DeviceAdaptorInterface> adaptor_;
+ scoped_ptr<PortalDetector> portal_detector_;
+ scoped_ptr<Callback1<const PortalDetector::Result &>::Type>
+ portal_detector_callback_;
Technology::Identifier technology_;
// Maintain a reference to the connected / connecting service