Bug 860731 - Part c: Move LockedFile to WebIDL; r=janv
authorMs2ger <ms2ger@gmail.com>
Mon, 24 Mar 2014 16:10:27 +0100
changeset 193586 94c92db0b503fce7f52659022734f4eb9582bbb0
parent 193585 f4e975c7d8d3f4f7865443e32aab224d3f789aec
child 193587 85555bfd48442aefecb3c7948be2843ff6469d1b
push id3624
push userasasaki@mozilla.com
push dateMon, 09 Jun 2014 21:49:01 +0000
treeherdermozilla-beta@b1a5da15899a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjanv
bugs860731
milestone31.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 860731 - Part c: Move LockedFile to WebIDL; r=janv
dom/base/nsDOMClassInfo.cpp
dom/base/nsDOMClassInfoClasses.h
dom/bindings/Bindings.conf
dom/bindings/Errors.msg
dom/file/FileHandle.cpp
dom/file/FileHandle.h
dom/file/FileRequest.cpp
dom/file/FileRequest.h
dom/file/FileService.cpp
dom/file/LockedFile.cpp
dom/file/LockedFile.h
dom/file/moz.build
dom/file/nsIDOMLockedFile.idl
dom/webidl/FileHandle.webidl
dom/webidl/FileRequest.webidl
dom/webidl/LockedFile.webidl
js/xpconnect/src/dom_quickstubs.qsconf
--- a/dom/base/nsDOMClassInfo.cpp
+++ b/dom/base/nsDOMClassInfo.cpp
@@ -153,17 +153,16 @@
 #include "nsIDOMMobileConnection.h"
 #endif // MOZ_B2G_RIL
 
 #ifdef MOZ_B2G_FM
 #include "FMRadio.h"
 #endif
 
 #include "nsIDOMGlobalObjectConstructor.h"
-#include "nsIDOMLockedFile.h"
 #include "nsDebug.h"
 
 #include "mozilla/dom/BindingUtils.h"
 #include "mozilla/Likely.h"
 #include "WindowNamedPropertiesHandler.h"
 #include "nsIInterfaceInfoManager.h"
 #include "mozilla/dom/EventTargetBinding.h"
 #include "mozilla/dom/WindowBinding.h"
@@ -454,18 +453,16 @@ static nsDOMClassInfoData sClassInfoData
   NS_DEFINE_CLASSINFO_DATA(CSSPageRule, nsDOMGenericSH,
                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
 
 #ifdef MOZ_B2G_RIL
   NS_DEFINE_CLASSINFO_DATA(MozIccManager, nsDOMGenericSH,
                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
 #endif
 
-  NS_DEFINE_CLASSINFO_DATA(LockedFile, nsEventTargetSH,
-                           EVENTTARGET_SCRIPTABLE_FLAGS)
   NS_DEFINE_CLASSINFO_DATA(CSSFontFeatureValuesRule, nsDOMGenericSH,
                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
 
   NS_DEFINE_CHROME_XBL_CLASSINFO_DATA(UserDataHandler, nsDOMGenericSH,
                                       DOM_DEFAULT_SCRIPTABLE_FLAGS)
   NS_DEFINE_CLASSINFO_DATA(XPathNamespace, nsDOMGenericSH,
                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
   NS_DEFINE_CHROME_XBL_CLASSINFO_DATA(XULControlElement, nsDOMGenericSH,
@@ -1149,20 +1146,16 @@ nsDOMClassInfo::Init()
 #ifdef MOZ_B2G_RIL
   DOM_CLASSINFO_MAP_BEGIN(MozIccManager, nsIDOMMozIccManager)
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMMozIccManager)
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget)
   DOM_CLASSINFO_MAP_END
 
 #endif
 
-  DOM_CLASSINFO_MAP_BEGIN(LockedFile, nsIDOMLockedFile)
-    DOM_CLASSINFO_MAP_ENTRY(nsIDOMLockedFile)
-  DOM_CLASSINFO_MAP_END
-
   DOM_CLASSINFO_MAP_BEGIN(CSSFontFeatureValuesRule, nsIDOMCSSFontFeatureValuesRule)
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMCSSFontFeatureValuesRule)
   DOM_CLASSINFO_MAP_END
 
   DOM_CLASSINFO_MAP_BEGIN_NO_CLASS_IF(UserDataHandler, nsIDOMUserDataHandler)
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMUserDataHandler)
   DOM_CLASSINFO_MAP_END
 
--- a/dom/base/nsDOMClassInfoClasses.h
+++ b/dom/base/nsDOMClassInfoClasses.h
@@ -93,18 +93,16 @@ DOMCI_CLASS(MozCSSKeyframeRule)
 DOMCI_CLASS(MozCSSKeyframesRule)
 
 DOMCI_CLASS(CSSPageRule)
 
 #ifdef MOZ_B2G_RIL
 DOMCI_CLASS(MozIccManager)
 #endif
 
-DOMCI_CLASS(LockedFile)
-
 DOMCI_CLASS(CSSFontFeatureValuesRule)
 
 DOMCI_CLASS(UserDataHandler)
 DOMCI_CLASS(XPathNamespace)
 DOMCI_CLASS(XULControlElement)
 DOMCI_CLASS(XULLabeledControlElement)
 DOMCI_CLASS(XULButtonElement)
 DOMCI_CLASS(XULCheckboxElement)
--- a/dom/bindings/Bindings.conf
+++ b/dom/bindings/Bindings.conf
@@ -687,16 +687,20 @@ DOMInterfaces = {
 'Location': {
     # NOTE: Before you turn on codegen for Location, make sure all the
     # Unforgeable stuff is dealt with.
     'nativeType': 'nsIDOMLocation',
     'skipGen': True,
     'register': False
 },
 
+'LockedFile': {
+    'nativeType': 'mozilla::dom::file::LockedFile',
+},
+
 'MediaList': {
     'nativeType': 'nsMediaList',
     'headerFile': 'nsIMediaList.h',
 },
 
 'MediaSource': [{
     'resultNotAddRefed': [ 'sourceBuffers', 'activeSourceBuffers' ],
 },
@@ -1848,17 +1852,16 @@ addExternalIface('Counter')
 addExternalIface('CSSRule')
 addExternalIface('mozIDOMApplication', nativeType='mozIDOMApplication', headerFile='nsIDOMApplicationRegistry.h')
 addExternalIface('CSSRuleList')
 addExternalIface('RTCDataChannel', nativeType='nsIDOMDataChannel')
 addExternalIface('File')
 addExternalIface('HitRegionOptions', nativeType='nsISupports')
 addExternalIface('imgINotificationObserver', nativeType='imgINotificationObserver')
 addExternalIface('imgIRequest', nativeType='imgIRequest', notflattened=True)
-addExternalIface('LockedFile')
 addExternalIface('MenuBuilder', nativeType='nsIMenuBuilder', notflattened=True)
 addExternalIface('MozBoxObject', nativeType='nsIBoxObject')
 addExternalIface('MozControllers', nativeType='nsIControllers')
 addExternalIface('MozFrameLoader', nativeType='nsIFrameLoader', notflattened=True)
 addExternalIface('MozFrameRequestCallback', nativeType='nsIFrameRequestCallback',
                  notflattened=True)
 addExternalIface('MozIccInfo', headerFile='nsIDOMIccInfo.h')
 addExternalIface('MozIccManager', headerFile='nsIDOMIccManager.h')
--- a/dom/bindings/Errors.msg
+++ b/dom/bindings/Errors.msg
@@ -47,8 +47,10 @@ MSG_DEF(MSG_DOM_ENCODING_NOT_UTF, 0, "Th
 MSG_DEF(MSG_NOT_FINITE, 1, "{0} is not a finite floating-point value.")
 MSG_DEF(MSG_INVALID_VERSION, 0, "0 (Zero) is not a valid database version.")
 MSG_DEF(MSG_INVALID_BYTESTRING, 2, "Cannot convert string to ByteString because the character"
         " at index {0} has value {1} which is greater than 255.")
 MSG_DEF(MSG_NOT_DATE, 1, "{0} is not a date.")
 MSG_DEF(MSG_INVALID_ADVANCE_COUNT, 0, "0 (Zero) is not a valid advance count.")
 MSG_DEF(MSG_DEFINEPROPERTY_ON_GSP, 0, "Not allowed to define a property on the named properties object.")
 MSG_DEF(MSG_INVALID_URL, 1, "{0} is not a valid URL.")
+MSG_DEF(MSG_METADATA_NOT_CONFIGURED, 0, "Either size or lastModified should be true.")
+MSG_DEF(MSG_INVALID_READ_SIZE, 0, "0 (Zero) is not a valid read size.")
--- a/dom/file/FileHandle.cpp
+++ b/dom/file/FileHandle.cpp
@@ -123,17 +123,17 @@ FileHandle::CreateFileObject(LockedFile*
 
 // virtual
 JSObject*
 FileHandle::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope)
 {
   return FileHandleBinding::Wrap(aCx, aScope, this);
 }
 
-already_AddRefed<nsIDOMLockedFile>
+already_AddRefed<LockedFile>
 FileHandle::Open(FileMode aMode, ErrorResult& aError)
 {
   MOZ_ASSERT(NS_IsMainThread());
 
   if (FileService::IsShuttingDown() || mFileStorage->IsShuttingDown()) {
     aError.Throw(NS_ERROR_DOM_FILEHANDLE_UNKNOWN_ERR);
     return nullptr;
   }
--- a/dom/file/FileHandle.h
+++ b/dom/file/FileHandle.h
@@ -108,17 +108,17 @@ public:
   }
 
   void
   GetType(nsString& aType) const
   {
     aType = mType;
   }
 
-  already_AddRefed<nsIDOMLockedFile>
+  already_AddRefed<LockedFile>
   Open(FileMode aMode, ErrorResult& aError);
 
   already_AddRefed<DOMRequest>
   GetFile(ErrorResult& aError);
 
   IMPL_EVENT_HANDLER(abort)
   IMPL_EVENT_HANDLER(error)
 
--- a/dom/file/FileRequest.cpp
+++ b/dom/file/FileRequest.cpp
@@ -110,17 +110,17 @@ JSObject*
 FileRequest::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope)
 {
   if (mWrapAsDOMRequest) {
     return DOMRequest::WrapObject(aCx, aScope);
   }
   return FileRequestBinding::Wrap(aCx, aScope, this);
 }
 
-nsIDOMLockedFile*
+LockedFile*
 FileRequest::GetLockedFile() const
 {
   MOZ_ASSERT(NS_IsMainThread(), "Wrong thread!");
   return mLockedFile;
 }
 
 void
 FileRequest::FireProgressEvent(uint64_t aLoaded, uint64_t aTotal)
--- a/dom/file/FileRequest.h
+++ b/dom/file/FileRequest.h
@@ -46,17 +46,17 @@ public:
   nsresult
   NotifyHelperCompleted(FileHelper* aFileHelper);
 
   // nsWrapperCache
   virtual JSObject*
   WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope) MOZ_OVERRIDE;
 
   // WebIDL
-  nsIDOMLockedFile*
+  LockedFile*
   GetLockedFile() const;
 
   IMPL_EVENT_HANDLER(progress)
 
 protected:
   FileRequest(nsPIDOMWindow* aWindow);
   ~FileRequest();
 
--- a/dom/file/FileService.cpp
+++ b/dom/file/FileService.cpp
@@ -279,17 +279,18 @@ FileService::AbortLockedFilesForStorage(
     return;
   }
 
   nsAutoTArray<nsRefPtr<LockedFile>, 10> lockedFiles;
   fileStorageInfo->CollectRunningAndDelayedLockedFiles(aFileStorage,
                                                        lockedFiles);
 
   for (uint32_t index = 0; index < lockedFiles.Length(); index++) {
-    lockedFiles[index]->Abort();
+    ErrorResult ignored;
+    lockedFiles[index]->Abort(ignored);
   }
 }
 
 bool
 FileService::HasLockedFilesForStorage(nsIFileStorage* aFileStorage)
 {
   NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
   NS_ASSERTION(aFileStorage, "Null pointer!");
--- a/dom/file/LockedFile.cpp
+++ b/dom/file/LockedFile.cpp
@@ -1,50 +1,44 @@
 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* vim: set ts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
  * You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "LockedFile.h"
 
-#include "nsIAppShell.h"
+#include "AsyncHelper.h"
 #include "nsIDOMEvent.h"
-#include "nsIDOMFile.h"
-#include "nsIFileStorage.h"
-#include "nsISeekableStream.h"
-
-#include "jsfriendapi.h"
-#include "nsNetUtil.h"
-#include "nsDOMClassInfoID.h"
-#include "nsJSUtils.h"
-#include "nsStringStream.h"
-#include "nsWidgetsCID.h"
-#include "xpcpublic.h"
-
-#include "AsyncHelper.h"
 #include "FileHandle.h"
 #include "FileHelper.h"
 #include "FileRequest.h"
 #include "FileService.h"
 #include "FileStreamWrappers.h"
 #include "MemoryStreams.h"
 #include "MetadataHelper.h"
-#include "nsError.h"
-#include "nsContentUtils.h"
-
-#include "mozilla/EventDispatcher.h"
+#include "mozilla/dom/DOMRequest.h"
 #include "mozilla/dom/EncodingUtils.h"
 #include "mozilla/dom/LockedFileBinding.h"
+#include "mozilla/dom/TypedArray.h"
+#include "mozilla/dom/UnionTypes.h"
+#include "mozilla/EventDispatcher.h"
+#include "nsContentUtils.h"
+#include "nsError.h"
+#include "nsIAppShell.h"
+#include "nsIDOMFile.h"
+#include "nsIFileStorage.h"
+#include "nsISeekableStream.h"
+#include "nsNetUtil.h"
+#include "nsStringStream.h"
+#include "nsWidgetsCID.h"
 
 #define STREAM_COPY_BLOCK_SIZE 32768
 
-using namespace mozilla;
-using namespace mozilla::dom;
-USING_FILE_NAMESPACE
+BEGIN_FILE_NAMESPACE
 
 namespace {
 
 NS_DEFINE_CID(kAppShellCID, NS_APPSHELL_CID);
 
 class ReadHelper : public FileHelper
 {
 public:
@@ -210,71 +204,16 @@ CreateGenericEvent(mozilla::dom::EventTa
   nsresult rv = event->InitEvent(aType, aBubbles, aCancelable);
   NS_ENSURE_SUCCESS(rv, nullptr);
 
   event->SetTrusted(true);
 
   return event.forget();
 }
 
-inline nsresult
-GetInputStreamForJSVal(JS::Handle<JS::Value> aValue, JSContext* aCx,
-                       nsIInputStream** aInputStream, uint64_t* aInputLength)
-{
-  nsresult rv;
-
-  if (aValue.isObject()) {
-    JS::Rooted<JSObject*> obj(aCx, &aValue.toObject());
-    if (JS_IsArrayBufferObject(obj)) {
-      char* data = reinterpret_cast<char*>(JS_GetArrayBufferData(obj));
-      uint32_t length = JS_GetArrayBufferByteLength(obj);
-
-      rv = NS_NewByteInputStream(aInputStream, data, length,
-                                 NS_ASSIGNMENT_COPY);
-      NS_ENSURE_SUCCESS(rv, rv);
-
-      *aInputLength = length;
-
-      return NS_OK;
-    }
-
-    nsCOMPtr<nsIDOMBlob> blob = do_QueryInterface(
-      nsContentUtils::XPConnect()->GetNativeOfWrapper(aCx, obj));
-    if (blob) {
-      rv = blob->GetSize(aInputLength);
-      NS_ENSURE_SUCCESS(rv, rv);
-
-      rv = blob->GetInternalStream(aInputStream);
-      NS_ENSURE_SUCCESS(rv, rv);
-
-      return NS_OK;
-    }
-  }
-
-  JSString* jsstr = JS::ToString(aCx, aValue);
-  NS_ENSURE_TRUE(jsstr, NS_ERROR_XPC_BAD_CONVERT_JS);
-
-  nsDependentJSString str;
-  if (!str.init(aCx, jsstr)) {
-    return NS_ERROR_FAILURE;
-  }
-
-  nsCString cstr;
-  CopyUTF16toUTF8(str, cstr);
-
-  nsCOMPtr<nsIInputStream> stream;
-  rv = NS_NewCStringInputStream(getter_AddRefs(stream), cstr);
-  NS_ENSURE_SUCCESS(rv, rv);
-
-  stream.forget(aInputStream);
-  *aInputLength = cstr.Length();
-
-  return NS_OK;
-}
-
 } // anonymous namespace
 
 // static
 already_AddRefed<LockedFile>
 LockedFile::Create(FileHandle* aFileHandle,
                    FileMode aMode,
                    RequestMode aRequestMode)
 {
@@ -300,51 +239,92 @@ LockedFile::Create(FileHandle* aFileHand
   NS_ENSURE_TRUE(service, nullptr);
 
   rv = service->Enqueue(lockedFile, nullptr);
   NS_ENSURE_SUCCESS(rv, nullptr);
 
   return lockedFile.forget();
 }
 
+/* static */ already_AddRefed<nsIInputStream>
+LockedFile::GetInputStream(const ArrayBuffer& aValue, uint64_t* aInputLength,
+                           ErrorResult& aRv)
+{
+  const char* data = reinterpret_cast<const char*>(aValue.Data());
+  uint32_t length = aValue.Length();
+
+  nsCOMPtr<nsIInputStream> stream;
+  aRv = NS_NewByteInputStream(getter_AddRefs(stream), data, length,
+                              NS_ASSIGNMENT_COPY);
+  if (aRv.Failed()) {
+    return nullptr;
+  }
+
+  *aInputLength = length;
+  return stream.forget();
+}
+
+/* static */ already_AddRefed<nsIInputStream>
+LockedFile::GetInputStream(nsIDOMBlob* aValue, uint64_t* aInputLength,
+                           ErrorResult& aRv)
+{
+  aRv = aValue->GetSize(aInputLength);
+  if (aRv.Failed()) {
+    return nullptr;
+  }
+
+  nsCOMPtr<nsIInputStream> stream;
+  aRv = aValue->GetInternalStream(getter_AddRefs(stream));
+  return stream.forget();
+}
+
+/* static */ already_AddRefed<nsIInputStream>
+LockedFile::GetInputStream(const nsAString& aValue, uint64_t* aInputLength,
+                           ErrorResult& aRv)
+{
+  NS_ConvertUTF16toUTF8 cstr(aValue);
+
+  nsCOMPtr<nsIInputStream> stream;
+  aRv = NS_NewCStringInputStream(getter_AddRefs(stream), cstr);
+  if (aRv.Failed()) {
+    return nullptr;
+  }
+
+  *aInputLength = cstr.Length();
+  return stream.forget();
+}
+
 LockedFile::LockedFile()
 : mReadyState(INITIAL),
   mMode(FileMode::Readonly),
   mRequestMode(NORMAL),
   mLocation(0),
   mPendingRequests(0),
   mAborted(false),
   mCreating(false)
 {
   NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
+  SetIsDOMBinding();
 }
 
 LockedFile::~LockedFile()
 {
   NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
 }
 
 NS_IMPL_CYCLE_COLLECTION_INHERITED_1(LockedFile, nsDOMEventTargetHelper,
                                      mFileHandle)
 
 NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(LockedFile)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMLockedFile)
   NS_INTERFACE_MAP_ENTRY(nsIRunnable)
-  NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(LockedFile)
 NS_INTERFACE_MAP_END_INHERITING(nsDOMEventTargetHelper)
 
 NS_IMPL_ADDREF_INHERITED(LockedFile, nsDOMEventTargetHelper)
 NS_IMPL_RELEASE_INHERITED(LockedFile, nsDOMEventTargetHelper)
 
-DOMCI_DATA(LockedFile, LockedFile)
-
-NS_IMPL_EVENT_HANDLER(LockedFile, complete)
-NS_IMPL_EVENT_HANDLER(LockedFile, abort)
-NS_IMPL_EVENT_HANDLER(LockedFile, error)
-
 nsresult
 LockedFile::PreHandleEvent(EventChainPreVisitor& aVisitor)
 {
   NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
 
   aVisitor.mCanHandle = true;
   aVisitor.mParentTarget = mFileHandle;
   return NS_OK;
@@ -452,336 +432,231 @@ LockedFile::IsOpen() const
     if (FileHelper::GetCurrentLockedFile() == this) {
       return true;
     }
   }
 
   return false;
 }
 
-NS_IMETHODIMP
-LockedFile::GetFileHandle(nsISupports** aFileHandle)
-{
-  nsCOMPtr<nsISupports> result(mFileHandle);
-  result.forget(aFileHandle);
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-LockedFile::GetMode(nsAString& aMode)
-{
-  NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
-
-  switch (mMode) {
-   case FileMode::Readonly:
-     aMode.AssignLiteral("readonly");
-     break;
-   case FileMode::Readwrite:
-     aMode.AssignLiteral("readwrite");
-     break;
-   default:
-     NS_NOTREACHED("Unknown mode!");
-  }
-
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-LockedFile::GetActive(bool* aActive)
-{
-  NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
-  *aActive = IsOpen();
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-LockedFile::GetLocation(JSContext* aCx,
-                        JS::MutableHandle<JS::Value> aLocation)
-{
-  NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
-
-  if (mLocation == UINT64_MAX) {
-    aLocation.setNull();
-  }
-  else {
-    aLocation.setDouble(double(mLocation));
-  }
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-LockedFile::SetLocation(JSContext* aCx,
-                        JS::Handle<JS::Value> aLocation)
-{
-  NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
-
-  // Null means the end-of-file.
-  if (aLocation.isNull()) {
-    mLocation = UINT64_MAX;
-    return NS_OK;
-  }
-
-  uint64_t location;
-  if (!JS::ToUint64(aCx, aLocation, &location)) {
-    return NS_ERROR_TYPE_ERR;
-  }
-
-  mLocation = location;
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-LockedFile::GetMetadata(JS::Handle<JS::Value> aParameters,
-                        JSContext* aCx,
-                        nsISupports** _retval)
+already_AddRefed<FileRequest>
+LockedFile::GetMetadata(const DOMFileMetadataParameters& aParameters,
+                        ErrorResult& aRv)
 {
   NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
 
   if (!IsOpen()) {
-    return NS_ERROR_DOM_FILEHANDLE_LOCKEDFILE_INACTIVE_ERR;
+    aRv.Throw(NS_ERROR_DOM_FILEHANDLE_LOCKEDFILE_INACTIVE_ERR);
+    return nullptr;
   }
 
   // Do nothing if the window is closed
   if (!GetOwner()) {
-    return NS_OK;
+    return nullptr;
   }
 
-  // Get optional arguments.
-  DOMFileMetadataParameters config;
-  JS::Rooted<JS::Value> parameters(aCx, aParameters);
-  bool result = config.Init(aCx, parameters);
-  NS_ENSURE_TRUE(result, NS_ERROR_DOM_FILEHANDLE_UNKNOWN_ERR);
-
   nsRefPtr<MetadataParameters> params =
-    new MetadataParameters(config.mSize, config.mLastModified);
+    new MetadataParameters(aParameters.mSize, aParameters.mLastModified);
   if (!params->IsConfigured()) {
-    return NS_ERROR_TYPE_ERR;
+    aRv.ThrowTypeError(MSG_METADATA_NOT_CONFIGURED);
+    return nullptr;
   }
 
   nsRefPtr<FileRequest> fileRequest = GenerateFileRequest();
 
   nsRefPtr<MetadataHelper> helper =
     new MetadataHelper(this, fileRequest, params);
 
-  nsresult rv = helper->Enqueue();
-  NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_FILEHANDLE_UNKNOWN_ERR);
+  if (NS_FAILED(helper->Enqueue())) {
+    aRv.Throw(NS_ERROR_DOM_FILEHANDLE_UNKNOWN_ERR);
+    return nullptr;
+  }
 
-  nsRefPtr<nsIDOMDOMRequest> request = fileRequest.forget();
-  request.forget(_retval);
-  return NS_OK;
+  return fileRequest.forget();
 }
 
-NS_IMETHODIMP
-LockedFile::ReadAsArrayBuffer(uint64_t aSize,
-                              JSContext* aCx,
-                              nsISupports** _retval)
+bool
+LockedFile::CheckStateAndArgumentsForRead(uint64_t aSize, ErrorResult& aRv)
 {
-  NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
-
   if (!IsOpen()) {
-    return NS_ERROR_DOM_FILEHANDLE_LOCKEDFILE_INACTIVE_ERR;
+    aRv.Throw(NS_ERROR_DOM_FILEHANDLE_LOCKEDFILE_INACTIVE_ERR);
+    return false;
   }
 
   if (mLocation == UINT64_MAX) {
-    return NS_ERROR_DOM_FILEHANDLE_NOT_ALLOWED_ERR;
+    aRv.Throw(NS_ERROR_DOM_FILEHANDLE_NOT_ALLOWED_ERR);
+    return false;
   }
 
   if (!aSize) {
-    return NS_ERROR_TYPE_ERR;
+    aRv.ThrowTypeError(MSG_INVALID_READ_SIZE);
+    return false;
   }
 
   // Do nothing if the window is closed
   if (!GetOwner()) {
-    return NS_OK;
+    return false;
+  }
+
+  return true;
+}
+
+already_AddRefed<FileRequest>
+LockedFile::ReadAsArrayBuffer(uint64_t aSize, ErrorResult& aRv)
+{
+  NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
+
+  if (!CheckStateAndArgumentsForRead(aSize, aRv)) {
+    return nullptr;
   }
 
   nsRefPtr<FileRequest> fileRequest = GenerateFileRequest();
 
   nsRefPtr<ReadHelper> helper =
     new ReadHelper(this, fileRequest, mLocation, aSize);
 
-  nsresult rv = helper->Init();
-  NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_FILEHANDLE_UNKNOWN_ERR);
-
-  rv = helper->Enqueue();
-  NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_FILEHANDLE_UNKNOWN_ERR);
+  if (NS_FAILED(helper->Init()) || NS_FAILED(helper->Enqueue())) {
+    aRv.Throw(NS_ERROR_DOM_FILEHANDLE_UNKNOWN_ERR);
+    return nullptr;
+  }
 
   mLocation += aSize;
 
-  nsRefPtr<nsIDOMDOMRequest> request = fileRequest.forget();
-  request.forget(_retval);
-  return NS_OK;
+  return fileRequest.forget();
 }
 
-NS_IMETHODIMP
-LockedFile::ReadAsText(uint64_t aSize,
-                       const nsAString& aEncoding,
-                       nsISupports** _retval)
+already_AddRefed<FileRequest>
+LockedFile::ReadAsText(uint64_t aSize, const nsAString& aEncoding,
+                       ErrorResult& aRv)
 {
   NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
 
-  if (!IsOpen()) {
-    return NS_ERROR_DOM_FILEHANDLE_LOCKEDFILE_INACTIVE_ERR;
-  }
-
-  if (mLocation == UINT64_MAX) {
-    return NS_ERROR_DOM_FILEHANDLE_NOT_ALLOWED_ERR;
-  }
-
-  if (!aSize) {
-    return NS_ERROR_TYPE_ERR;
-  }
-
-  // Do nothing if the window is closed
-  if (!GetOwner()) {
-    return NS_OK;
+  if (!CheckStateAndArgumentsForRead(aSize, aRv)) {
+    return nullptr;
   }
 
   nsRefPtr<FileRequest> fileRequest = GenerateFileRequest();
 
   nsRefPtr<ReadTextHelper> helper =
     new ReadTextHelper(this, fileRequest, mLocation, aSize, aEncoding);
 
-  nsresult rv = helper->Init();
-  NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_FILEHANDLE_UNKNOWN_ERR);
-
-  rv = helper->Enqueue();
-  NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_FILEHANDLE_UNKNOWN_ERR);
+  if (NS_FAILED(helper->Init()) || NS_FAILED(helper->Enqueue())) {
+    aRv.Throw(NS_ERROR_DOM_FILEHANDLE_UNKNOWN_ERR);
+    return nullptr;
+  }
 
   mLocation += aSize;
 
-  nsRefPtr<nsIDOMDOMRequest> request = fileRequest.forget();
-  request.forget(_retval);
-  return NS_OK;
+  return fileRequest.forget();
 }
 
-NS_IMETHODIMP
-LockedFile::Write(JS::Handle<JS::Value> aValue,
-                  JSContext* aCx,
-                  nsISupports** _retval)
+bool
+LockedFile::CheckStateForWrite(ErrorResult& aRv)
+{
+  if (!IsOpen()) {
+    aRv.Throw(NS_ERROR_DOM_FILEHANDLE_LOCKEDFILE_INACTIVE_ERR);
+    return false;
+  }
+
+  if (mMode != FileMode::Readwrite) {
+    aRv.Throw(NS_ERROR_DOM_FILEHANDLE_READ_ONLY_ERR);
+    return false;
+  }
+
+  // Do nothing if the window is closed
+  if (!GetOwner()) {
+    return false;
+  }
+
+  return true;
+}
+
+already_AddRefed<FileRequest>
+LockedFile::Truncate(const Optional<uint64_t>& aSize, ErrorResult& aRv)
 {
   NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
 
-  return WriteOrAppend(aValue, aCx, _retval, false);
-}
-
-NS_IMETHODIMP
-LockedFile::Append(JS::Handle<JS::Value> aValue,
-                   JSContext* aCx,
-                   nsISupports** _retval)
-{
-  NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
-
-  return WriteOrAppend(aValue, aCx, _retval, true);
-}
-
-NS_IMETHODIMP
-LockedFile::Truncate(uint64_t aSize,
-                     uint8_t aOptionalArgCount,
-                     nsISupports** _retval)
-{
-  NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
-
-  if (!IsOpen()) {
-    return NS_ERROR_DOM_FILEHANDLE_LOCKEDFILE_INACTIVE_ERR;
-  }
-
-  if (mMode != FileMode::Readwrite) {
-    return NS_ERROR_DOM_FILEHANDLE_READ_ONLY_ERR;
-  }
-
   uint64_t location;
-  if (aOptionalArgCount) {
+  if (aSize.WasPassed()) {
     // Just in case someone calls us from C++
-    NS_ASSERTION(aSize != UINT64_MAX, "Passed wrong size!");
-    location = aSize;
-  }
-  else {
+    NS_ASSERTION(aSize.Value() != UINT64_MAX, "Passed wrong size!");
+    location = aSize.Value();
+  } else {
     if (mLocation == UINT64_MAX) {
-      return NS_ERROR_DOM_FILEHANDLE_NOT_ALLOWED_ERR;
+      aRv.Throw(NS_ERROR_DOM_FILEHANDLE_NOT_ALLOWED_ERR);
+      return nullptr;
     }
     location = mLocation;
   }
 
-  // Do nothing if the window is closed
-  if (!GetOwner()) {
-    return NS_OK;
+  if (!CheckStateForWrite(aRv)) {
+    return nullptr;
   }
 
   nsRefPtr<FileRequest> fileRequest = GenerateFileRequest();
 
   nsRefPtr<TruncateHelper> helper =
     new TruncateHelper(this, fileRequest, location);
 
-  nsresult rv = helper->Enqueue();
-  NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_FILEHANDLE_UNKNOWN_ERR);
-
-  if (aOptionalArgCount) {
-    mLocation = aSize;
+  if (NS_FAILED(helper->Enqueue())) {
+    aRv.Throw(NS_ERROR_DOM_FILEHANDLE_UNKNOWN_ERR);
+    return nullptr;
   }
 
-  nsRefPtr<nsIDOMDOMRequest> request = fileRequest.forget();
-  request.forget(_retval);
-  return NS_OK;
+  if (aSize.WasPassed()) {
+    mLocation = aSize.Value();
+  }
+
+  return fileRequest.forget();
 }
 
-NS_IMETHODIMP
-LockedFile::Flush(nsISupports** _retval)
+already_AddRefed<FileRequest>
+LockedFile::Flush(ErrorResult& aRv)
 {
   NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
 
-  if (!IsOpen()) {
-    return NS_ERROR_DOM_FILEHANDLE_LOCKEDFILE_INACTIVE_ERR;
-  }
-
-  if (mMode != FileMode::Readwrite) {
-    return NS_ERROR_DOM_FILEHANDLE_READ_ONLY_ERR;
-  }
-
-  // Do nothing if the window is closed
-  if (!GetOwner()) {
-    return NS_OK;
+  if (!CheckStateForWrite(aRv)) {
+    return nullptr;
   }
 
   nsRefPtr<FileRequest> fileRequest = GenerateFileRequest();
 
   nsRefPtr<FlushHelper> helper = new FlushHelper(this, fileRequest);
 
-  nsresult rv = helper->Enqueue();
-  NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_FILEHANDLE_UNKNOWN_ERR);
+  if (NS_FAILED(helper->Enqueue())) {
+    aRv.Throw(NS_ERROR_DOM_FILEHANDLE_UNKNOWN_ERR);
+    return nullptr;
+  }
 
-  nsRefPtr<nsIDOMDOMRequest> request = fileRequest.forget();
-  request.forget(_retval);
-  return NS_OK;
+  return fileRequest.forget();
 }
 
-NS_IMETHODIMP
-LockedFile::Abort()
+void
+LockedFile::Abort(ErrorResult& aRv)
 {
   NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
 
   // We can't use IsOpen here since we need it to be possible to call Abort()
   // even from outside of transaction callbacks.
   if (mReadyState != LockedFile::INITIAL &&
       mReadyState != LockedFile::LOADING) {
-    return NS_ERROR_DOM_FILEHANDLE_NOT_ALLOWED_ERR;
+    aRv.Throw(NS_ERROR_DOM_FILEHANDLE_NOT_ALLOWED_ERR);
+    return;
   }
 
   bool needToFinish = mReadyState == INITIAL;
 
   mAborted = true;
   mReadyState = DONE;
 
   // Fire the abort event if there are no outstanding requests. Otherwise the
   // abort event will be fired when all outstanding requests finish.
   if (needToFinish) {
-    return Finish();
+    aRv = Finish();
   }
-
-  return NS_OK;
 }
 
 NS_IMETHODIMP
 LockedFile::Run()
 {
   NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
 
   // We're back at the event loop, no longer newborn.
@@ -824,70 +699,55 @@ LockedFile::OpenInputStream(bool aWholeF
 
   nsCOMPtr<nsIInputStream>& result = helper->Result();
   NS_ENSURE_TRUE(result, NS_ERROR_DOM_FILEHANDLE_UNKNOWN_ERR);
 
   result.forget(aResult);
   return NS_OK;
 }
 
-nsresult
-LockedFile::WriteOrAppend(JS::Handle<JS::Value> aValue,
-                          JSContext* aCx,
-                          nsISupports** _retval,
-                          bool aAppend)
+already_AddRefed<FileRequest>
+LockedFile::WriteOrAppend(nsIInputStream* aInputStream, uint64_t aInputLength,
+                          bool aAppend, ErrorResult& aRv)
 {
-  if (!IsOpen()) {
-    return NS_ERROR_DOM_FILEHANDLE_LOCKEDFILE_INACTIVE_ERR;
-  }
-
-  if (mMode != FileMode::Readwrite) {
-    return NS_ERROR_DOM_FILEHANDLE_READ_ONLY_ERR;
-  }
+  NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
 
   if (!aAppend && mLocation == UINT64_MAX) {
-    return NS_ERROR_DOM_FILEHANDLE_NOT_ALLOWED_ERR;
-  }
-
-  // Do nothing if the window is closed
-  if (!GetOwner()) {
-    return NS_OK;
+    aRv.Throw(NS_ERROR_DOM_FILEHANDLE_NOT_ALLOWED_ERR);
+    return nullptr;
   }
 
-  nsCOMPtr<nsIInputStream> inputStream;
-  uint64_t inputLength;
-  nsresult rv =
-    GetInputStreamForJSVal(aValue, aCx, getter_AddRefs(inputStream),
-                           &inputLength);
-  NS_ENSURE_SUCCESS(rv, rv);
+  if (!CheckStateForWrite(aRv)) {
+    return nullptr;
+  }
 
-  if (!inputLength) {
-    return NS_OK;
+  if (!aInputLength) {
+    return nullptr;
   }
 
   nsRefPtr<FileRequest> fileRequest = GenerateFileRequest();
 
   uint64_t location = aAppend ? UINT64_MAX : mLocation;
 
   nsRefPtr<WriteHelper> helper =
-    new WriteHelper(this, fileRequest, location, inputStream, inputLength);
+    new WriteHelper(this, fileRequest, location, aInputStream, aInputLength);
 
-  rv = helper->Enqueue();
-  NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_FILEHANDLE_UNKNOWN_ERR);
+  if (NS_FAILED(helper->Enqueue())) {
+    aRv.Throw(NS_ERROR_DOM_FILEHANDLE_UNKNOWN_ERR);
+    return nullptr;
+  }
 
   if (aAppend) {
     mLocation = UINT64_MAX;
   }
   else {
-    mLocation += inputLength;
+    mLocation += aInputLength;
   }
 
-  nsRefPtr<nsIDOMDOMRequest> request = fileRequest.forget();
-  request.forget(_retval);
-  return NS_OK;
+  return fileRequest.forget();
 }
 
 nsresult
 LockedFile::Finish()
 {
   NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
 
   nsRefPtr<FinishHelper> helper(new FinishHelper(this));
@@ -898,16 +758,23 @@ LockedFile::Finish()
   nsIEventTarget* target = service->StreamTransportTarget();
 
   nsresult rv = target->Dispatch(helper, NS_DISPATCH_NORMAL);
   NS_ENSURE_SUCCESS(rv, rv);
 
   return NS_OK;
 }
 
+/* virtual */ JSObject*
+LockedFile::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope)
+{
+  return LockedFileBinding::Wrap(aCx, aScope, this);
+}
+
+
 FinishHelper::FinishHelper(LockedFile* aLockedFile)
 : mLockedFile(aLockedFile),
   mAborted(aLockedFile->mAborted)
 {
   mParallelStreams.SwapElements(aLockedFile->mParallelStreams);
   mStream.swap(aLockedFile->mStream);
 }
 
@@ -1147,8 +1014,10 @@ OpenStreamHelper::DoAsyncRun(nsISupports
                    FileStreamWrapper::NOTIFY_DESTROY;
 
   mStream = mWholeFile ?
     new FileInputStreamWrapper(aStream, this, 0, mLength, flags) :
     new FileInputStreamWrapper(aStream, this, mStart, mLength, flags);
 
   return NS_OK;
 }
+
+END_FILE_NAMESPACE
--- a/dom/file/LockedFile.h
+++ b/dom/file/LockedFile.h
@@ -2,48 +2,51 @@
 /* vim: set ts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
  * You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef mozilla_dom_file_lockedfile_h__
 #define mozilla_dom_file_lockedfile_h__
 
+#include "FileCommon.h"
 #include "mozilla/Attributes.h"
-#include "FileCommon.h"
 #include "mozilla/dom/FileModeBinding.h"
-#include "nsIDOMLockedFile.h"
+#include "mozilla/dom/TypedArray.h"
+#include "nsDOMEventTargetHelper.h"
+#include "nsIInputStream.h"
 #include "nsIRunnable.h"
 
-#include "nsDOMEventTargetHelper.h"
-
-class nsIInputStream;
+namespace mozilla {
+namespace dom {
+class DOMFileMetadataParameters;
+class DOMRequest;
+} // namespace dom
+} // namespace mozilla
 
 namespace mozilla {
 class EventChainPreVisitor;
 } // namespace mozilla
 
 BEGIN_FILE_NAMESPACE
 
 class FileHandle;
 class FileRequest;
 class MetadataHelper;
 
 class LockedFile : public nsDOMEventTargetHelper,
-                   public nsIDOMLockedFile,
                    public nsIRunnable
 {
   friend class FinishHelper;
   friend class FileService;
   friend class FileHelper;
   friend class MetadataHelper;
 
 public:
   NS_DECL_ISUPPORTS_INHERITED
-  NS_DECL_NSIDOMLOCKEDFILE
   NS_DECL_NSIRUNNABLE
 
   NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(LockedFile, nsDOMEventTargetHelper)
 
   enum RequestMode
   {
     NORMAL = 0, // Sequential
     PARALLEL
@@ -86,36 +89,148 @@ public:
   {
     return mFileHandle;
   }
 
   nsresult
   OpenInputStream(bool aWholeFile, uint64_t aStart, uint64_t aLength,
                   nsIInputStream** aResult);
 
+  // WrapperCache
+  nsPIDOMWindow* GetParentObject() const
+  {
+    return GetOwner();
+  }
+
+  virtual JSObject*
+  WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope) MOZ_OVERRIDE;
+
+  // WebIDL
+  FileHandle* GetFileHandle() const
+  {
+    return Handle();
+  }
+
+  FileMode Mode() const
+  {
+    return mMode;
+  }
+
+  bool Active() const
+  {
+    return IsOpen();
+  }
+
+  Nullable<uint64_t> GetLocation() const
+  {
+    if (mLocation == UINT64_MAX) {
+      return Nullable<uint64_t>();
+    }
+    return Nullable<uint64_t>(mLocation);
+  }
+
+  void SetLocation(const Nullable<uint64_t>& aLocation)
+  {
+    // Null means the end-of-file.
+    if (aLocation.IsNull()) {
+      mLocation = UINT64_MAX;
+    } else {
+      mLocation = aLocation.Value();
+    }
+  }
+
+  already_AddRefed<FileRequest>
+  GetMetadata(const DOMFileMetadataParameters& aParameters, ErrorResult& aRv);
+
+  already_AddRefed<FileRequest>
+  ReadAsArrayBuffer(uint64_t aSize, ErrorResult& aRv);
+
+  already_AddRefed<FileRequest>
+  ReadAsText(uint64_t aSize, const nsAString& aEncoding, ErrorResult& aRv);
+
+  template<class T>
+  already_AddRefed<FileRequest>
+  Write(const T& aValue, ErrorResult& aRv)
+  {
+    uint64_t length;
+    nsCOMPtr<nsIInputStream> stream = GetInputStream(aValue, &length, aRv);
+    if (aRv.Failed()) {
+      return nullptr;
+    }
+    return Write(stream, length, aRv);
+  }
+
+  template<class T>
+  already_AddRefed<FileRequest>
+  Append(const T& aValue, ErrorResult& aRv)
+  {
+    uint64_t length;
+    nsCOMPtr<nsIInputStream> stream = GetInputStream(aValue, &length, aRv);
+    if (aRv.Failed()) {
+      return nullptr;
+    }
+    return Append(stream, length, aRv);
+  }
+
+  already_AddRefed<FileRequest>
+  Truncate(const Optional<uint64_t>& aSize, ErrorResult& aRv);
+
+  already_AddRefed<FileRequest>
+  Flush(ErrorResult& aRv);
+
+  void Abort(ErrorResult& aRv);
+
+  IMPL_EVENT_HANDLER(complete)
+  IMPL_EVENT_HANDLER(abort)
+  IMPL_EVENT_HANDLER(error)
+
 private:
   LockedFile();
   ~LockedFile();
 
   void
   OnNewRequest();
 
   void
   OnRequestFinished();
 
+  bool CheckStateAndArgumentsForRead(uint64_t aSize, ErrorResult& aRv);
+  bool CheckStateForWrite(ErrorResult& aRv);
+
   already_AddRefed<FileRequest>
   GenerateFileRequest();
 
-  nsresult
-  WriteOrAppend(JS::Handle<JS::Value> aValue, JSContext* aCx,
-                nsISupports** _retval, bool aAppend);
+  already_AddRefed<FileRequest>
+  Write(nsIInputStream* aInputStream, uint64_t aInputLength, ErrorResult& aRv)
+  {
+    return WriteOrAppend(aInputStream, aInputLength, false, aRv);
+  }
+
+  already_AddRefed<FileRequest>
+  Append(nsIInputStream* aInputStream, uint64_t aInputLength, ErrorResult& aRv)
+  {
+    return WriteOrAppend(aInputStream, aInputLength, true, aRv);
+  }
+
+  already_AddRefed<FileRequest>
+  WriteOrAppend(nsIInputStream* aInputStream, uint64_t aInputLength,
+                bool aAppend, ErrorResult& aRv);
 
   nsresult
   Finish();
 
+  static already_AddRefed<nsIInputStream>
+  GetInputStream(const ArrayBuffer& aValue, uint64_t* aInputLength,
+                 ErrorResult& aRv);
+  static already_AddRefed<nsIInputStream>
+  GetInputStream(nsIDOMBlob* aValue, uint64_t* aInputLength, ErrorResult& aRv);
+  static already_AddRefed<nsIInputStream>
+  GetInputStream(const nsAString& aValue, uint64_t* aInputLength,
+                 ErrorResult& aRv);
+
   nsRefPtr<FileHandle> mFileHandle;
   ReadyState mReadyState;
   FileMode mMode;
   RequestMode mRequestMode;
   uint64_t mLocation;
   uint32_t mPendingRequests;
 
   nsTArray<nsCOMPtr<nsISupports> > mParallelStreams;
--- a/dom/file/moz.build
+++ b/dom/file/moz.build
@@ -1,22 +1,16 @@
 # -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
 # vim: set filetype=python:
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 TEST_DIRS += ['test']
 
-XPIDL_SOURCES += [
-    'nsIDOMLockedFile.idl',
-]
-
-XPIDL_MODULE = 'dom_file'
-
 EXPORTS += [
     'nsIFileStorage.h',
 ]
 
 EXPORTS.mozilla.dom.file += [
     'ArchiveEvent.h',
     'ArchiveReader.h',
     'ArchiveRequest.h',
deleted file mode 100644
--- a/dom/file/nsIDOMLockedFile.idl
+++ /dev/null
@@ -1,60 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set ts=2 et sw=2 tw=80: */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this file,
- * You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#include "nsISupports.idl"
-
-interface nsIDOMEventListener;
-
-[scriptable, builtinclass, uuid(a09cdc35-6b1e-42ce-95bb-f8f10a354202)]
-interface nsIDOMLockedFile : nsISupports
-{
-  readonly attribute nsISupports /* FileHandle */ fileHandle;
-
-  // "readonly" or "readwrite"
-  readonly attribute DOMString mode;
-
-  readonly attribute boolean active;
-
-  [implicit_jscontext]
-  attribute jsval location;
-
-  [implicit_jscontext]
-  nsISupports /* FileRequest */
-  getMetadata(/* DOMFileMetadataParameters */
-              [optional /* all */] in jsval parameters);
-
-  [implicit_jscontext]
-  nsISupports /* FileRequest */
-  readAsArrayBuffer(in unsigned long long size);
-
-  nsISupports /* FileRequest */
-  readAsText(in unsigned long long size,
-             [optional] in DOMString encoding);
-
-  [implicit_jscontext]
-  nsISupports /* FileRequest */
-  write(in jsval value);
-
-  [implicit_jscontext]
-  nsISupports /* FileRequest */
-  append(in jsval value);
-
-  [optional_argc]
-  nsISupports /* FileRequest */
-  truncate([optional] in unsigned long long size);
-
-  nsISupports /* FileRequest */
-  flush();
-
-  void
-  abort();
-
-  [implicit_jscontext] attribute jsval oncomplete;
-
-  [implicit_jscontext] attribute jsval onabort;
-
-  [implicit_jscontext] attribute jsval onerror;
-};
--- a/dom/webidl/FileHandle.webidl
+++ b/dom/webidl/FileHandle.webidl
@@ -1,15 +1,13 @@
 /* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
-interface LockedFile;
-
 interface FileHandle : EventTarget {
   readonly attribute DOMString name;
   readonly attribute DOMString type;
 
   [Throws]
   LockedFile open(optional FileMode mode = "readonly");
 
   [Throws]
--- a/dom/webidl/FileRequest.webidl
+++ b/dom/webidl/FileRequest.webidl
@@ -1,13 +1,11 @@
 /* -*- Mode: IDL; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* vim: set ts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
-interface LockedFile;
-
 interface FileRequest : DOMRequest {
   readonly attribute LockedFile? lockedFile;
 
   attribute EventHandler onprogress;
 };
--- a/dom/webidl/LockedFile.webidl
+++ b/dom/webidl/LockedFile.webidl
@@ -2,8 +2,47 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
  * You can obtaone at http://mozilla.org/MPL/2.0/. */
 
 dictionary DOMFileMetadataParameters
 {
   boolean size = true;
   boolean lastModified = true;
 };
+
+interface LockedFile : EventTarget
+{
+  readonly attribute FileHandle? fileHandle;
+  readonly attribute FileMode mode;
+  readonly attribute boolean active;
+  attribute unsigned long long? location;
+
+  [Throws]
+  FileRequest? getMetadata(optional DOMFileMetadataParameters parameters);
+  [Throws]
+  FileRequest? readAsArrayBuffer(unsigned long long size);
+  [Throws]
+  FileRequest? readAsText(unsigned long long size,
+                         optional DOMString? encoding = null);
+
+  [Throws]
+  FileRequest? write(ArrayBuffer value);
+  [Throws]
+  FileRequest? write(Blob value);
+  [Throws]
+  FileRequest? write(DOMString value);
+  [Throws]
+  FileRequest? append(ArrayBuffer value);
+  [Throws]
+  FileRequest? append(Blob value);
+  [Throws]
+  FileRequest? append(DOMString value);
+  [Throws]
+  FileRequest? truncate(optional unsigned long long size);
+  [Throws]
+  FileRequest? flush();
+  [Throws]
+  void abort();
+
+  attribute EventHandler oncomplete;
+  attribute EventHandler onabort;
+  attribute EventHandler onerror;
+};
--- a/js/xpconnect/src/dom_quickstubs.qsconf
+++ b/js/xpconnect/src/dom_quickstubs.qsconf
@@ -60,19 +60,16 @@ members = [
     'nsIBoxObject.screenX',
     'nsIBoxObject.screenY',
     'nsIBoxObject.width',
     'nsIBoxObject.height',
 
     # dom/indexedDB
     'nsIIndexedDatabaseManager.*',
 
-    # dom/file
-    'nsIDOMLockedFile.*',
-
     # dom/quota
     'nsIQuotaManager.*',
     'nsIQuotaRequest.*',
     'nsIUsageCallback.*',
     ]
 
 # Most interfaces can be found by searching the includePath; to find
 # nsIDOMEvent, for example, just look for nsIDOMEvent.idl.  But IDL filenames