netwerk/ipc/RemoteOpenFileChild.cpp

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/netwerk/ipc/RemoteOpenFileChild.cpp	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,800 @@
     1.4 +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     1.5 +/* vim: set sw=2 ts=8 et tw=80 : */
     1.6 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.7 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.8 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.9 +
    1.10 +#include "RemoteOpenFileChild.h"
    1.11 +
    1.12 +#include "mozilla/unused.h"
    1.13 +#include "mozilla/ipc/FileDescriptor.h"
    1.14 +#include "mozilla/ipc/FileDescriptorUtils.h"
    1.15 +#include "mozilla/ipc/URIUtils.h"
    1.16 +#include "mozilla/net/NeckoChild.h"
    1.17 +#include "nsThreadUtils.h"
    1.18 +#include "nsJARProtocolHandler.h"
    1.19 +#include "nsIRemoteOpenFileListener.h"
    1.20 +#include "nsProxyRelease.h"
    1.21 +
    1.22 +// needed to alloc/free NSPR file descriptors
    1.23 +#include "private/pprio.h"
    1.24 +
    1.25 +using namespace mozilla::ipc;
    1.26 +
    1.27 +namespace mozilla {
    1.28 +namespace net {
    1.29 +
    1.30 +//-----------------------------------------------------------------------------
    1.31 +// Helper class to dispatch events async on windows/OSX
    1.32 +//-----------------------------------------------------------------------------
    1.33 +
    1.34 +class CallsListenerInNewEvent : public nsRunnable
    1.35 +{
    1.36 +public:
    1.37 +    CallsListenerInNewEvent(nsIRemoteOpenFileListener *aListener, nsresult aRv)
    1.38 +      : mListener(aListener), mRV(aRv)
    1.39 +    {
    1.40 +        MOZ_ASSERT(NS_IsMainThread());
    1.41 +        MOZ_ASSERT(aListener);
    1.42 +    }
    1.43 +
    1.44 +    void Dispatch()
    1.45 +    {
    1.46 +        MOZ_ASSERT(NS_IsMainThread());
    1.47 +
    1.48 +        nsresult rv = NS_DispatchToCurrentThread(this);
    1.49 +        NS_ENSURE_SUCCESS_VOID(rv);
    1.50 +    }
    1.51 +
    1.52 +private:
    1.53 +    NS_IMETHOD Run()
    1.54 +    {
    1.55 +        MOZ_ASSERT(NS_IsMainThread());
    1.56 +        MOZ_ASSERT(mListener);
    1.57 +
    1.58 +        mListener->OnRemoteFileOpenComplete(mRV);
    1.59 +        return NS_OK;
    1.60 +    }
    1.61 +
    1.62 +    nsCOMPtr<nsIRemoteOpenFileListener> mListener;
    1.63 +    nsresult mRV;
    1.64 +};
    1.65 +
    1.66 +//-----------------------------------------------------------------------------
    1.67 +// RemoteOpenFileChild
    1.68 +//-----------------------------------------------------------------------------
    1.69 +
    1.70 +NS_IMPL_ISUPPORTS(RemoteOpenFileChild,
    1.71 +                  nsIFile,
    1.72 +                  nsIHashable,
    1.73 +                  nsICachedFileDescriptorListener)
    1.74 +
    1.75 +RemoteOpenFileChild::RemoteOpenFileChild(const RemoteOpenFileChild& other)
    1.76 +  : mTabChild(other.mTabChild)
    1.77 +  , mNSPRFileDesc(other.mNSPRFileDesc)
    1.78 +  , mAsyncOpenCalled(other.mAsyncOpenCalled)
    1.79 +  , mNSPROpenCalled(other.mNSPROpenCalled)
    1.80 +{
    1.81 +  // Note: don't clone mListener or we'll have a refcount leak.
    1.82 +  other.mURI->Clone(getter_AddRefs(mURI));
    1.83 +  if (other.mAppURI) {
    1.84 +    other.mAppURI->Clone(getter_AddRefs(mAppURI));
    1.85 +  }
    1.86 +  other.mFile->Clone(getter_AddRefs(mFile));
    1.87 +}
    1.88 +
    1.89 +RemoteOpenFileChild::~RemoteOpenFileChild()
    1.90 +{
    1.91 +  if (NS_IsMainThread()) {
    1.92 +    if (mListener) {
    1.93 +      NotifyListener(NS_ERROR_UNEXPECTED);
    1.94 +    }
    1.95 +  } else {
    1.96 +    nsCOMPtr<nsIThread> mainThread = do_GetMainThread();
    1.97 +    if (mainThread) {
    1.98 +      MOZ_ALWAYS_TRUE(NS_SUCCEEDED(NS_ProxyRelease(mainThread, mURI, true)));
    1.99 +      MOZ_ALWAYS_TRUE(NS_SUCCEEDED(NS_ProxyRelease(mainThread, mAppURI, true)));
   1.100 +      MOZ_ALWAYS_TRUE(NS_SUCCEEDED(NS_ProxyRelease(mainThread, mListener,
   1.101 +                                                   true)));
   1.102 +
   1.103 +      TabChild* tabChild;
   1.104 +      mTabChild.forget(&tabChild);
   1.105 +
   1.106 +      if (tabChild) {
   1.107 +        nsCOMPtr<nsIRunnable> runnable =
   1.108 +          NS_NewNonOwningRunnableMethod(tabChild, &TabChild::Release);
   1.109 +        MOZ_ASSERT(runnable);
   1.110 +
   1.111 +        MOZ_ALWAYS_TRUE(NS_SUCCEEDED(mainThread->Dispatch(runnable,
   1.112 +                                                          NS_DISPATCH_NORMAL)));
   1.113 +      }
   1.114 +    } else {
   1.115 +      using mozilla::unused;
   1.116 +
   1.117 +      NS_WARNING("RemoteOpenFileChild released after thread shutdown, leaking "
   1.118 +                 "its members!");
   1.119 +
   1.120 +      unused << mURI.forget();
   1.121 +      unused << mAppURI.forget();
   1.122 +      unused << mListener.forget();
   1.123 +      unused << mTabChild.forget();
   1.124 +    }
   1.125 +  }
   1.126 +
   1.127 +  if (mNSPRFileDesc) {
   1.128 +    // If we handed out fd we shouldn't have pointer to it any more.
   1.129 +    MOZ_ASSERT(!mNSPROpenCalled);
   1.130 +    // PR_Close both closes the file and deallocates the PRFileDesc
   1.131 +    PR_Close(mNSPRFileDesc);
   1.132 +  }
   1.133 +}
   1.134 +
   1.135 +nsresult
   1.136 +RemoteOpenFileChild::Init(nsIURI* aRemoteOpenUri, nsIURI* aAppUri)
   1.137 +{
   1.138 +  if (!aRemoteOpenUri) {
   1.139 +    return NS_ERROR_INVALID_ARG;
   1.140 +  }
   1.141 +
   1.142 +  if (aAppUri) {
   1.143 +    aAppUri->Clone(getter_AddRefs(mAppURI));
   1.144 +  }
   1.145 +
   1.146 +  nsAutoCString scheme;
   1.147 +  nsresult rv = aRemoteOpenUri->GetScheme(scheme);
   1.148 +  NS_ENSURE_SUCCESS(rv, rv);
   1.149 +
   1.150 +  if (!scheme.EqualsLiteral("remoteopenfile")) {
   1.151 +    return NS_ERROR_INVALID_ARG;
   1.152 +  }
   1.153 +
   1.154 +  // scheme of URI is not file:// so this is not a nsIFileURL.  Convert to one.
   1.155 +  nsCOMPtr<nsIURI> clonedURI;
   1.156 +  rv = aRemoteOpenUri->Clone(getter_AddRefs(clonedURI));
   1.157 +  NS_ENSURE_SUCCESS(rv, rv);
   1.158 +
   1.159 +  clonedURI->SetScheme(NS_LITERAL_CSTRING("file"));
   1.160 +  nsAutoCString spec;
   1.161 +  clonedURI->GetSpec(spec);
   1.162 +
   1.163 +  rv = NS_NewURI(getter_AddRefs(mURI), spec);
   1.164 +  NS_ENSURE_SUCCESS(rv, rv);
   1.165 +
   1.166 +  // Get nsIFile
   1.167 +  nsCOMPtr<nsIFileURL> fileURL = do_QueryInterface(mURI);
   1.168 +  if (!fileURL) {
   1.169 +    return NS_ERROR_UNEXPECTED;
   1.170 +  }
   1.171 +
   1.172 +  rv = fileURL->GetFile(getter_AddRefs(mFile));
   1.173 +  NS_ENSURE_SUCCESS(rv, rv);
   1.174 +
   1.175 +  return NS_OK;
   1.176 +}
   1.177 +
   1.178 +nsresult
   1.179 +RemoteOpenFileChild::AsyncRemoteFileOpen(int32_t aFlags,
   1.180 +                                         nsIRemoteOpenFileListener* aListener,
   1.181 +                                         nsITabChild* aTabChild)
   1.182 +{
   1.183 +  if (!mFile) {
   1.184 +    return NS_ERROR_NOT_INITIALIZED;
   1.185 +  }
   1.186 +
   1.187 +  if (!aListener) {
   1.188 +    return NS_ERROR_INVALID_ARG;
   1.189 +  }
   1.190 +
   1.191 +  if (mAsyncOpenCalled) {
   1.192 +    return NS_ERROR_ALREADY_OPENED;
   1.193 +  }
   1.194 +
   1.195 +  if (aFlags != PR_RDONLY) {
   1.196 +    return NS_ERROR_NOT_AVAILABLE;
   1.197 +  }
   1.198 +
   1.199 +  mTabChild = static_cast<TabChild*>(aTabChild);
   1.200 +
   1.201 +  if (MissingRequiredTabChild(mTabChild, "remoteopenfile")) {
   1.202 +    return NS_ERROR_ILLEGAL_VALUE;
   1.203 +  }
   1.204 +
   1.205 +#if defined(XP_WIN) || defined(MOZ_WIDGET_COCOA)
   1.206 +  // Windows/OSX desktop builds skip remoting, and just open file in child
   1.207 +  // process when asked for NSPR handle
   1.208 +  nsRefPtr<CallsListenerInNewEvent> runnable =
   1.209 +    new CallsListenerInNewEvent(aListener, NS_OK);
   1.210 +  runnable->Dispatch();
   1.211 +
   1.212 +  mAsyncOpenCalled = true;
   1.213 +  return NS_OK;
   1.214 +#else
   1.215 +  nsString path;
   1.216 +  if (NS_FAILED(mFile->GetPath(path))) {
   1.217 +    MOZ_CRASH("Couldn't get path from file!");
   1.218 +  }
   1.219 +
   1.220 +  if (mTabChild) {
   1.221 +    if (mTabChild->GetCachedFileDescriptor(path, this)) {
   1.222 +      // The file descriptor was found in the cache and OnCachedFileDescriptor()
   1.223 +      // will be called with it.
   1.224 +      return NS_OK;
   1.225 +    }
   1.226 +  }
   1.227 +
   1.228 +  URIParams uri;
   1.229 +  SerializeURI(mURI, uri);
   1.230 +  OptionalURIParams appUri;
   1.231 +  SerializeURI(mAppURI, appUri);
   1.232 +
   1.233 +  gNeckoChild->SendPRemoteOpenFileConstructor(this, uri, appUri);
   1.234 +
   1.235 +  // The chrome process now has a logical ref to us until it calls Send__delete.
   1.236 +  AddIPDLReference();
   1.237 +
   1.238 +  mListener = aListener;
   1.239 +  mAsyncOpenCalled = true;
   1.240 +  return NS_OK;
   1.241 +#endif
   1.242 +}
   1.243 +
   1.244 +void
   1.245 +RemoteOpenFileChild::OnCachedFileDescriptor(const nsAString& aPath,
   1.246 +                                            const FileDescriptor& aFD)
   1.247 +{
   1.248 +#ifdef DEBUG
   1.249 +  if (!aPath.IsEmpty()) {
   1.250 +    MOZ_ASSERT(mFile);
   1.251 +
   1.252 +    nsString path;
   1.253 +    MOZ_ASSERT(NS_SUCCEEDED(mFile->GetPath(path)));
   1.254 +    MOZ_ASSERT(path == aPath, "Paths don't match!");
   1.255 +  }
   1.256 +#endif
   1.257 +
   1.258 +  HandleFileDescriptorAndNotifyListener(aFD, /* aFromRecvDelete */ false);
   1.259 +}
   1.260 +
   1.261 +void
   1.262 +RemoteOpenFileChild::HandleFileDescriptorAndNotifyListener(
   1.263 +                                                      const FileDescriptor& aFD,
   1.264 +                                                      bool aFromRecvDelete)
   1.265 +{
   1.266 +#if defined(XP_WIN) || defined(MOZ_WIDGET_COCOA)
   1.267 +  MOZ_CRASH("OS X and Windows shouldn't be doing IPDL here");
   1.268 +#else
   1.269 +  if (!mListener) {
   1.270 +    // We already notified our listener (either in response to a cached file
   1.271 +    // descriptor callback or through the normal messaging mechanism). Close the
   1.272 +    // file descriptor if it is valid.
   1.273 +    if (aFD.IsValid()) {
   1.274 +      nsRefPtr<CloseFileRunnable> runnable = new CloseFileRunnable(aFD);
   1.275 +      runnable->Dispatch();
   1.276 +    }
   1.277 +    return;
   1.278 +  }
   1.279 +
   1.280 +  MOZ_ASSERT(!mNSPRFileDesc);
   1.281 +
   1.282 +  nsRefPtr<TabChild> tabChild;
   1.283 +  mTabChild.swap(tabChild);
   1.284 +
   1.285 +  // If RemoteOpenFile reply (Recv__delete__) for app's application.zip comes
   1.286 +  // back sooner than the parent-pushed fd (TabChild::RecvCacheFileDescriptor())
   1.287 +  // have TabChild cancel running callbacks, since we'll call them in
   1.288 +  // NotifyListener.
   1.289 +  if (tabChild && aFromRecvDelete) {
   1.290 +    nsString path;
   1.291 +    if (NS_FAILED(mFile->GetPath(path))) {
   1.292 +      MOZ_CRASH("Couldn't get path from file!");
   1.293 +    }
   1.294 +
   1.295 +    tabChild->CancelCachedFileDescriptorCallback(path, this);
   1.296 +  }
   1.297 +
   1.298 +  if (aFD.IsValid()) {
   1.299 +    mNSPRFileDesc = PR_ImportFile(aFD.PlatformHandle());
   1.300 +    if (!mNSPRFileDesc) {
   1.301 +      NS_WARNING("Failed to import file handle!");
   1.302 +    }
   1.303 +  }
   1.304 +
   1.305 +  NotifyListener(mNSPRFileDesc ? NS_OK : NS_ERROR_FILE_NOT_FOUND);
   1.306 +#endif
   1.307 +}
   1.308 +
   1.309 +void
   1.310 +RemoteOpenFileChild::NotifyListener(nsresult aResult)
   1.311 +{
   1.312 +  MOZ_ASSERT(mListener);
   1.313 +  mListener->OnRemoteFileOpenComplete(aResult);
   1.314 +  mListener = nullptr;     // release ref to listener
   1.315 +
   1.316 +  nsRefPtr<nsJARProtocolHandler> handler(gJarHandler);
   1.317 +  NS_WARN_IF_FALSE(handler, "nsJARProtocolHandler is already gone!");
   1.318 +
   1.319 +  if (handler) {
   1.320 +    handler->RemoteOpenFileComplete(this, aResult);
   1.321 +  }
   1.322 +}
   1.323 +
   1.324 +//-----------------------------------------------------------------------------
   1.325 +// RemoteOpenFileChild::PRemoteOpenFileChild
   1.326 +//-----------------------------------------------------------------------------
   1.327 +
   1.328 +bool
   1.329 +RemoteOpenFileChild::Recv__delete__(const FileDescriptor& aFD)
   1.330 +{
   1.331 +#if defined(XP_WIN) || defined(MOZ_WIDGET_COCOA)
   1.332 +  NS_NOTREACHED("OS X and Windows shouldn't be doing IPDL here");
   1.333 +#else
   1.334 +  HandleFileDescriptorAndNotifyListener(aFD, /* aFromRecvDelete */ true);
   1.335 +#endif
   1.336 +
   1.337 +  return true;
   1.338 +}
   1.339 +
   1.340 +//-----------------------------------------------------------------------------
   1.341 +// RemoteOpenFileChild::nsIFile functions that we override logic for
   1.342 +//-----------------------------------------------------------------------------
   1.343 +
   1.344 +NS_IMETHODIMP
   1.345 +RemoteOpenFileChild::Clone(nsIFile **file)
   1.346 +{
   1.347 +  *file = new RemoteOpenFileChild(*this);
   1.348 +  NS_ADDREF(*file);
   1.349 +
   1.350 +  // if we transferred ownership of file to clone, forget our pointer.
   1.351 +  if (mNSPRFileDesc) {
   1.352 +    mNSPRFileDesc = nullptr;
   1.353 +  }
   1.354 +
   1.355 +  return NS_OK;
   1.356 +}
   1.357 +
   1.358 +/* The main event: get file descriptor from parent process
   1.359 + */
   1.360 +NS_IMETHODIMP
   1.361 +RemoteOpenFileChild::OpenNSPRFileDesc(int32_t aFlags, int32_t aMode,
   1.362 +                                      PRFileDesc **aRetval)
   1.363 +{
   1.364 +#if defined(XP_WIN) || defined(MOZ_WIDGET_COCOA)
   1.365 +  // Windows and OSX builds: just open nsIFile locally.
   1.366 +  return mFile->OpenNSPRFileDesc(aFlags, aMode, aRetval);
   1.367 +
   1.368 +#else
   1.369 +  if (aFlags != PR_RDONLY) {
   1.370 +    return NS_ERROR_NOT_AVAILABLE;
   1.371 +  }
   1.372 +
   1.373 +  // Unlike regular nsIFile we can't (easily) support multiple open()s.
   1.374 +  if (mNSPROpenCalled) {
   1.375 +    return NS_ERROR_ALREADY_OPENED;
   1.376 +  }
   1.377 +
   1.378 +  if (!mNSPRFileDesc) {
   1.379 +    // client skipped AsyncRemoteFileOpen() or didn't wait for result, or this
   1.380 +    // object has been cloned
   1.381 +    return NS_ERROR_NOT_AVAILABLE;
   1.382 +  }
   1.383 +
   1.384 +  // hand off ownership (i.e responsibility to PR_Close() file handle) to caller
   1.385 +  *aRetval = mNSPRFileDesc;
   1.386 +  mNSPRFileDesc = nullptr;
   1.387 +  mNSPROpenCalled = true;
   1.388 +
   1.389 +  return NS_OK;
   1.390 +#endif
   1.391 +}
   1.392 +
   1.393 +
   1.394 +//-----------------------------------------------------------------------------
   1.395 +// RemoteOpenFileChild::nsIFile functions that we delegate to underlying nsIFile
   1.396 +//-----------------------------------------------------------------------------
   1.397 +
   1.398 +nsresult
   1.399 +RemoteOpenFileChild::GetLeafName(nsAString &aLeafName)
   1.400 +{
   1.401 +  return mFile->GetLeafName(aLeafName);
   1.402 +}
   1.403 +
   1.404 +NS_IMETHODIMP
   1.405 +RemoteOpenFileChild::GetNativeLeafName(nsACString &aLeafName)
   1.406 +{
   1.407 +  return mFile->GetNativeLeafName(aLeafName);
   1.408 +}
   1.409 +
   1.410 +nsresult
   1.411 +RemoteOpenFileChild::GetTarget(nsAString &_retval)
   1.412 +{
   1.413 +  return mFile->GetTarget(_retval);
   1.414 +}
   1.415 +
   1.416 +NS_IMETHODIMP
   1.417 +RemoteOpenFileChild::GetNativeTarget(nsACString &_retval)
   1.418 +{
   1.419 +  return mFile->GetNativeTarget(_retval);
   1.420 +}
   1.421 +
   1.422 +nsresult
   1.423 +RemoteOpenFileChild::GetPath(nsAString &_retval)
   1.424 +{
   1.425 +  return mFile->GetPath(_retval);
   1.426 +}
   1.427 +
   1.428 +NS_IMETHODIMP
   1.429 +RemoteOpenFileChild::GetNativePath(nsACString &_retval)
   1.430 +{
   1.431 +  return mFile->GetNativePath(_retval);
   1.432 +}
   1.433 +
   1.434 +NS_IMETHODIMP
   1.435 +RemoteOpenFileChild::Equals(nsIFile *inFile, bool *_retval)
   1.436 +{
   1.437 +  return mFile->Equals(inFile, _retval);
   1.438 +}
   1.439 +
   1.440 +NS_IMETHODIMP
   1.441 +RemoteOpenFileChild::Contains(nsIFile *inFile, bool recur, bool *_retval)
   1.442 +{
   1.443 +  return mFile->Contains(inFile, recur, _retval);
   1.444 +}
   1.445 +
   1.446 +NS_IMETHODIMP
   1.447 +RemoteOpenFileChild::GetParent(nsIFile **aParent)
   1.448 +{
   1.449 +  return mFile->GetParent(aParent);
   1.450 +}
   1.451 +
   1.452 +NS_IMETHODIMP
   1.453 +RemoteOpenFileChild::GetFollowLinks(bool *aFollowLinks)
   1.454 +{
   1.455 +  return mFile->GetFollowLinks(aFollowLinks);
   1.456 +}
   1.457 +
   1.458 +//-----------------------------------------------------------------------------
   1.459 +// RemoteOpenFileChild::nsIFile functions that are not currently supported
   1.460 +//-----------------------------------------------------------------------------
   1.461 +
   1.462 +nsresult
   1.463 +RemoteOpenFileChild::Append(const nsAString &node)
   1.464 +{
   1.465 +  return NS_ERROR_NOT_IMPLEMENTED;
   1.466 +}
   1.467 +
   1.468 +NS_IMETHODIMP
   1.469 +RemoteOpenFileChild::AppendNative(const nsACString &fragment)
   1.470 +{
   1.471 +  return NS_ERROR_NOT_IMPLEMENTED;
   1.472 +}
   1.473 +
   1.474 +NS_IMETHODIMP
   1.475 +RemoteOpenFileChild::Normalize()
   1.476 +{
   1.477 +  return NS_ERROR_NOT_IMPLEMENTED;
   1.478 +}
   1.479 +
   1.480 +NS_IMETHODIMP
   1.481 +RemoteOpenFileChild::Create(uint32_t type, uint32_t permissions)
   1.482 +{
   1.483 +  return NS_ERROR_NOT_IMPLEMENTED;
   1.484 +}
   1.485 +
   1.486 +nsresult
   1.487 +RemoteOpenFileChild::SetLeafName(const nsAString &aLeafName)
   1.488 +{
   1.489 +  return NS_ERROR_NOT_IMPLEMENTED;
   1.490 +}
   1.491 +
   1.492 +NS_IMETHODIMP
   1.493 +RemoteOpenFileChild::SetNativeLeafName(const nsACString &aLeafName)
   1.494 +{
   1.495 +  return NS_ERROR_NOT_IMPLEMENTED;
   1.496 +}
   1.497 +
   1.498 +nsresult
   1.499 +RemoteOpenFileChild::InitWithPath(const nsAString &filePath)
   1.500 +{
   1.501 +  return NS_ERROR_NOT_IMPLEMENTED;
   1.502 +}
   1.503 +
   1.504 +NS_IMETHODIMP
   1.505 +RemoteOpenFileChild::InitWithNativePath(const nsACString &filePath)
   1.506 +{
   1.507 +  return NS_ERROR_NOT_IMPLEMENTED;
   1.508 +}
   1.509 +
   1.510 +NS_IMETHODIMP
   1.511 +RemoteOpenFileChild::InitWithFile(nsIFile *aFile)
   1.512 +{
   1.513 +  return NS_ERROR_NOT_IMPLEMENTED;
   1.514 +}
   1.515 +
   1.516 +NS_IMETHODIMP
   1.517 +RemoteOpenFileChild::SetFollowLinks(bool aFollowLinks)
   1.518 +{
   1.519 +  return NS_ERROR_NOT_IMPLEMENTED;
   1.520 +}
   1.521 +
   1.522 +nsresult  
   1.523 +RemoteOpenFileChild::AppendRelativePath(const nsAString &node)
   1.524 +{
   1.525 +  return NS_ERROR_NOT_IMPLEMENTED;
   1.526 +}
   1.527 +
   1.528 +NS_IMETHODIMP
   1.529 +RemoteOpenFileChild::AppendRelativeNativePath(const nsACString &fragment)
   1.530 +{
   1.531 +  return NS_ERROR_NOT_IMPLEMENTED;
   1.532 +}
   1.533 +
   1.534 +NS_IMETHODIMP
   1.535 +RemoteOpenFileChild::GetPersistentDescriptor(nsACString &aPersistentDescriptor)
   1.536 +{
   1.537 +  return NS_ERROR_NOT_IMPLEMENTED;
   1.538 +}
   1.539 +
   1.540 +NS_IMETHODIMP
   1.541 +RemoteOpenFileChild::SetPersistentDescriptor(const nsACString &aPersistentDescriptor)
   1.542 +{
   1.543 +  return NS_ERROR_NOT_IMPLEMENTED;
   1.544 +}
   1.545 +
   1.546 +NS_IMETHODIMP
   1.547 +RemoteOpenFileChild::GetRelativeDescriptor(nsIFile *fromFile, nsACString& _retval)
   1.548 +{
   1.549 +  return NS_ERROR_NOT_IMPLEMENTED;
   1.550 +}
   1.551 +
   1.552 +NS_IMETHODIMP
   1.553 +RemoteOpenFileChild::SetRelativeDescriptor(nsIFile *fromFile,
   1.554 +                                   const nsACString& relativeDesc)
   1.555 +{
   1.556 +  return NS_ERROR_NOT_IMPLEMENTED;
   1.557 +}
   1.558 +
   1.559 +nsresult
   1.560 +RemoteOpenFileChild::CopyTo(nsIFile *newParentDir, const nsAString &newName)
   1.561 +{
   1.562 +  return NS_ERROR_NOT_IMPLEMENTED;
   1.563 +}
   1.564 +
   1.565 +NS_IMETHODIMP
   1.566 +RemoteOpenFileChild::CopyToNative(nsIFile *newParent, const nsACString &newName)
   1.567 +{
   1.568 +  return NS_ERROR_NOT_IMPLEMENTED;
   1.569 +}
   1.570 +
   1.571 +nsresult
   1.572 +RemoteOpenFileChild::CopyToFollowingLinks(nsIFile *newParentDir,
   1.573 +                                  const nsAString &newName)
   1.574 +{
   1.575 +  return NS_ERROR_NOT_IMPLEMENTED;
   1.576 +}
   1.577 +
   1.578 +NS_IMETHODIMP
   1.579 +RemoteOpenFileChild::CopyToFollowingLinksNative(nsIFile *newParent,
   1.580 +                                        const nsACString &newName)
   1.581 +{
   1.582 +  return NS_ERROR_NOT_IMPLEMENTED;
   1.583 +}
   1.584 +
   1.585 +nsresult
   1.586 +RemoteOpenFileChild::MoveTo(nsIFile *newParentDir, const nsAString &newName)
   1.587 +{
   1.588 +  return NS_ERROR_NOT_IMPLEMENTED;
   1.589 +}
   1.590 +
   1.591 +NS_IMETHODIMP
   1.592 +RemoteOpenFileChild::MoveToNative(nsIFile *newParent, const nsACString &newName)
   1.593 +{
   1.594 +  return NS_ERROR_NOT_IMPLEMENTED;
   1.595 +}
   1.596 +
   1.597 +NS_IMETHODIMP
   1.598 +RemoteOpenFileChild::RenameTo(nsIFile *newParentDir, const nsAString &newName)
   1.599 +{
   1.600 +  return NS_ERROR_NOT_IMPLEMENTED;
   1.601 +}
   1.602 +
   1.603 +NS_IMETHODIMP
   1.604 +RemoteOpenFileChild::Remove(bool recursive)
   1.605 +{
   1.606 +  return NS_ERROR_NOT_IMPLEMENTED;
   1.607 +}
   1.608 +
   1.609 +NS_IMETHODIMP
   1.610 +RemoteOpenFileChild::GetPermissions(uint32_t *aPermissions)
   1.611 +{
   1.612 +  return NS_ERROR_NOT_IMPLEMENTED;
   1.613 +}
   1.614 +
   1.615 +NS_IMETHODIMP
   1.616 +RemoteOpenFileChild::SetPermissions(uint32_t aPermissions)
   1.617 +{
   1.618 +  return NS_ERROR_NOT_IMPLEMENTED;
   1.619 +}
   1.620 +
   1.621 +NS_IMETHODIMP
   1.622 +RemoteOpenFileChild::GetPermissionsOfLink(uint32_t *aPermissionsOfLink)
   1.623 +{
   1.624 +  return NS_ERROR_NOT_IMPLEMENTED;
   1.625 +}
   1.626 +
   1.627 +NS_IMETHODIMP
   1.628 +RemoteOpenFileChild::SetPermissionsOfLink(uint32_t aPermissions)
   1.629 +{
   1.630 +  return NS_ERROR_NOT_IMPLEMENTED;
   1.631 +}
   1.632 +
   1.633 +NS_IMETHODIMP
   1.634 +RemoteOpenFileChild::GetLastModifiedTime(PRTime *aLastModTime)
   1.635 +{
   1.636 +  return NS_ERROR_NOT_IMPLEMENTED;
   1.637 +}
   1.638 +
   1.639 +NS_IMETHODIMP
   1.640 +RemoteOpenFileChild::SetLastModifiedTime(PRTime aLastModTime)
   1.641 +{
   1.642 +  return NS_ERROR_NOT_IMPLEMENTED;
   1.643 +}
   1.644 +
   1.645 +NS_IMETHODIMP
   1.646 +RemoteOpenFileChild::GetLastModifiedTimeOfLink(PRTime *aLastModTimeOfLink)
   1.647 +{
   1.648 +  return NS_ERROR_NOT_IMPLEMENTED;
   1.649 +}
   1.650 +
   1.651 +NS_IMETHODIMP
   1.652 +RemoteOpenFileChild::SetLastModifiedTimeOfLink(PRTime aLastModTimeOfLink)
   1.653 +{
   1.654 +  return NS_ERROR_NOT_IMPLEMENTED;
   1.655 +}
   1.656 +
   1.657 +NS_IMETHODIMP
   1.658 +RemoteOpenFileChild::GetFileSize(int64_t *aFileSize)
   1.659 +{
   1.660 +  return NS_ERROR_NOT_IMPLEMENTED;
   1.661 +}
   1.662 +
   1.663 +NS_IMETHODIMP
   1.664 +RemoteOpenFileChild::SetFileSize(int64_t aFileSize)
   1.665 +{
   1.666 +  return NS_ERROR_NOT_IMPLEMENTED;
   1.667 +}
   1.668 +
   1.669 +NS_IMETHODIMP
   1.670 +RemoteOpenFileChild::GetFileSizeOfLink(int64_t *aFileSize)
   1.671 +{
   1.672 +  return NS_ERROR_NOT_IMPLEMENTED;
   1.673 +}
   1.674 +
   1.675 +NS_IMETHODIMP
   1.676 +RemoteOpenFileChild::Exists(bool *_retval)
   1.677 +{
   1.678 +  return NS_ERROR_NOT_IMPLEMENTED;
   1.679 +}
   1.680 +
   1.681 +NS_IMETHODIMP
   1.682 +RemoteOpenFileChild::IsWritable(bool *_retval)
   1.683 +{
   1.684 +  return NS_ERROR_NOT_IMPLEMENTED;
   1.685 +}
   1.686 +
   1.687 +NS_IMETHODIMP
   1.688 +RemoteOpenFileChild::IsReadable(bool *_retval)
   1.689 +{
   1.690 +  return NS_ERROR_NOT_IMPLEMENTED;
   1.691 +}
   1.692 +
   1.693 +NS_IMETHODIMP
   1.694 +RemoteOpenFileChild::IsExecutable(bool *_retval)
   1.695 +{
   1.696 +  return NS_ERROR_NOT_IMPLEMENTED;
   1.697 +}
   1.698 +
   1.699 +NS_IMETHODIMP
   1.700 +RemoteOpenFileChild::IsHidden(bool *_retval)
   1.701 +{
   1.702 +  return NS_ERROR_NOT_IMPLEMENTED;
   1.703 +}
   1.704 +
   1.705 +NS_IMETHODIMP
   1.706 +RemoteOpenFileChild::IsDirectory(bool *_retval)
   1.707 +{
   1.708 +  return NS_ERROR_NOT_IMPLEMENTED;
   1.709 +}
   1.710 +
   1.711 +NS_IMETHODIMP
   1.712 +RemoteOpenFileChild::IsFile(bool *_retval)
   1.713 +{
   1.714 +  return NS_ERROR_NOT_IMPLEMENTED;
   1.715 +}
   1.716 +
   1.717 +NS_IMETHODIMP
   1.718 +RemoteOpenFileChild::IsSymlink(bool *_retval)
   1.719 +{
   1.720 +  return NS_ERROR_NOT_IMPLEMENTED;
   1.721 +}
   1.722 +
   1.723 +NS_IMETHODIMP
   1.724 +RemoteOpenFileChild::IsSpecial(bool *_retval)
   1.725 +{
   1.726 +  return NS_ERROR_NOT_IMPLEMENTED;
   1.727 +}
   1.728 +
   1.729 +NS_IMETHODIMP
   1.730 +RemoteOpenFileChild::CreateUnique(uint32_t type, uint32_t attributes)
   1.731 +{
   1.732 +  return NS_ERROR_NOT_IMPLEMENTED;
   1.733 +}
   1.734 +
   1.735 +NS_IMETHODIMP
   1.736 +RemoteOpenFileChild::GetDirectoryEntries(nsISimpleEnumerator **entries)
   1.737 +{
   1.738 +  return NS_ERROR_NOT_IMPLEMENTED;
   1.739 +}
   1.740 +
   1.741 +NS_IMETHODIMP
   1.742 +RemoteOpenFileChild::OpenANSIFileDesc(const char *mode, FILE **_retval)
   1.743 +{
   1.744 +  // TODO: can implement using fdopen()?
   1.745 +  return NS_ERROR_NOT_IMPLEMENTED;
   1.746 +}
   1.747 +
   1.748 +NS_IMETHODIMP
   1.749 +RemoteOpenFileChild::Load(PRLibrary **_retval)
   1.750 +{
   1.751 +  return NS_ERROR_NOT_IMPLEMENTED;
   1.752 +}
   1.753 +
   1.754 +NS_IMETHODIMP
   1.755 +RemoteOpenFileChild::GetDiskSpaceAvailable(int64_t *aDiskSpaceAvailable)
   1.756 +{
   1.757 +  return NS_ERROR_NOT_IMPLEMENTED;
   1.758 +}
   1.759 +
   1.760 +NS_IMETHODIMP
   1.761 +RemoteOpenFileChild::Reveal()
   1.762 +{
   1.763 +  return NS_ERROR_NOT_IMPLEMENTED;
   1.764 +}
   1.765 +
   1.766 +NS_IMETHODIMP
   1.767 +RemoteOpenFileChild::Launch()
   1.768 +{
   1.769 +  return NS_ERROR_NOT_IMPLEMENTED;
   1.770 +}
   1.771 +
   1.772 +//-----------------------------------------------------------------------------
   1.773 +// RemoteOpenFileChild::nsIHashable functions that we delegate to underlying nsIFile
   1.774 +//-----------------------------------------------------------------------------
   1.775 +
   1.776 +NS_IMETHODIMP
   1.777 +RemoteOpenFileChild::Equals(nsIHashable* aOther, bool *aResult)
   1.778 +{
   1.779 +  nsCOMPtr<nsIHashable> hashable = do_QueryInterface(mFile);
   1.780 +
   1.781 +  MOZ_ASSERT(hashable);
   1.782 +
   1.783 +  if (hashable) {
   1.784 +    return hashable->Equals(aOther, aResult);
   1.785 +  }
   1.786 +  return NS_ERROR_UNEXPECTED;
   1.787 +}
   1.788 +
   1.789 +NS_IMETHODIMP
   1.790 +RemoteOpenFileChild::GetHashCode(uint32_t *aResult)
   1.791 +{
   1.792 +  nsCOMPtr<nsIHashable> hashable = do_QueryInterface(mFile);
   1.793 +
   1.794 +  MOZ_ASSERT(hashable);
   1.795 +
   1.796 +  if (hashable) {
   1.797 +    return hashable->GetHashCode(aResult);
   1.798 +  }
   1.799 +  return NS_ERROR_UNEXPECTED;
   1.800 +}
   1.801 +
   1.802 +} // namespace net
   1.803 +} // namespace mozilla

mercurial