diff --git a/dom/file/ipc/IPCBlob.ipdlh b/dom/file/ipc/IPCBlob.ipdlh deleted file mode 100644 index 7097c3aa9b25..000000000000 --- a/dom/file/ipc/IPCBlob.ipdlh +++ /dev/null @@ -1,47 +0,0 @@ -/* 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 protocol PChildToParentStream; -include protocol PParentToChildStream; - -include IPCStream; -include ProtocolTypes; - -using struct mozilla::void_t - from "ipc/IPCMessageUtils.h"; - -namespace mozilla { -namespace dom { - -// This contains any extra bit for making a File out of a Blob. -struct IPCFile -{ - nsString name; - int64_t lastModified; - nsString DOMPath; -}; - -// Union for blob vs file. -union IPCFileUnion -{ - // For Blob. - void_t; - - // For File. - IPCFile; -}; - -struct IPCBlob -{ - nsString type; - uint64_t size; - - IPCStream inputStream; - - IPCFileUnion file; -}; - -} // namespace dom -} // namespace mozilla - diff --git a/dom/file/ipc/IPCBlobUtils.cpp b/dom/file/ipc/IPCBlobUtils.cpp deleted file mode 100644 index 20ace6526c3e..000000000000 --- a/dom/file/ipc/IPCBlobUtils.cpp +++ /dev/null @@ -1,118 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim: set ts=8 sts=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 "IPCBlobUtils.h" -#include "mozilla/dom/IPCBlob.h" -#include "prtime.h" - -namespace mozilla { -namespace dom { -namespace IPCBlobUtils { - -already_AddRefed -Deserialize(const IPCBlob& aIPCBlob) -{ - nsCOMPtr inputStream = - DeserializeIPCStream(aIPCBlob.inputStream()); - - RefPtr blobImpl; - - if (aIPCBlob.file().type() == IPCFileUnion::Tvoid_t) { - blobImpl = StreamBlobImpl::Create(inputStream, - aIPCBlob.type(), - aIPCBlob.size()); - } else { - const IPCFile& file = aIPCBlob.file().get_IPCFile(); - blobImpl = StreamBlobImpl::Create(inputStream, - file.name(), - aIPCBlob.type(), - file.lastModified(), - aIPCBlob.size()); - blobImpl->SetDOMPath(file.DOMPath()); - } - - return blobImpl.forget(); -} - -template -nsresult -SerializeInternal(BlobImpl* aBlobImpl, M* aManager, IPCBlob& aIPCBlob) -{ - MOZ_ASSERT(aBlobImpl); - - nsAutoString value; - aBlobImpl->GetType(value); - aIPCBlob.type() = value; - - ErrorResult rv; - aIPCBlob.size() = aBlobImpl->GetSize(rv); - if (NS_WARN_IF(rv.Failed())) { - return rv.StealNSResult(); - } - - if (!aBlobImpl->IsFile()) { - aIPCBlob.file() = void_t(); - } else { - IPCFile file; - - aBlobImpl->GetName(value); - file.name() = value; - - file.lastModified() = aBlobImpl->GetLastModified(rv) * PR_USEC_PER_MSEC; - if (NS_WARN_IF(rv.Failed())) { - return rv.StealNSResult(); - } - - aBlobImpl->GetDOMPath(value); - file.DOMPath() = value; - - aIPCBlob.file() = file; - } - - ErrorResult error; - nsCOMPtr inputStream; - aBlobImpl->GetInternalStream(getter_AddRefs(inputStream), error); - if (NS_WARN_IF(error.Failed())) { - return error.StealNSResult(); - } - - AutoIPCStream ipcStream(true /* delayStart */); - - if (!ipcStream.Serialize(inputStream, aManager)) { - return NS_ERROR_FAILURE; - } - - aIPCBlob.inputStream() = ipcStream.TakeValue(); - return NS_OK; -} - -nsresult -Serialize(BlobImpl* aBlobImpl, nsIContentChild* aManager, IPCBlob& aIPCBlob) -{ - return SerializeInternal(aBlobImpl, aManager, aIPCBlob); -} - -nsresult -Serialize(BlobImpl* aBlobImpl, PBackgroundChild* aManager, IPCBlob& aIPCBlob) -{ - return SerializeInternal(aBlobImpl, aManager, aIPCBlob); -} - -nsresult -Serialize(BlobImpl* aBlobImpl, nsIContentParent* aManager, IPCBlob& aIPCBlob) -{ - return SerializeInternal(aBlobImpl, aManager, aIPCBlob); -} - -nsresult -Serialize(BlobImpl* aBlobImpl, PBackgroundParent* aManager, IPCBlob& aIPCBlob) -{ - return SerializeInternal(aBlobImpl, aManager, aIPCBlob); -} - -} // IPCBlobUtils namespace -} // dom namespace -} // mozilla namespace diff --git a/dom/file/ipc/IPCBlobUtils.h b/dom/file/ipc/IPCBlobUtils.h deleted file mode 100644 index 545185e230ee..000000000000 --- a/dom/file/ipc/IPCBlobUtils.h +++ /dev/null @@ -1,47 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim: set ts=8 sts=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_IPCBlobUtils_h -#define mozilla_dom_IPCBlobUtils_h - -#include "mozilla/dom/File.h" - -namespace mozilla { - -namespace ipc { -class PBackgroundChild; -class PBackgroundParent; -} - -namespace dom { - -class nsIContentChild; -class nsIContentParent; - -namespace IPCBlobUtils { - -already_AddRefed -Deserialize(const IPCBlob& aIPCBlob); - -// These 4 methods serialize aBlobImpl into aIPCBlob using the right manager. - -nsresult -Serialize(BlobImpl* aBlobImpl, nsIContentChild* aManager, IPCBlob& aIPCBlob); - -nsresult -Serialize(BlobImpl* aBlobImpl, PBackgroundChild* aManager, IPCBlob& aIPCBlob); - -nsresult -Serialize(BlobImpl* aBlobImpl, nsIContentParent* aManager, IPCBlob& aIPCBlob); - -nsresult -Serialize(BlobImpl* aBlobImpl, PBackgroundParent* aManager, IPCBlob& aIPCBlob); - -} // IPCBlobUtils -} // dom namespace -} // mozilla namespace - -#endif // mozilla_dom_IPCBlobUtils_h diff --git a/dom/file/ipc/moz.build b/dom/file/ipc/moz.build index 2ff658c025ec..1857261726ec 100644 --- a/dom/file/ipc/moz.build +++ b/dom/file/ipc/moz.build @@ -12,19 +12,13 @@ EXPORTS.mozilla.dom.ipc += [ 'nsIRemoteBlob.h', ] -EXPORTS.mozilla.dom += [ - 'IPCBlobUtils.h', -] - UNIFIED_SOURCES += [ 'Blob.cpp', - 'IPCBlobUtils.cpp', 'MemoryStreamParent.cpp', ] IPDL_SOURCES += [ 'BlobTypes.ipdlh', - 'IPCBlob.ipdlh', 'PBlob.ipdl', 'PBlobStream.ipdl', 'PMemoryStream.ipdl',