shill: Add "IO Ready" handler

For output sockets and for non-traditional "input" events we
need to trigger when an fd is ready, but we don't want GLib
to be in charge of the IO itself.  For this, we create a
"ready handler" which triggers a callback which is passed the
file descriptor which is ready.

BUG=chromium-os:21664
TEST=New unit tests

Change-Id: I4960658e6d0940d8db65ae6f77ff09679b3ef96a
Reviewed-on: http://gerrit.chromium.org/gerrit/10327
Reviewed-by: Darin Petkov <petkov@chromium.org>
Reviewed-by: mukesh agrawal <quiche@chromium.org>
Tested-by: Paul Stewart <pstew@chromium.org>
diff --git a/glib_io_ready_handler.h b/glib_io_ready_handler.h
new file mode 100644
index 0000000..919c8c3
--- /dev/null
+++ b/glib_io_ready_handler.h
@@ -0,0 +1,41 @@
+// Copyright (c) 2011 The Chromium OS Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef SHILL_GLIB_IO_READY_HANDLER_
+#define SHILL_GLIB_IO_READY_HANDLER_
+
+#include <stdio.h>
+#include <glib.h>
+
+#include <base/callback_old.h>
+
+#include "shill/io_handler.h"
+
+namespace shill {
+
+// This handler is different from the GlibIOInputHandler
+// in that we don't read/write from the file handle and
+// leave that to the caller.  This is useful in accept()ing
+// sockets and effort to working with peripheral libraries.
+class GlibIOReadyHandler : public IOHandler {
+ public:
+    GlibIOReadyHandler(int fd,
+                       IOHandler::ReadyMode mode,
+                       Callback1<int>::Type *callback);
+  ~GlibIOReadyHandler();
+
+  virtual void Start();
+  virtual void Stop();
+
+ private:
+  GIOChannel *channel_;
+  GIOCondition condition_;
+  Callback1<int>::Type *callback_;
+  guint source_id_;
+};
+
+
+}  // namespace shill
+
+#endif  // SHILL_GLIB_IO_READY_HANDLER_