/src/mozilla-central/dom/file/ipc/PendingIPCBlobParent.cpp
Line | Count | Source (jump to first uncovered line) |
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 | | PendingIPCBlobParent::Create(PBackgroundParent* aManager, |
19 | | BlobImpl* aBlobImpl) |
20 | 0 | { |
21 | 0 | MOZ_ASSERT(aManager); |
22 | 0 | MOZ_ASSERT(aBlobImpl); |
23 | 0 |
|
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 | 0 | } |
29 | 0 | |
30 | 0 | PendingIPCBlobParent* actor = new PendingIPCBlobParent(aBlobImpl); |
31 | 0 | if (!aManager->SendPPendingIPCBlobConstructor(actor, ipcBlob)) { |
32 | 0 | // The actor will be deleted by the manager. |
33 | 0 | return nullptr; |
34 | 0 | } |
35 | 0 | |
36 | 0 | return actor; |
37 | 0 | } |
38 | | |
39 | | PendingIPCBlobParent::PendingIPCBlobParent(BlobImpl* aBlobImpl) |
40 | | : mBlobImpl(aBlobImpl) |
41 | 0 | {} |
42 | | |
43 | | IPCResult |
44 | | PendingIPCBlobParent::Recv__delete__(const PendingIPCBlobData& aData) |
45 | 0 | { |
46 | 0 | if (aData.file().type() == PendingIPCFileUnion::Tvoid_t) { |
47 | 0 | mBlobImpl->SetLazyData(VoidString(), aData.type(), aData.size(), INT64_MAX); |
48 | 0 | } else { |
49 | 0 | const PendingIPCFileData& fileData = |
50 | 0 | aData.file().get_PendingIPCFileData(); |
51 | 0 | mBlobImpl->SetLazyData(fileData.name(), aData.type(), aData.size(), |
52 | 0 | fileData.lastModified()); |
53 | 0 | } |
54 | 0 |
|
55 | 0 | return IPC_OK(); |
56 | 0 | } |
57 | | |
58 | | } // namespace dom |
59 | | } // namespace mozilla |