Line data Source code
1 : /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 : /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 : /* This Source Code Form is subject to the terms of the Mozilla Public
4 : * License, v. 2.0. If a copy of the MPL was not distributed with this
5 : * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 :
7 : #include "PendingIPCBlobParent.h"
8 : #include "mozilla/ipc/PBackgroundParent.h"
9 :
10 : namespace mozilla {
11 :
12 : using namespace ipc;
13 :
14 : namespace dom {
15 :
16 : /* static */
17 : PendingIPCBlobParent*
18 0 : PendingIPCBlobParent::Create(PBackgroundParent* aManager,
19 : BlobImpl* aBlobImpl)
20 : {
21 0 : MOZ_ASSERT(aManager);
22 0 : MOZ_ASSERT(aBlobImpl);
23 :
24 0 : IPCBlob ipcBlob;
25 0 : nsresult rv = IPCBlobUtils::Serialize(aBlobImpl, aManager, ipcBlob);
26 0 : if (NS_WARN_IF(NS_FAILED(rv))) {
27 0 : return nullptr;
28 : }
29 :
30 0 : PendingIPCBlobParent* actor = new PendingIPCBlobParent(aBlobImpl);
31 0 : if (!aManager->SendPPendingIPCBlobConstructor(actor, ipcBlob)) {
32 : // The actor will be deleted by the manager.
33 0 : return nullptr;
34 : }
35 :
36 0 : return actor;
37 : }
38 :
39 0 : PendingIPCBlobParent::PendingIPCBlobParent(BlobImpl* aBlobImpl)
40 0 : : mBlobImpl(aBlobImpl)
41 0 : {}
42 :
43 : IPCResult
44 0 : PendingIPCBlobParent::Recv__delete__(const PendingIPCBlobData& aData)
45 : {
46 0 : if (aData.file().type() == PendingIPCFileUnion::Tvoid_t) {
47 0 : mBlobImpl->SetLazyData(NullString(), aData.type(), aData.size(), INT64_MAX);
48 : } else {
49 : const PendingIPCFileData& fileData =
50 0 : aData.file().get_PendingIPCFileData();
51 0 : mBlobImpl->SetLazyData(fileData.name(), aData.type(), aData.size(),
52 0 : fileData.lastModified());
53 : }
54 :
55 0 : return IPC_OK();
56 : }
57 :
58 : } // namespace dom
59 9 : } // namespace mozilla
|