Paul Stewart | f0aae10 | 2011-10-19 12:11:44 -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 | #ifndef SHILL_GLIB_IO_READY_HANDLER_ |
| 6 | #define SHILL_GLIB_IO_READY_HANDLER_ |
| 7 | |
| 8 | #include <stdio.h> |
| 9 | #include <glib.h> |
| 10 | |
Eric Shienbrood | 3e20a23 | 2012-02-16 11:35:56 -0500 | [diff] [blame] | 11 | #include <base/callback.h> |
Paul Stewart | f0aae10 | 2011-10-19 12:11:44 -0700 | [diff] [blame] | 12 | |
| 13 | #include "shill/io_handler.h" |
| 14 | |
| 15 | namespace shill { |
| 16 | |
| 17 | // This handler is different from the GlibIOInputHandler |
| 18 | // in that we don't read/write from the file handle and |
| 19 | // leave that to the caller. This is useful in accept()ing |
| 20 | // sockets and effort to working with peripheral libraries. |
| 21 | class GlibIOReadyHandler : public IOHandler { |
| 22 | public: |
Paul Stewart | c2350ee | 2011-10-19 12:28:40 -0700 | [diff] [blame] | 23 | GlibIOReadyHandler(int fd, |
| 24 | IOHandler::ReadyMode mode, |
Eric Shienbrood | 3e20a23 | 2012-02-16 11:35:56 -0500 | [diff] [blame] | 25 | const base::Callback<void(int)> &callback); |
Paul Stewart | f0aae10 | 2011-10-19 12:11:44 -0700 | [diff] [blame] | 26 | ~GlibIOReadyHandler(); |
| 27 | |
| 28 | virtual void Start(); |
| 29 | virtual void Stop(); |
| 30 | |
Eric Shienbrood | 3e20a23 | 2012-02-16 11:35:56 -0500 | [diff] [blame] | 31 | const base::Callback<void(int)> &callback() { return callback_; } |
| 32 | |
Paul Stewart | f0aae10 | 2011-10-19 12:11:44 -0700 | [diff] [blame] | 33 | private: |
| 34 | GIOChannel *channel_; |
| 35 | GIOCondition condition_; |
Eric Shienbrood | 3e20a23 | 2012-02-16 11:35:56 -0500 | [diff] [blame] | 36 | const base::Callback<void(int)> callback_; |
Paul Stewart | f0aae10 | 2011-10-19 12:11:44 -0700 | [diff] [blame] | 37 | guint source_id_; |
| 38 | }; |
| 39 | |
| 40 | |
| 41 | } // namespace shill |
| 42 | |
| 43 | #endif // SHILL_GLIB_IO_READY_HANDLER_ |