Coverage Report

Created: 2018-09-25 14:53

/src/mozilla-central/netwerk/base/nsBase64Encoder.cpp
Line
Count
Source (jump to first uncovered line)
1
/* This Source Code Form is subject to the terms of the Mozilla Public
2
 * License, v. 2.0. If a copy of the MPL was not distributed with this
3
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4
5
#include "nsBase64Encoder.h"
6
7
#include "mozilla/Base64.h"
8
9
NS_IMPL_ISUPPORTS(nsBase64Encoder, nsIOutputStream)
10
11
NS_IMETHODIMP
12
nsBase64Encoder::Close()
13
0
{
14
0
  return NS_OK;
15
0
}
16
17
NS_IMETHODIMP
18
nsBase64Encoder::Flush()
19
0
{
20
0
  return NS_OK;
21
0
}
22
23
NS_IMETHODIMP
24
nsBase64Encoder::Write(const char* aBuf, uint32_t aCount, uint32_t* _retval)
25
0
{
26
0
  mData.Append(aBuf, aCount);
27
0
  *_retval = aCount;
28
0
  return NS_OK;
29
0
}
30
31
NS_IMETHODIMP
32
nsBase64Encoder::WriteFrom(nsIInputStream* aStream, uint32_t aCount,
33
                           uint32_t* _retval)
34
0
{
35
0
  return NS_ERROR_NOT_IMPLEMENTED;
36
0
}
37
38
NS_IMETHODIMP
39
nsBase64Encoder::WriteSegments(nsReadSegmentFun aReader,
40
                               void* aClosure,
41
                               uint32_t aCount,
42
                               uint32_t* _retval)
43
0
{
44
0
  return NS_ERROR_NOT_IMPLEMENTED;
45
0
}
46
47
NS_IMETHODIMP
48
nsBase64Encoder::IsNonBlocking(bool* aNonBlocking)
49
0
{
50
0
  *aNonBlocking = false;
51
0
  return NS_OK;
52
0
}
53
54
nsresult
55
nsBase64Encoder::Finish(nsACString& result)
56
0
{
57
0
  nsresult rv = mozilla::Base64Encode(mData, result);
58
0
  if (NS_FAILED(rv)) {
59
0
    return rv;
60
0
  }
61
0
62
0
  // Free unneeded memory and allow reusing the object
63
0
  mData.Truncate();
64
0
  return NS_OK;
65
0
}