netwerk/ipc/RemoteOpenFileChild.cpp

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
michael@0 2 /* vim: set sw=2 ts=8 et tw=80 : */
michael@0 3 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 4 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 6
michael@0 7 #include "RemoteOpenFileChild.h"
michael@0 8
michael@0 9 #include "mozilla/unused.h"
michael@0 10 #include "mozilla/ipc/FileDescriptor.h"
michael@0 11 #include "mozilla/ipc/FileDescriptorUtils.h"
michael@0 12 #include "mozilla/ipc/URIUtils.h"
michael@0 13 #include "mozilla/net/NeckoChild.h"
michael@0 14 #include "nsThreadUtils.h"
michael@0 15 #include "nsJARProtocolHandler.h"
michael@0 16 #include "nsIRemoteOpenFileListener.h"
michael@0 17 #include "nsProxyRelease.h"
michael@0 18
michael@0 19 // needed to alloc/free NSPR file descriptors
michael@0 20 #include "private/pprio.h"
michael@0 21
michael@0 22 using namespace mozilla::ipc;
michael@0 23
michael@0 24 namespace mozilla {
michael@0 25 namespace net {
michael@0 26
michael@0 27 //-----------------------------------------------------------------------------
michael@0 28 // Helper class to dispatch events async on windows/OSX
michael@0 29 //-----------------------------------------------------------------------------
michael@0 30
michael@0 31 class CallsListenerInNewEvent : public nsRunnable
michael@0 32 {
michael@0 33 public:
michael@0 34 CallsListenerInNewEvent(nsIRemoteOpenFileListener *aListener, nsresult aRv)
michael@0 35 : mListener(aListener), mRV(aRv)
michael@0 36 {
michael@0 37 MOZ_ASSERT(NS_IsMainThread());
michael@0 38 MOZ_ASSERT(aListener);
michael@0 39 }
michael@0 40
michael@0 41 void Dispatch()
michael@0 42 {
michael@0 43 MOZ_ASSERT(NS_IsMainThread());
michael@0 44
michael@0 45 nsresult rv = NS_DispatchToCurrentThread(this);
michael@0 46 NS_ENSURE_SUCCESS_VOID(rv);
michael@0 47 }
michael@0 48
michael@0 49 private:
michael@0 50 NS_IMETHOD Run()
michael@0 51 {
michael@0 52 MOZ_ASSERT(NS_IsMainThread());
michael@0 53 MOZ_ASSERT(mListener);
michael@0 54
michael@0 55 mListener->OnRemoteFileOpenComplete(mRV);
michael@0 56 return NS_OK;
michael@0 57 }
michael@0 58
michael@0 59 nsCOMPtr<nsIRemoteOpenFileListener> mListener;
michael@0 60 nsresult mRV;
michael@0 61 };
michael@0 62
michael@0 63 //-----------------------------------------------------------------------------
michael@0 64 // RemoteOpenFileChild
michael@0 65 //-----------------------------------------------------------------------------
michael@0 66
michael@0 67 NS_IMPL_ISUPPORTS(RemoteOpenFileChild,
michael@0 68 nsIFile,
michael@0 69 nsIHashable,
michael@0 70 nsICachedFileDescriptorListener)
michael@0 71
michael@0 72 RemoteOpenFileChild::RemoteOpenFileChild(const RemoteOpenFileChild& other)
michael@0 73 : mTabChild(other.mTabChild)
michael@0 74 , mNSPRFileDesc(other.mNSPRFileDesc)
michael@0 75 , mAsyncOpenCalled(other.mAsyncOpenCalled)
michael@0 76 , mNSPROpenCalled(other.mNSPROpenCalled)
michael@0 77 {
michael@0 78 // Note: don't clone mListener or we'll have a refcount leak.
michael@0 79 other.mURI->Clone(getter_AddRefs(mURI));
michael@0 80 if (other.mAppURI) {
michael@0 81 other.mAppURI->Clone(getter_AddRefs(mAppURI));
michael@0 82 }
michael@0 83 other.mFile->Clone(getter_AddRefs(mFile));
michael@0 84 }
michael@0 85
michael@0 86 RemoteOpenFileChild::~RemoteOpenFileChild()
michael@0 87 {
michael@0 88 if (NS_IsMainThread()) {
michael@0 89 if (mListener) {
michael@0 90 NotifyListener(NS_ERROR_UNEXPECTED);
michael@0 91 }
michael@0 92 } else {
michael@0 93 nsCOMPtr<nsIThread> mainThread = do_GetMainThread();
michael@0 94 if (mainThread) {
michael@0 95 MOZ_ALWAYS_TRUE(NS_SUCCEEDED(NS_ProxyRelease(mainThread, mURI, true)));
michael@0 96 MOZ_ALWAYS_TRUE(NS_SUCCEEDED(NS_ProxyRelease(mainThread, mAppURI, true)));
michael@0 97 MOZ_ALWAYS_TRUE(NS_SUCCEEDED(NS_ProxyRelease(mainThread, mListener,
michael@0 98 true)));
michael@0 99
michael@0 100 TabChild* tabChild;
michael@0 101 mTabChild.forget(&tabChild);
michael@0 102
michael@0 103 if (tabChild) {
michael@0 104 nsCOMPtr<nsIRunnable> runnable =
michael@0 105 NS_NewNonOwningRunnableMethod(tabChild, &TabChild::Release);
michael@0 106 MOZ_ASSERT(runnable);
michael@0 107
michael@0 108 MOZ_ALWAYS_TRUE(NS_SUCCEEDED(mainThread->Dispatch(runnable,
michael@0 109 NS_DISPATCH_NORMAL)));
michael@0 110 }
michael@0 111 } else {
michael@0 112 using mozilla::unused;
michael@0 113
michael@0 114 NS_WARNING("RemoteOpenFileChild released after thread shutdown, leaking "
michael@0 115 "its members!");
michael@0 116
michael@0 117 unused << mURI.forget();
michael@0 118 unused << mAppURI.forget();
michael@0 119 unused << mListener.forget();
michael@0 120 unused << mTabChild.forget();
michael@0 121 }
michael@0 122 }
michael@0 123
michael@0 124 if (mNSPRFileDesc) {
michael@0 125 // If we handed out fd we shouldn't have pointer to it any more.
michael@0 126 MOZ_ASSERT(!mNSPROpenCalled);
michael@0 127 // PR_Close both closes the file and deallocates the PRFileDesc
michael@0 128 PR_Close(mNSPRFileDesc);
michael@0 129 }
michael@0 130 }
michael@0 131
michael@0 132 nsresult
michael@0 133 RemoteOpenFileChild::Init(nsIURI* aRemoteOpenUri, nsIURI* aAppUri)
michael@0 134 {
michael@0 135 if (!aRemoteOpenUri) {
michael@0 136 return NS_ERROR_INVALID_ARG;
michael@0 137 }
michael@0 138
michael@0 139 if (aAppUri) {
michael@0 140 aAppUri->Clone(getter_AddRefs(mAppURI));
michael@0 141 }
michael@0 142
michael@0 143 nsAutoCString scheme;
michael@0 144 nsresult rv = aRemoteOpenUri->GetScheme(scheme);
michael@0 145 NS_ENSURE_SUCCESS(rv, rv);
michael@0 146
michael@0 147 if (!scheme.EqualsLiteral("remoteopenfile")) {
michael@0 148 return NS_ERROR_INVALID_ARG;
michael@0 149 }
michael@0 150
michael@0 151 // scheme of URI is not file:// so this is not a nsIFileURL. Convert to one.
michael@0 152 nsCOMPtr<nsIURI> clonedURI;
michael@0 153 rv = aRemoteOpenUri->Clone(getter_AddRefs(clonedURI));
michael@0 154 NS_ENSURE_SUCCESS(rv, rv);
michael@0 155
michael@0 156 clonedURI->SetScheme(NS_LITERAL_CSTRING("file"));
michael@0 157 nsAutoCString spec;
michael@0 158 clonedURI->GetSpec(spec);
michael@0 159
michael@0 160 rv = NS_NewURI(getter_AddRefs(mURI), spec);
michael@0 161 NS_ENSURE_SUCCESS(rv, rv);
michael@0 162
michael@0 163 // Get nsIFile
michael@0 164 nsCOMPtr<nsIFileURL> fileURL = do_QueryInterface(mURI);
michael@0 165 if (!fileURL) {
michael@0 166 return NS_ERROR_UNEXPECTED;
michael@0 167 }
michael@0 168
michael@0 169 rv = fileURL->GetFile(getter_AddRefs(mFile));
michael@0 170 NS_ENSURE_SUCCESS(rv, rv);
michael@0 171
michael@0 172 return NS_OK;
michael@0 173 }
michael@0 174
michael@0 175 nsresult
michael@0 176 RemoteOpenFileChild::AsyncRemoteFileOpen(int32_t aFlags,
michael@0 177 nsIRemoteOpenFileListener* aListener,
michael@0 178 nsITabChild* aTabChild)
michael@0 179 {
michael@0 180 if (!mFile) {
michael@0 181 return NS_ERROR_NOT_INITIALIZED;
michael@0 182 }
michael@0 183
michael@0 184 if (!aListener) {
michael@0 185 return NS_ERROR_INVALID_ARG;
michael@0 186 }
michael@0 187
michael@0 188 if (mAsyncOpenCalled) {
michael@0 189 return NS_ERROR_ALREADY_OPENED;
michael@0 190 }
michael@0 191
michael@0 192 if (aFlags != PR_RDONLY) {
michael@0 193 return NS_ERROR_NOT_AVAILABLE;
michael@0 194 }
michael@0 195
michael@0 196 mTabChild = static_cast<TabChild*>(aTabChild);
michael@0 197
michael@0 198 if (MissingRequiredTabChild(mTabChild, "remoteopenfile")) {
michael@0 199 return NS_ERROR_ILLEGAL_VALUE;
michael@0 200 }
michael@0 201
michael@0 202 #if defined(XP_WIN) || defined(MOZ_WIDGET_COCOA)
michael@0 203 // Windows/OSX desktop builds skip remoting, and just open file in child
michael@0 204 // process when asked for NSPR handle
michael@0 205 nsRefPtr<CallsListenerInNewEvent> runnable =
michael@0 206 new CallsListenerInNewEvent(aListener, NS_OK);
michael@0 207 runnable->Dispatch();
michael@0 208
michael@0 209 mAsyncOpenCalled = true;
michael@0 210 return NS_OK;
michael@0 211 #else
michael@0 212 nsString path;
michael@0 213 if (NS_FAILED(mFile->GetPath(path))) {
michael@0 214 MOZ_CRASH("Couldn't get path from file!");
michael@0 215 }
michael@0 216
michael@0 217 if (mTabChild) {
michael@0 218 if (mTabChild->GetCachedFileDescriptor(path, this)) {
michael@0 219 // The file descriptor was found in the cache and OnCachedFileDescriptor()
michael@0 220 // will be called with it.
michael@0 221 return NS_OK;
michael@0 222 }
michael@0 223 }
michael@0 224
michael@0 225 URIParams uri;
michael@0 226 SerializeURI(mURI, uri);
michael@0 227 OptionalURIParams appUri;
michael@0 228 SerializeURI(mAppURI, appUri);
michael@0 229
michael@0 230 gNeckoChild->SendPRemoteOpenFileConstructor(this, uri, appUri);
michael@0 231
michael@0 232 // The chrome process now has a logical ref to us until it calls Send__delete.
michael@0 233 AddIPDLReference();
michael@0 234
michael@0 235 mListener = aListener;
michael@0 236 mAsyncOpenCalled = true;
michael@0 237 return NS_OK;
michael@0 238 #endif
michael@0 239 }
michael@0 240
michael@0 241 void
michael@0 242 RemoteOpenFileChild::OnCachedFileDescriptor(const nsAString& aPath,
michael@0 243 const FileDescriptor& aFD)
michael@0 244 {
michael@0 245 #ifdef DEBUG
michael@0 246 if (!aPath.IsEmpty()) {
michael@0 247 MOZ_ASSERT(mFile);
michael@0 248
michael@0 249 nsString path;
michael@0 250 MOZ_ASSERT(NS_SUCCEEDED(mFile->GetPath(path)));
michael@0 251 MOZ_ASSERT(path == aPath, "Paths don't match!");
michael@0 252 }
michael@0 253 #endif
michael@0 254
michael@0 255 HandleFileDescriptorAndNotifyListener(aFD, /* aFromRecvDelete */ false);
michael@0 256 }
michael@0 257
michael@0 258 void
michael@0 259 RemoteOpenFileChild::HandleFileDescriptorAndNotifyListener(
michael@0 260 const FileDescriptor& aFD,
michael@0 261 bool aFromRecvDelete)
michael@0 262 {
michael@0 263 #if defined(XP_WIN) || defined(MOZ_WIDGET_COCOA)
michael@0 264 MOZ_CRASH("OS X and Windows shouldn't be doing IPDL here");
michael@0 265 #else
michael@0 266 if (!mListener) {
michael@0 267 // We already notified our listener (either in response to a cached file
michael@0 268 // descriptor callback or through the normal messaging mechanism). Close the
michael@0 269 // file descriptor if it is valid.
michael@0 270 if (aFD.IsValid()) {
michael@0 271 nsRefPtr<CloseFileRunnable> runnable = new CloseFileRunnable(aFD);
michael@0 272 runnable->Dispatch();
michael@0 273 }
michael@0 274 return;
michael@0 275 }
michael@0 276
michael@0 277 MOZ_ASSERT(!mNSPRFileDesc);
michael@0 278
michael@0 279 nsRefPtr<TabChild> tabChild;
michael@0 280 mTabChild.swap(tabChild);
michael@0 281
michael@0 282 // If RemoteOpenFile reply (Recv__delete__) for app's application.zip comes
michael@0 283 // back sooner than the parent-pushed fd (TabChild::RecvCacheFileDescriptor())
michael@0 284 // have TabChild cancel running callbacks, since we'll call them in
michael@0 285 // NotifyListener.
michael@0 286 if (tabChild && aFromRecvDelete) {
michael@0 287 nsString path;
michael@0 288 if (NS_FAILED(mFile->GetPath(path))) {
michael@0 289 MOZ_CRASH("Couldn't get path from file!");
michael@0 290 }
michael@0 291
michael@0 292 tabChild->CancelCachedFileDescriptorCallback(path, this);
michael@0 293 }
michael@0 294
michael@0 295 if (aFD.IsValid()) {
michael@0 296 mNSPRFileDesc = PR_ImportFile(aFD.PlatformHandle());
michael@0 297 if (!mNSPRFileDesc) {
michael@0 298 NS_WARNING("Failed to import file handle!");
michael@0 299 }
michael@0 300 }
michael@0 301
michael@0 302 NotifyListener(mNSPRFileDesc ? NS_OK : NS_ERROR_FILE_NOT_FOUND);
michael@0 303 #endif
michael@0 304 }
michael@0 305
michael@0 306 void
michael@0 307 RemoteOpenFileChild::NotifyListener(nsresult aResult)
michael@0 308 {
michael@0 309 MOZ_ASSERT(mListener);
michael@0 310 mListener->OnRemoteFileOpenComplete(aResult);
michael@0 311 mListener = nullptr; // release ref to listener
michael@0 312
michael@0 313 nsRefPtr<nsJARProtocolHandler> handler(gJarHandler);
michael@0 314 NS_WARN_IF_FALSE(handler, "nsJARProtocolHandler is already gone!");
michael@0 315
michael@0 316 if (handler) {
michael@0 317 handler->RemoteOpenFileComplete(this, aResult);
michael@0 318 }
michael@0 319 }
michael@0 320
michael@0 321 //-----------------------------------------------------------------------------
michael@0 322 // RemoteOpenFileChild::PRemoteOpenFileChild
michael@0 323 //-----------------------------------------------------------------------------
michael@0 324
michael@0 325 bool
michael@0 326 RemoteOpenFileChild::Recv__delete__(const FileDescriptor& aFD)
michael@0 327 {
michael@0 328 #if defined(XP_WIN) || defined(MOZ_WIDGET_COCOA)
michael@0 329 NS_NOTREACHED("OS X and Windows shouldn't be doing IPDL here");
michael@0 330 #else
michael@0 331 HandleFileDescriptorAndNotifyListener(aFD, /* aFromRecvDelete */ true);
michael@0 332 #endif
michael@0 333
michael@0 334 return true;
michael@0 335 }
michael@0 336
michael@0 337 //-----------------------------------------------------------------------------
michael@0 338 // RemoteOpenFileChild::nsIFile functions that we override logic for
michael@0 339 //-----------------------------------------------------------------------------
michael@0 340
michael@0 341 NS_IMETHODIMP
michael@0 342 RemoteOpenFileChild::Clone(nsIFile **file)
michael@0 343 {
michael@0 344 *file = new RemoteOpenFileChild(*this);
michael@0 345 NS_ADDREF(*file);
michael@0 346
michael@0 347 // if we transferred ownership of file to clone, forget our pointer.
michael@0 348 if (mNSPRFileDesc) {
michael@0 349 mNSPRFileDesc = nullptr;
michael@0 350 }
michael@0 351
michael@0 352 return NS_OK;
michael@0 353 }
michael@0 354
michael@0 355 /* The main event: get file descriptor from parent process
michael@0 356 */
michael@0 357 NS_IMETHODIMP
michael@0 358 RemoteOpenFileChild::OpenNSPRFileDesc(int32_t aFlags, int32_t aMode,
michael@0 359 PRFileDesc **aRetval)
michael@0 360 {
michael@0 361 #if defined(XP_WIN) || defined(MOZ_WIDGET_COCOA)
michael@0 362 // Windows and OSX builds: just open nsIFile locally.
michael@0 363 return mFile->OpenNSPRFileDesc(aFlags, aMode, aRetval);
michael@0 364
michael@0 365 #else
michael@0 366 if (aFlags != PR_RDONLY) {
michael@0 367 return NS_ERROR_NOT_AVAILABLE;
michael@0 368 }
michael@0 369
michael@0 370 // Unlike regular nsIFile we can't (easily) support multiple open()s.
michael@0 371 if (mNSPROpenCalled) {
michael@0 372 return NS_ERROR_ALREADY_OPENED;
michael@0 373 }
michael@0 374
michael@0 375 if (!mNSPRFileDesc) {
michael@0 376 // client skipped AsyncRemoteFileOpen() or didn't wait for result, or this
michael@0 377 // object has been cloned
michael@0 378 return NS_ERROR_NOT_AVAILABLE;
michael@0 379 }
michael@0 380
michael@0 381 // hand off ownership (i.e responsibility to PR_Close() file handle) to caller
michael@0 382 *aRetval = mNSPRFileDesc;
michael@0 383 mNSPRFileDesc = nullptr;
michael@0 384 mNSPROpenCalled = true;
michael@0 385
michael@0 386 return NS_OK;
michael@0 387 #endif
michael@0 388 }
michael@0 389
michael@0 390
michael@0 391 //-----------------------------------------------------------------------------
michael@0 392 // RemoteOpenFileChild::nsIFile functions that we delegate to underlying nsIFile
michael@0 393 //-----------------------------------------------------------------------------
michael@0 394
michael@0 395 nsresult
michael@0 396 RemoteOpenFileChild::GetLeafName(nsAString &aLeafName)
michael@0 397 {
michael@0 398 return mFile->GetLeafName(aLeafName);
michael@0 399 }
michael@0 400
michael@0 401 NS_IMETHODIMP
michael@0 402 RemoteOpenFileChild::GetNativeLeafName(nsACString &aLeafName)
michael@0 403 {
michael@0 404 return mFile->GetNativeLeafName(aLeafName);
michael@0 405 }
michael@0 406
michael@0 407 nsresult
michael@0 408 RemoteOpenFileChild::GetTarget(nsAString &_retval)
michael@0 409 {
michael@0 410 return mFile->GetTarget(_retval);
michael@0 411 }
michael@0 412
michael@0 413 NS_IMETHODIMP
michael@0 414 RemoteOpenFileChild::GetNativeTarget(nsACString &_retval)
michael@0 415 {
michael@0 416 return mFile->GetNativeTarget(_retval);
michael@0 417 }
michael@0 418
michael@0 419 nsresult
michael@0 420 RemoteOpenFileChild::GetPath(nsAString &_retval)
michael@0 421 {
michael@0 422 return mFile->GetPath(_retval);
michael@0 423 }
michael@0 424
michael@0 425 NS_IMETHODIMP
michael@0 426 RemoteOpenFileChild::GetNativePath(nsACString &_retval)
michael@0 427 {
michael@0 428 return mFile->GetNativePath(_retval);
michael@0 429 }
michael@0 430
michael@0 431 NS_IMETHODIMP
michael@0 432 RemoteOpenFileChild::Equals(nsIFile *inFile, bool *_retval)
michael@0 433 {
michael@0 434 return mFile->Equals(inFile, _retval);
michael@0 435 }
michael@0 436
michael@0 437 NS_IMETHODIMP
michael@0 438 RemoteOpenFileChild::Contains(nsIFile *inFile, bool recur, bool *_retval)
michael@0 439 {
michael@0 440 return mFile->Contains(inFile, recur, _retval);
michael@0 441 }
michael@0 442
michael@0 443 NS_IMETHODIMP
michael@0 444 RemoteOpenFileChild::GetParent(nsIFile **aParent)
michael@0 445 {
michael@0 446 return mFile->GetParent(aParent);
michael@0 447 }
michael@0 448
michael@0 449 NS_IMETHODIMP
michael@0 450 RemoteOpenFileChild::GetFollowLinks(bool *aFollowLinks)
michael@0 451 {
michael@0 452 return mFile->GetFollowLinks(aFollowLinks);
michael@0 453 }
michael@0 454
michael@0 455 //-----------------------------------------------------------------------------
michael@0 456 // RemoteOpenFileChild::nsIFile functions that are not currently supported
michael@0 457 //-----------------------------------------------------------------------------
michael@0 458
michael@0 459 nsresult
michael@0 460 RemoteOpenFileChild::Append(const nsAString &node)
michael@0 461 {
michael@0 462 return NS_ERROR_NOT_IMPLEMENTED;
michael@0 463 }
michael@0 464
michael@0 465 NS_IMETHODIMP
michael@0 466 RemoteOpenFileChild::AppendNative(const nsACString &fragment)
michael@0 467 {
michael@0 468 return NS_ERROR_NOT_IMPLEMENTED;
michael@0 469 }
michael@0 470
michael@0 471 NS_IMETHODIMP
michael@0 472 RemoteOpenFileChild::Normalize()
michael@0 473 {
michael@0 474 return NS_ERROR_NOT_IMPLEMENTED;
michael@0 475 }
michael@0 476
michael@0 477 NS_IMETHODIMP
michael@0 478 RemoteOpenFileChild::Create(uint32_t type, uint32_t permissions)
michael@0 479 {
michael@0 480 return NS_ERROR_NOT_IMPLEMENTED;
michael@0 481 }
michael@0 482
michael@0 483 nsresult
michael@0 484 RemoteOpenFileChild::SetLeafName(const nsAString &aLeafName)
michael@0 485 {
michael@0 486 return NS_ERROR_NOT_IMPLEMENTED;
michael@0 487 }
michael@0 488
michael@0 489 NS_IMETHODIMP
michael@0 490 RemoteOpenFileChild::SetNativeLeafName(const nsACString &aLeafName)
michael@0 491 {
michael@0 492 return NS_ERROR_NOT_IMPLEMENTED;
michael@0 493 }
michael@0 494
michael@0 495 nsresult
michael@0 496 RemoteOpenFileChild::InitWithPath(const nsAString &filePath)
michael@0 497 {
michael@0 498 return NS_ERROR_NOT_IMPLEMENTED;
michael@0 499 }
michael@0 500
michael@0 501 NS_IMETHODIMP
michael@0 502 RemoteOpenFileChild::InitWithNativePath(const nsACString &filePath)
michael@0 503 {
michael@0 504 return NS_ERROR_NOT_IMPLEMENTED;
michael@0 505 }
michael@0 506
michael@0 507 NS_IMETHODIMP
michael@0 508 RemoteOpenFileChild::InitWithFile(nsIFile *aFile)
michael@0 509 {
michael@0 510 return NS_ERROR_NOT_IMPLEMENTED;
michael@0 511 }
michael@0 512
michael@0 513 NS_IMETHODIMP
michael@0 514 RemoteOpenFileChild::SetFollowLinks(bool aFollowLinks)
michael@0 515 {
michael@0 516 return NS_ERROR_NOT_IMPLEMENTED;
michael@0 517 }
michael@0 518
michael@0 519 nsresult
michael@0 520 RemoteOpenFileChild::AppendRelativePath(const nsAString &node)
michael@0 521 {
michael@0 522 return NS_ERROR_NOT_IMPLEMENTED;
michael@0 523 }
michael@0 524
michael@0 525 NS_IMETHODIMP
michael@0 526 RemoteOpenFileChild::AppendRelativeNativePath(const nsACString &fragment)
michael@0 527 {
michael@0 528 return NS_ERROR_NOT_IMPLEMENTED;
michael@0 529 }
michael@0 530
michael@0 531 NS_IMETHODIMP
michael@0 532 RemoteOpenFileChild::GetPersistentDescriptor(nsACString &aPersistentDescriptor)
michael@0 533 {
michael@0 534 return NS_ERROR_NOT_IMPLEMENTED;
michael@0 535 }
michael@0 536
michael@0 537 NS_IMETHODIMP
michael@0 538 RemoteOpenFileChild::SetPersistentDescriptor(const nsACString &aPersistentDescriptor)
michael@0 539 {
michael@0 540 return NS_ERROR_NOT_IMPLEMENTED;
michael@0 541 }
michael@0 542
michael@0 543 NS_IMETHODIMP
michael@0 544 RemoteOpenFileChild::GetRelativeDescriptor(nsIFile *fromFile, nsACString& _retval)
michael@0 545 {
michael@0 546 return NS_ERROR_NOT_IMPLEMENTED;
michael@0 547 }
michael@0 548
michael@0 549 NS_IMETHODIMP
michael@0 550 RemoteOpenFileChild::SetRelativeDescriptor(nsIFile *fromFile,
michael@0 551 const nsACString& relativeDesc)
michael@0 552 {
michael@0 553 return NS_ERROR_NOT_IMPLEMENTED;
michael@0 554 }
michael@0 555
michael@0 556 nsresult
michael@0 557 RemoteOpenFileChild::CopyTo(nsIFile *newParentDir, const nsAString &newName)
michael@0 558 {
michael@0 559 return NS_ERROR_NOT_IMPLEMENTED;
michael@0 560 }
michael@0 561
michael@0 562 NS_IMETHODIMP
michael@0 563 RemoteOpenFileChild::CopyToNative(nsIFile *newParent, const nsACString &newName)
michael@0 564 {
michael@0 565 return NS_ERROR_NOT_IMPLEMENTED;
michael@0 566 }
michael@0 567
michael@0 568 nsresult
michael@0 569 RemoteOpenFileChild::CopyToFollowingLinks(nsIFile *newParentDir,
michael@0 570 const nsAString &newName)
michael@0 571 {
michael@0 572 return NS_ERROR_NOT_IMPLEMENTED;
michael@0 573 }
michael@0 574
michael@0 575 NS_IMETHODIMP
michael@0 576 RemoteOpenFileChild::CopyToFollowingLinksNative(nsIFile *newParent,
michael@0 577 const nsACString &newName)
michael@0 578 {
michael@0 579 return NS_ERROR_NOT_IMPLEMENTED;
michael@0 580 }
michael@0 581
michael@0 582 nsresult
michael@0 583 RemoteOpenFileChild::MoveTo(nsIFile *newParentDir, const nsAString &newName)
michael@0 584 {
michael@0 585 return NS_ERROR_NOT_IMPLEMENTED;
michael@0 586 }
michael@0 587
michael@0 588 NS_IMETHODIMP
michael@0 589 RemoteOpenFileChild::MoveToNative(nsIFile *newParent, const nsACString &newName)
michael@0 590 {
michael@0 591 return NS_ERROR_NOT_IMPLEMENTED;
michael@0 592 }
michael@0 593
michael@0 594 NS_IMETHODIMP
michael@0 595 RemoteOpenFileChild::RenameTo(nsIFile *newParentDir, const nsAString &newName)
michael@0 596 {
michael@0 597 return NS_ERROR_NOT_IMPLEMENTED;
michael@0 598 }
michael@0 599
michael@0 600 NS_IMETHODIMP
michael@0 601 RemoteOpenFileChild::Remove(bool recursive)
michael@0 602 {
michael@0 603 return NS_ERROR_NOT_IMPLEMENTED;
michael@0 604 }
michael@0 605
michael@0 606 NS_IMETHODIMP
michael@0 607 RemoteOpenFileChild::GetPermissions(uint32_t *aPermissions)
michael@0 608 {
michael@0 609 return NS_ERROR_NOT_IMPLEMENTED;
michael@0 610 }
michael@0 611
michael@0 612 NS_IMETHODIMP
michael@0 613 RemoteOpenFileChild::SetPermissions(uint32_t aPermissions)
michael@0 614 {
michael@0 615 return NS_ERROR_NOT_IMPLEMENTED;
michael@0 616 }
michael@0 617
michael@0 618 NS_IMETHODIMP
michael@0 619 RemoteOpenFileChild::GetPermissionsOfLink(uint32_t *aPermissionsOfLink)
michael@0 620 {
michael@0 621 return NS_ERROR_NOT_IMPLEMENTED;
michael@0 622 }
michael@0 623
michael@0 624 NS_IMETHODIMP
michael@0 625 RemoteOpenFileChild::SetPermissionsOfLink(uint32_t aPermissions)
michael@0 626 {
michael@0 627 return NS_ERROR_NOT_IMPLEMENTED;
michael@0 628 }
michael@0 629
michael@0 630 NS_IMETHODIMP
michael@0 631 RemoteOpenFileChild::GetLastModifiedTime(PRTime *aLastModTime)
michael@0 632 {
michael@0 633 return NS_ERROR_NOT_IMPLEMENTED;
michael@0 634 }
michael@0 635
michael@0 636 NS_IMETHODIMP
michael@0 637 RemoteOpenFileChild::SetLastModifiedTime(PRTime aLastModTime)
michael@0 638 {
michael@0 639 return NS_ERROR_NOT_IMPLEMENTED;
michael@0 640 }
michael@0 641
michael@0 642 NS_IMETHODIMP
michael@0 643 RemoteOpenFileChild::GetLastModifiedTimeOfLink(PRTime *aLastModTimeOfLink)
michael@0 644 {
michael@0 645 return NS_ERROR_NOT_IMPLEMENTED;
michael@0 646 }
michael@0 647
michael@0 648 NS_IMETHODIMP
michael@0 649 RemoteOpenFileChild::SetLastModifiedTimeOfLink(PRTime aLastModTimeOfLink)
michael@0 650 {
michael@0 651 return NS_ERROR_NOT_IMPLEMENTED;
michael@0 652 }
michael@0 653
michael@0 654 NS_IMETHODIMP
michael@0 655 RemoteOpenFileChild::GetFileSize(int64_t *aFileSize)
michael@0 656 {
michael@0 657 return NS_ERROR_NOT_IMPLEMENTED;
michael@0 658 }
michael@0 659
michael@0 660 NS_IMETHODIMP
michael@0 661 RemoteOpenFileChild::SetFileSize(int64_t aFileSize)
michael@0 662 {
michael@0 663 return NS_ERROR_NOT_IMPLEMENTED;
michael@0 664 }
michael@0 665
michael@0 666 NS_IMETHODIMP
michael@0 667 RemoteOpenFileChild::GetFileSizeOfLink(int64_t *aFileSize)
michael@0 668 {
michael@0 669 return NS_ERROR_NOT_IMPLEMENTED;
michael@0 670 }
michael@0 671
michael@0 672 NS_IMETHODIMP
michael@0 673 RemoteOpenFileChild::Exists(bool *_retval)
michael@0 674 {
michael@0 675 return NS_ERROR_NOT_IMPLEMENTED;
michael@0 676 }
michael@0 677
michael@0 678 NS_IMETHODIMP
michael@0 679 RemoteOpenFileChild::IsWritable(bool *_retval)
michael@0 680 {
michael@0 681 return NS_ERROR_NOT_IMPLEMENTED;
michael@0 682 }
michael@0 683
michael@0 684 NS_IMETHODIMP
michael@0 685 RemoteOpenFileChild::IsReadable(bool *_retval)
michael@0 686 {
michael@0 687 return NS_ERROR_NOT_IMPLEMENTED;
michael@0 688 }
michael@0 689
michael@0 690 NS_IMETHODIMP
michael@0 691 RemoteOpenFileChild::IsExecutable(bool *_retval)
michael@0 692 {
michael@0 693 return NS_ERROR_NOT_IMPLEMENTED;
michael@0 694 }
michael@0 695
michael@0 696 NS_IMETHODIMP
michael@0 697 RemoteOpenFileChild::IsHidden(bool *_retval)
michael@0 698 {
michael@0 699 return NS_ERROR_NOT_IMPLEMENTED;
michael@0 700 }
michael@0 701
michael@0 702 NS_IMETHODIMP
michael@0 703 RemoteOpenFileChild::IsDirectory(bool *_retval)
michael@0 704 {
michael@0 705 return NS_ERROR_NOT_IMPLEMENTED;
michael@0 706 }
michael@0 707
michael@0 708 NS_IMETHODIMP
michael@0 709 RemoteOpenFileChild::IsFile(bool *_retval)
michael@0 710 {
michael@0 711 return NS_ERROR_NOT_IMPLEMENTED;
michael@0 712 }
michael@0 713
michael@0 714 NS_IMETHODIMP
michael@0 715 RemoteOpenFileChild::IsSymlink(bool *_retval)
michael@0 716 {
michael@0 717 return NS_ERROR_NOT_IMPLEMENTED;
michael@0 718 }
michael@0 719
michael@0 720 NS_IMETHODIMP
michael@0 721 RemoteOpenFileChild::IsSpecial(bool *_retval)
michael@0 722 {
michael@0 723 return NS_ERROR_NOT_IMPLEMENTED;
michael@0 724 }
michael@0 725
michael@0 726 NS_IMETHODIMP
michael@0 727 RemoteOpenFileChild::CreateUnique(uint32_t type, uint32_t attributes)
michael@0 728 {
michael@0 729 return NS_ERROR_NOT_IMPLEMENTED;
michael@0 730 }
michael@0 731
michael@0 732 NS_IMETHODIMP
michael@0 733 RemoteOpenFileChild::GetDirectoryEntries(nsISimpleEnumerator **entries)
michael@0 734 {
michael@0 735 return NS_ERROR_NOT_IMPLEMENTED;
michael@0 736 }
michael@0 737
michael@0 738 NS_IMETHODIMP
michael@0 739 RemoteOpenFileChild::OpenANSIFileDesc(const char *mode, FILE **_retval)
michael@0 740 {
michael@0 741 // TODO: can implement using fdopen()?
michael@0 742 return NS_ERROR_NOT_IMPLEMENTED;
michael@0 743 }
michael@0 744
michael@0 745 NS_IMETHODIMP
michael@0 746 RemoteOpenFileChild::Load(PRLibrary **_retval)
michael@0 747 {
michael@0 748 return NS_ERROR_NOT_IMPLEMENTED;
michael@0 749 }
michael@0 750
michael@0 751 NS_IMETHODIMP
michael@0 752 RemoteOpenFileChild::GetDiskSpaceAvailable(int64_t *aDiskSpaceAvailable)
michael@0 753 {
michael@0 754 return NS_ERROR_NOT_IMPLEMENTED;
michael@0 755 }
michael@0 756
michael@0 757 NS_IMETHODIMP
michael@0 758 RemoteOpenFileChild::Reveal()
michael@0 759 {
michael@0 760 return NS_ERROR_NOT_IMPLEMENTED;
michael@0 761 }
michael@0 762
michael@0 763 NS_IMETHODIMP
michael@0 764 RemoteOpenFileChild::Launch()
michael@0 765 {
michael@0 766 return NS_ERROR_NOT_IMPLEMENTED;
michael@0 767 }
michael@0 768
michael@0 769 //-----------------------------------------------------------------------------
michael@0 770 // RemoteOpenFileChild::nsIHashable functions that we delegate to underlying nsIFile
michael@0 771 //-----------------------------------------------------------------------------
michael@0 772
michael@0 773 NS_IMETHODIMP
michael@0 774 RemoteOpenFileChild::Equals(nsIHashable* aOther, bool *aResult)
michael@0 775 {
michael@0 776 nsCOMPtr<nsIHashable> hashable = do_QueryInterface(mFile);
michael@0 777
michael@0 778 MOZ_ASSERT(hashable);
michael@0 779
michael@0 780 if (hashable) {
michael@0 781 return hashable->Equals(aOther, aResult);
michael@0 782 }
michael@0 783 return NS_ERROR_UNEXPECTED;
michael@0 784 }
michael@0 785
michael@0 786 NS_IMETHODIMP
michael@0 787 RemoteOpenFileChild::GetHashCode(uint32_t *aResult)
michael@0 788 {
michael@0 789 nsCOMPtr<nsIHashable> hashable = do_QueryInterface(mFile);
michael@0 790
michael@0 791 MOZ_ASSERT(hashable);
michael@0 792
michael@0 793 if (hashable) {
michael@0 794 return hashable->GetHashCode(aResult);
michael@0 795 }
michael@0 796 return NS_ERROR_UNEXPECTED;
michael@0 797 }
michael@0 798
michael@0 799 } // namespace net
michael@0 800 } // namespace mozilla

mercurial