blob: 10a8f7d3e7ee00665ffe678ab9b8b6ab632e04c5 [file] [log] [blame]
Paul Stewartf0aae102011-10-19 12:11:44 -07001// 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
Peter Qiu40a01482014-10-31 11:54:23 -07005#ifndef SHILL_GLIB_IO_READY_HANDLER_H_
6#define SHILL_GLIB_IO_READY_HANDLER_H_
Paul Stewartf0aae102011-10-19 12:11:44 -07007
Paul Stewartf0aae102011-10-19 12:11:44 -07008#include <glib.h>
Alex Vakulenkoa41ab512014-07-23 14:24:23 -07009#include <stdio.h>
Paul Stewartf0aae102011-10-19 12:11:44 -070010
Eric Shienbrood3e20a232012-02-16 11:35:56 -050011#include <base/callback.h>
Paul Stewartf0aae102011-10-19 12:11:44 -070012
Peter Qiu8d6b5972014-10-28 15:33:34 -070013#include "shill/net/io_handler.h"
Paul Stewartf0aae102011-10-19 12:11:44 -070014
15namespace 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.
21class GlibIOReadyHandler : public IOHandler {
22 public:
Paul Stewartc2350ee2011-10-19 12:28:40 -070023 GlibIOReadyHandler(int fd,
24 IOHandler::ReadyMode mode,
Paul Stewart8ae18742015-06-16 13:13:10 -070025 const base::Callback<void(int)>& callback);
Paul Stewartf0aae102011-10-19 12:11:44 -070026 ~GlibIOReadyHandler();
27
28 virtual void Start();
29 virtual void Stop();
30
Paul Stewart8ae18742015-06-16 13:13:10 -070031 const base::Callback<void(int)>& callback() { return callback_; }
Eric Shienbrood3e20a232012-02-16 11:35:56 -050032
Paul Stewartf0aae102011-10-19 12:11:44 -070033 private:
Paul Stewart8ae18742015-06-16 13:13:10 -070034 GIOChannel* channel_;
Paul Stewartf0aae102011-10-19 12:11:44 -070035 GIOCondition condition_;
Eric Shienbrood3e20a232012-02-16 11:35:56 -050036 const base::Callback<void(int)> callback_;
Paul Stewartf0aae102011-10-19 12:11:44 -070037 guint source_id_;
38};
39
40
41} // namespace shill
42
Peter Qiu40a01482014-10-31 11:54:23 -070043#endif // SHILL_GLIB_IO_READY_HANDLER_H_