Coverage Report

Created: 2018-09-25 14:53

/src/mozilla-central/netwerk/protocol/file/FileChannelChild.cpp
Line
Count
Source (jump to first uncovered line)
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
NS_IMPL_ISUPPORTS_INHERITED(FileChannelChild, nsFileChannel, nsIChildChannel)
17
18
FileChannelChild::FileChannelChild(nsIURI *uri)
19
  : nsFileChannel(uri)
20
  , mIPCOpen(false)
21
0
{
22
0
}
23
24
NS_IMETHODIMP
25
FileChannelChild::ConnectParent(uint32_t id)
26
0
{
27
0
  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
0
  }
32
0
33
0
  if (!gNeckoChild->SendPFileChannelConstructor(this, id)) {
34
0
    return NS_ERROR_FAILURE;
35
0
  }
36
0
37
0
  AddIPDLReference();
38
0
  return NS_OK;
39
0
}
40
41
NS_IMETHODIMP
42
FileChannelChild::CompleteRedirectSetup(nsIStreamListener *listener,
43
                                        nsISupports *ctx)
44
0
{
45
0
  nsresult rv;
46
0
47
0
  if (mLoadInfo && mLoadInfo->GetEnforceSecurity()) {
48
0
    MOZ_ASSERT(!ctx, "Context should be null");
49
0
    rv = AsyncOpen2(listener);
50
0
  } else {
51
0
    rv = AsyncOpen(listener, ctx);
52
0
  }
53
0
54
0
  if (NS_WARN_IF(NS_FAILED(rv))) {
55
0
    return rv;
56
0
  }
57
0
58
0
  if (mIPCOpen) {
59
0
    Unused << Send__delete__(this);
60
0
  }
61
0
62
0
  return NS_OK;
63
0
}
64
65
void
66
FileChannelChild::AddIPDLReference()
67
0
{
68
0
  AddRef();
69
0
  mIPCOpen = true;
70
0
}
71
72
void
73
FileChannelChild::ActorDestroy(ActorDestroyReason why)
74
0
{
75
0
  MOZ_ASSERT(mIPCOpen);
76
0
  mIPCOpen = false;
77
0
  Release();
78
0
}
79
80
} // namespace net
81
} // namespace mozilla