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/. */
6 
7 #include <fcntl.h>
8 #include "UnixFileWatcher.h"
9 
10 namespace mozilla {
11 namespace ipc {
12 
~UnixFileWatcher()13 UnixFileWatcher::~UnixFileWatcher()
14 {
15 }
16 
17 nsresult
Open(const char * aFilename,int aFlags,mode_t aMode)18 UnixFileWatcher::Open(const char* aFilename, int aFlags, mode_t aMode)
19 {
20   MOZ_ASSERT(MessageLoopForIO::current() == GetIOLoop());
21   MOZ_ASSERT(aFlags & O_NONBLOCK);
22 
23   int fd = TEMP_FAILURE_RETRY(open(aFilename, aFlags, aMode));
24   if (fd < 0) {
25     OnError("open", errno);
26     return NS_ERROR_FAILURE;
27   }
28   SetFd(fd);
29   OnOpened();
30 
31   return NS_OK;
32 }
33 
UnixFileWatcher(MessageLoop * aIOLoop)34 UnixFileWatcher::UnixFileWatcher(MessageLoop* aIOLoop)
35 : UnixFdWatcher(aIOLoop)
36 {
37 }
38 
UnixFileWatcher(MessageLoop * aIOLoop,int aFd)39 UnixFileWatcher::UnixFileWatcher(MessageLoop* aIOLoop, int aFd)
40 : UnixFdWatcher(aIOLoop, aFd)
41 {
42 }
43 
44 }
45 }
46