Wade Guthrie | 5020b57 | 2012-10-12 15:51:14 -0700 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium OS Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | // This class is a callback object that observes all nl80211 events that come |
| 6 | // up from the kernel. |
| 7 | |
Wade Guthrie | 89e6cb3 | 2013-03-07 08:03:45 -0800 | [diff] [blame] | 8 | #ifndef SHILL_CALLBACK80211_METRICS_H_ |
| 9 | #define SHILL_CALLBACK80211_METRICS_H_ |
Wade Guthrie | 5020b57 | 2012-10-12 15:51:14 -0700 | [diff] [blame] | 10 | |
Wade Guthrie | 5020b57 | 2012-10-12 15:51:14 -0700 | [diff] [blame] | 11 | #include <base/basictypes.h> |
Wade Guthrie | c6c8196 | 2013-03-06 15:47:13 -0800 | [diff] [blame] | 12 | #include <base/memory/weak_ptr.h> |
Wade Guthrie | 5020b57 | 2012-10-12 15:51:14 -0700 | [diff] [blame] | 13 | |
Wade Guthrie | bb9fca2 | 2013-04-10 17:21:42 -0700 | [diff] [blame] | 14 | #include "shill/netlink_manager.h" |
Wade Guthrie | 5020b57 | 2012-10-12 15:51:14 -0700 | [diff] [blame] | 15 | |
| 16 | namespace shill { |
| 17 | |
Wade Guthrie | 5020b57 | 2012-10-12 15:51:14 -0700 | [diff] [blame] | 18 | class Metrics; |
Wade Guthrie | bb9fca2 | 2013-04-10 17:21:42 -0700 | [diff] [blame] | 19 | class NetlinkManager; |
Wade Guthrie | c6c8196 | 2013-03-06 15:47:13 -0800 | [diff] [blame] | 20 | class NetlinkMessage; |
Wade Guthrie | 5020b57 | 2012-10-12 15:51:14 -0700 | [diff] [blame] | 21 | |
Wade Guthrie | bb9fca2 | 2013-04-10 17:21:42 -0700 | [diff] [blame] | 22 | // NetlinkManager callback object that sends stuff to UMA metrics. |
Wade Guthrie | c6c8196 | 2013-03-06 15:47:13 -0800 | [diff] [blame] | 23 | class Callback80211Metrics : |
| 24 | public base::SupportsWeakPtr<Callback80211Metrics> { |
Wade Guthrie | 5020b57 | 2012-10-12 15:51:14 -0700 | [diff] [blame] | 25 | public: |
Wade Guthrie | bb9fca2 | 2013-04-10 17:21:42 -0700 | [diff] [blame] | 26 | Callback80211Metrics(const NetlinkManager &netlink_manager, Metrics *metrics); |
Wade Guthrie | 5020b57 | 2012-10-12 15:51:14 -0700 | [diff] [blame] | 27 | |
Wade Guthrie | c6c8196 | 2013-03-06 15:47:13 -0800 | [diff] [blame] | 28 | // This retrieves the numerical id for the "nl80211" family of messages. |
| 29 | // Should only be called (once) at initialization time but must be called |
Wade Guthrie | bb9fca2 | 2013-04-10 17:21:42 -0700 | [diff] [blame] | 30 | // only after NetlinkManager knows about the "nl80211" family. |
| 31 | void InitNl80211FamilyId(const NetlinkManager &netlink_manager); |
Wade Guthrie | c6c8196 | 2013-03-06 15:47:13 -0800 | [diff] [blame] | 32 | |
Wade Guthrie | bb9fca2 | 2013-04-10 17:21:42 -0700 | [diff] [blame] | 33 | // Called with each broadcast netlink message that arrives to NetlinkManager. |
Wade Guthrie | c6c8196 | 2013-03-06 15:47:13 -0800 | [diff] [blame] | 34 | // If the message is a deauthenticate message, the method collects the reason |
| 35 | // for the deauthentication and communicates those to UMA. |
| 36 | void CollectDisconnectStatistics(const NetlinkMessage &msg); |
Wade Guthrie | 5020b57 | 2012-10-12 15:51:14 -0700 | [diff] [blame] | 37 | |
Christopher Wiley | fe34be0 | 2012-11-12 16:02:46 -0800 | [diff] [blame] | 38 | private: |
Wade Guthrie | 5020b57 | 2012-10-12 15:51:14 -0700 | [diff] [blame] | 39 | static const char kMetricLinkDisconnectCount[]; |
| 40 | |
| 41 | Metrics *metrics_; |
Wade Guthrie | c6c8196 | 2013-03-06 15:47:13 -0800 | [diff] [blame] | 42 | uint16_t nl80211_message_type_; |
Wade Guthrie | 5020b57 | 2012-10-12 15:51:14 -0700 | [diff] [blame] | 43 | |
Wade Guthrie | 5020b57 | 2012-10-12 15:51:14 -0700 | [diff] [blame] | 44 | DISALLOW_COPY_AND_ASSIGN(Callback80211Metrics); |
| 45 | }; |
| 46 | |
| 47 | } // namespace shill |
| 48 | |
Wade Guthrie | 89e6cb3 | 2013-03-07 08:03:45 -0800 | [diff] [blame] | 49 | #endif // SHILL_CALLBACK80211_METRICS_H_ |