Line data Source code
1 : /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 : /* vim: set ts=2 sw=2 sts=2 et 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 "FileChannelChild.h"
8 :
9 : #include "mozilla/Unused.h"
10 : #include "mozilla/dom/ContentChild.h"
11 : #include "mozilla/net/NeckoChild.h"
12 :
13 : namespace mozilla {
14 : namespace net {
15 :
16 5386 : NS_IMPL_ISUPPORTS_INHERITED(FileChannelChild, nsFileChannel, nsIChildChannel)
17 :
18 279 : FileChannelChild::FileChannelChild(nsIURI *uri)
19 : : nsFileChannel(uri)
20 279 : , mIPCOpen(false)
21 : {
22 279 : }
23 :
24 : NS_IMETHODIMP
25 0 : FileChannelChild::ConnectParent(uint32_t id)
26 : {
27 : mozilla::dom::ContentChild* cc =
28 0 : static_cast<mozilla::dom::ContentChild*>(gNeckoChild->Manager());
29 0 : if (cc->IsShuttingDown()) {
30 0 : return NS_ERROR_FAILURE;
31 : }
32 :
33 0 : if (!gNeckoChild->SendPFileChannelConstructor(this, id)) {
34 0 : return NS_ERROR_FAILURE;
35 : }
36 :
37 0 : AddIPDLReference();
38 0 : return NS_OK;
39 : }
40 :
41 : NS_IMETHODIMP
42 0 : FileChannelChild::CompleteRedirectSetup(nsIStreamListener *listener,
43 : nsISupports *ctx)
44 : {
45 : nsresult rv;
46 :
47 0 : if (mLoadInfo && mLoadInfo->GetEnforceSecurity()) {
48 0 : MOZ_ASSERT(!ctx, "Context should be null");
49 0 : rv = AsyncOpen2(listener);
50 : } else {
51 0 : rv = AsyncOpen(listener, ctx);
52 : }
53 :
54 0 : if (NS_WARN_IF(NS_FAILED(rv))) {
55 0 : return rv;
56 : }
57 :
58 0 : if (mIPCOpen) {
59 0 : Unused << Send__delete__(this);
60 : }
61 :
62 0 : return NS_OK;
63 : }
64 :
65 : void
66 0 : FileChannelChild::AddIPDLReference()
67 : {
68 0 : AddRef();
69 0 : mIPCOpen = true;
70 0 : }
71 :
72 : void
73 0 : FileChannelChild::ActorDestroy(ActorDestroyReason why)
74 : {
75 0 : MOZ_ASSERT(mIPCOpen);
76 0 : mIPCOpen = false;
77 0 : Release();
78 0 : }
79 :
80 : } // namespace net
81 : } // namespace mozilla
|