shill: Simplifies netlink message callbacks.

Config80211 had required broadcast callbacks to be child classes of some
special (and, as it turns out, completely unnecessary) superclass.  This
CL a) replaces the superclass with |base::Callback|, b) updates
callback_metrics to use this new mechanism, and c) removes callback_object
(which was really just a template for future callback and is no longer
necessary).

BUG=None.
TEST=unittests.

Change-Id: I8f080521ba17e45e678289d10060f8e8927c0496
Reviewed-on: https://gerrit.chromium.org/gerrit/44779
Commit-Queue: Wade Guthrie <wdg@chromium.org>
Reviewed-by: Wade Guthrie <wdg@chromium.org>
Tested-by: Wade Guthrie <wdg@chromium.org>
diff --git a/callback80211_metrics.cc b/callback80211_metrics.cc
index 835a6f0..087bfcf 100644
--- a/callback80211_metrics.cc
+++ b/callback80211_metrics.cc
@@ -13,14 +13,31 @@
 
 namespace shill {
 
-Callback80211Metrics::Callback80211Metrics(Metrics *metrics)
-    : Callback80211Object(),
-      metrics_(metrics) {
+Callback80211Metrics::Callback80211Metrics(const Config80211 &config80211,
+                                           Metrics *metrics)
+    : metrics_(metrics),
+      nl80211_message_type_(NetlinkMessage::kIllegalMessageType) {}
+
+void Callback80211Metrics::InitNl80211FamilyId(
+    const Config80211 &config80211) {
+  nl80211_message_type_ =
+      config80211.GetMessageType(Nl80211Message::kMessageTypeString);
 }
 
-void Callback80211Metrics::Config80211MessageCallback(
-    const NetlinkMessage &message) {
-#if 0  // TODO(wdg): Enable after code arrives from upcoming CL.
+void Callback80211Metrics::CollectDisconnectStatistics(
+    const NetlinkMessage &netlink_message) {
+  if (nl80211_message_type_ == NetlinkMessage::kIllegalMessageType) {
+    LOG(ERROR) << "Somehow, nl80211_message_type_ didn't get set correctly";
+    return;
+  }
+
+  // We only handle deauthenticate messages, which are nl80211 messages.
+  if (netlink_message.message_type() != nl80211_message_type_) {
+    return;
+  }
+  const Nl80211Message &message =
+      * reinterpret_cast<const Nl80211Message *>(&netlink_message);
+
   SLOG(WiFi, 3) << "Received " << message.command_string()
                 << " (" << + message.command() << ")";
   if (metrics_ &&
@@ -33,7 +50,7 @@
         IEEE_80211::kReasonCodeInvalid);
     ByteString rawdata;
     if (message.const_attributes()->GetRawAttributeValue(NL80211_ATTR_FRAME,
-                                                         &rawdata)) {
+                                                          &rawdata)) {
       Nl80211Frame frame(rawdata);
       reason = frame.reason();
     }
@@ -41,7 +58,6 @@
         static_cast<IEEE_80211::WiFiReasonCode>(reason);
     metrics_->Notify80211Disconnect(by_whom, reason_enum);
   }
-#endif  // 0
 }
 
 }  // namespace shill.