mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-19 16:25:38 +00:00
Backed out changeset 1cdd50772eec (bug 1353629)
This commit is contained in:
parent
1f2e49708e
commit
64f9722117
@ -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
|
||||
|
@ -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<BlobImpl>
|
||||
Deserialize(const IPCBlob& aIPCBlob)
|
||||
{
|
||||
nsCOMPtr<nsIInputStream> inputStream =
|
||||
DeserializeIPCStream(aIPCBlob.inputStream());
|
||||
|
||||
RefPtr<BlobImpl> 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<typename M>
|
||||
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<nsIInputStream> 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
|
@ -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<BlobImpl>
|
||||
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
|
@ -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',
|
||||
|
Loading…
Reference in New Issue
Block a user