Paul Stewart | a3c56f9 | 2011-05-26 07:08:52 -0700 | [diff] [blame] | 1 | // Copyright (c) 2011 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 | #include <base/callback_old.h> |
| 6 | |
| 7 | #include "shill/rtnl_listener.h" |
| 8 | #include "shill/rtnl_handler.h" |
| 9 | |
| 10 | namespace shill { |
| 11 | |
| 12 | RTNLListener::RTNLListener(int listen_flags, |
Chris Masone | 2aa9707 | 2011-08-09 17:35:08 -0700 | [diff] [blame] | 13 | Callback1<const RTNLMessage &>::Type *callback) |
Paul Stewart | a3c56f9 | 2011-05-26 07:08:52 -0700 | [diff] [blame] | 14 | : listen_flags_(listen_flags), callback_(callback) { |
| 15 | RTNLHandler::GetInstance()->AddListener(this); |
| 16 | } |
| 17 | |
| 18 | RTNLListener::~RTNLListener() { |
| 19 | RTNLHandler::GetInstance()->RemoveListener(this); |
| 20 | } |
| 21 | |
Chris Masone | 2aa9707 | 2011-08-09 17:35:08 -0700 | [diff] [blame] | 22 | void RTNLListener::NotifyEvent(int type, const RTNLMessage &msg) { |
Paul Stewart | a3c56f9 | 2011-05-26 07:08:52 -0700 | [diff] [blame] | 23 | if ((type & listen_flags_) != 0) |
Chris Masone | 2aa9707 | 2011-08-09 17:35:08 -0700 | [diff] [blame] | 24 | callback_->Run(msg); |
Paul Stewart | a3c56f9 | 2011-05-26 07:08:52 -0700 | [diff] [blame] | 25 | } |
| 26 | |
| 27 | } // namespace shill |