1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set sw=2 ts=8 et tw=80 : */
4 /* This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
8 #include "mozilla/net/RemoteOpenFileParent.h"
9 #include "mozilla/unused.h"
12 #if !defined(XP_WIN) && !defined(MOZ_WIDGET_COCOA)
21 RemoteOpenFileParent::ActorDestroy(ActorDestroyReason aWhy
)
23 // Implement me! Bug 1005186
27 RemoteOpenFileParent::OpenSendCloseDelete()
29 #if defined(XP_WIN) || defined(MOZ_WIDGET_COCOA)
30 MOZ_CRASH("OS X and Windows shouldn't be doing IPDL here");
33 // TODO: make this async!
35 FileDescriptor fileDescriptor
;
38 nsresult rv
= mURI
->GetFilePath(path
);
39 NS_WARN_IF_FALSE(NS_SUCCEEDED(rv
), "GetFilePath failed!");
43 if (NS_SUCCEEDED(rv
)) {
44 int fd
= open(path
.get(), O_RDONLY
);
46 printf_stderr("RemoteOpenFileParent: file '%s' was not found!\n",
49 fileDescriptor
= FileDescriptor(fd
);
50 // FileDescriptor does a dup() internally, so we need to close our fd
55 // Sending a potentially invalid file descriptor is just fine.
56 unused
<< Send__delete__(this, fileDescriptor
);
58 // Current process's file descriptor is closed by FileDescriptor destructor.
65 } // namespace mozilla