1 /* -*- Mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 40 -*- */
2 /* vim: set ts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef mozilla_ipc_UnixFdWatcher_h
8 #define mozilla_ipc_UnixFdWatcher_h
10 #include "base/message_loop.h"
11 #include "mozilla/FileUtils.h"
16 class UnixFdWatcher
: public MessageLoopForIO::Watcher
24 virtual ~UnixFdWatcher();
26 MessageLoop
* GetIOLoop() const
43 void AddWatchers(unsigned long aWatchers
, bool aPersistent
);
44 void RemoveWatchers(unsigned long aWatchers
);
46 // Callback method that's run before closing the file descriptor
47 virtual void OnClose() {};
49 // Callback method that's run on POSIX errors
50 virtual void OnError(const char* aFunction
, int aErrno
);
53 UnixFdWatcher(MessageLoop
* aIOLoop
);
54 UnixFdWatcher(MessageLoop
* aIOLoop
, int aFd
);
58 static bool FdIsNonBlocking(int aFd
);
62 MessageLoopForIO::FileDescriptorWatcher mReadWatcher
;
63 MessageLoopForIO::FileDescriptorWatcher mWriteWatcher
;