blob: d18e73b65f5bbc770836dacc748dda693eef54b3 [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
Ben Chanc45688b2014-07-02 23:50:45 -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
13#include "shill/io_handler.h"
14
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,
Eric Shienbrood3e20a232012-02-16 11:35:56 -050025 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
Eric Shienbrood3e20a232012-02-16 11:35:56 -050031 const base::Callback<void(int)> &callback() { return callback_; }
32
Paul Stewartf0aae102011-10-19 12:11:44 -070033 private:
34 GIOChannel *channel_;
35 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
Ben Chanc45688b2014-07-02 23:50:45 -070043#endif // SHILL_GLIB_IO_READY_HANDLER_H_