shill: Putting UMA metrics in a separate nl80211 callback.
BUG=chromium-os:35466
TEST=Manual and unit tests.
Change-Id: I908f887a7ff3ce4d0bf33f1096cd61155c20e14a
Reviewed-on: https://gerrit.chromium.org/gerrit/35963
Reviewed-by: Paul Stewart <pstew@chromium.org>
Commit-Ready: Wade Guthrie <wdg@google.com>
Tested-by: Wade Guthrie <wdg@google.com>
diff --git a/callback80211_metrics.h b/callback80211_metrics.h
new file mode 100644
index 0000000..14c7080
--- /dev/null
+++ b/callback80211_metrics.h
@@ -0,0 +1,53 @@
+// Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// This class is a callback object that observes all nl80211 events that come
+// up from the kernel.
+
+#ifndef SHILL_CALLBACK80211_METRICS_H
+#define SHILL_CALLBACK80211_METRICS_H
+
+#include <iomanip>
+#include <map>
+#include <string>
+
+#include <base/basictypes.h>
+#include <base/bind.h>
+#include <base/memory/weak_ptr.h>
+
+#include "shill/callback80211_object.h"
+
+namespace shill {
+
+class Config80211;
+class Metrics;
+class UserBoundNlMessage;
+
+// Config80211 callback object that sends stuff to UMA metrics.
+class Callback80211Metrics : public Callback80211Object {
+ public:
+ Callback80211Metrics(Config80211 *config80211, Metrics *metrics);
+
+ // Install ourselves as a callback. Done automatically by constructor.
+ virtual bool InstallAsDefaultCallback();
+
+ private:
+ // When installed, this is the method Config80211 will call when it gets a
+ // message from the mac80211 drivers.
+ virtual void Config80211MessageCallback(const UserBoundNlMessage &msg);
+
+ static const char kMetricLinkDisconnectCount[];
+
+ Metrics *metrics_;
+
+ // Config80211MessageCallback method bound to this object to install as a
+ // callback.
+ base::WeakPtrFactory<Callback80211Metrics> weak_ptr_factory_;
+
+ DISALLOW_COPY_AND_ASSIGN(Callback80211Metrics);
+};
+
+} // namespace shill
+
+#endif // SHILL_CALLBACK80211_METRICS_H