1 // 2 // Copyright (C) 2012 The Android Open Source Project 3 // 4 // Licensed under the Apache License, Version 2.0 (the "License"); 5 // you may not use this file except in compliance with the License. 6 // You may obtain a copy of the License at 7 // 8 // http://www.apache.org/licenses/LICENSE-2.0 9 // 10 // Unless required by applicable law or agreed to in writing, software 11 // distributed under the License is distributed on an "AS IS" BASIS, 12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 // See the License for the specific language governing permissions and 14 // limitations under the License. 15 // 16 17 // This class is a callback object that observes all nl80211 events that come 18 // up from the kernel. 19 20 #ifndef SHILL_WIFI_CALLBACK80211_METRICS_H_ 21 #define SHILL_WIFI_CALLBACK80211_METRICS_H_ 22 23 #include <base/macros.h> 24 #include <base/memory/weak_ptr.h> 25 26 #include "shill/net/ieee80211.h" 27 #include "shill/net/netlink_manager.h" 28 29 namespace shill { 30 31 class Metrics; 32 class NetlinkManager; 33 class NetlinkMessage; 34 35 // NetlinkManager callback object that sends stuff to UMA metrics. 36 class Callback80211Metrics : 37 public base::SupportsWeakPtr<Callback80211Metrics> { 38 public: 39 explicit Callback80211Metrics(Metrics* metrics); 40 41 // Called with each broadcast netlink message that arrives to NetlinkManager. 42 // If the message is a deauthenticate message, the method collects the reason 43 // for the deauthentication and communicates those to UMA. 44 void CollectDisconnectStatistics(const NetlinkMessage& msg); 45 46 private: 47 static const char kMetricLinkDisconnectCount[]; 48 49 IEEE_80211::WiFiReasonCode WiFiReasonCodeFromUint16(uint16_t reason) const; 50 51 Metrics* metrics_; 52 53 DISALLOW_COPY_AND_ASSIGN(Callback80211Metrics); 54 }; 55 56 } // namespace shill 57 58 #endif // SHILL_WIFI_CALLBACK80211_METRICS_H_ 59