Coverage Report

Created: 2018-09-25 14:53

/work/obj-fuzz/dist/include/mozilla/NullPrincipalURI.h
Line
Count
Source (jump to first uncovered line)
1
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2
 * vim: sw=2 ts=2 sts=2 expandtab
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
/**
8
 * This wraps nsSimpleURI so that all calls to it are done on the main thread.
9
 */
10
11
#ifndef mozilla_NullPrincipalURI_h
12
#define mozilla_NullPrincipalURI_h
13
14
#include "nsIURI.h"
15
#include "nsISizeOf.h"
16
#include "nsString.h"
17
#include "mozilla/Attributes.h"
18
#include "nsIIPCSerializableURI.h"
19
#include "mozilla/MemoryReporting.h"
20
#include "NullPrincipal.h"
21
#include "nsID.h"
22
#include "nsIURIMutator.h"
23
24
// {51fcd543-3b52-41f7-b91b-6b54102236e6}
25
#define NS_NULLPRINCIPALURI_IMPLEMENTATION_CID \
26
  {0x51fcd543, 0x3b52, 0x41f7, \
27
    {0xb9, 0x1b, 0x6b, 0x54, 0x10, 0x22, 0x36, 0xe6} }
28
29
namespace mozilla {
30
31
class Encoding;
32
33
class NullPrincipalURI final : public nsIURI
34
                             , public nsISizeOf
35
                             , public nsIIPCSerializableURI
36
{
37
public:
38
  NS_DECL_THREADSAFE_ISUPPORTS
39
  NS_DECL_NSIURI
40
  NS_DECL_NSIIPCSERIALIZABLEURI
41
42
  // nsISizeOf
43
  virtual size_t SizeOfExcludingThis(MallocSizeOf aMallocSizeOf) const override;
44
  virtual size_t SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const override;
45
46
  // Returns null on failure.
47
  static already_AddRefed<NullPrincipalURI> Create();
48
49
private:
50
  NullPrincipalURI();
51
  NullPrincipalURI(const NullPrincipalURI& aOther);
52
53
  ~NullPrincipalURI() {}
54
55
  nsresult Init();
56
57
  nsAutoCStringN<NSID_LENGTH> mPath;
58
59
  nsresult Clone(nsIURI** aURI);
60
  nsresult SetSpecInternal(const nsACString &input);
61
  nsresult SetScheme(const nsACString &input);
62
  nsresult SetUserPass(const nsACString &input);
63
  nsresult SetUsername(const nsACString &input);
64
  nsresult SetPassword(const nsACString &input);
65
  nsresult SetHostPort(const nsACString &aValue);
66
  nsresult SetHost(const nsACString &input);
67
  nsresult SetPort(int32_t port);
68
  nsresult SetPathQueryRef(const nsACString &input);
69
  nsresult SetRef(const nsACString &input);
70
  nsresult SetFilePath(const nsACString &input);
71
  nsresult SetQuery(const nsACString &input);
72
  nsresult SetQueryWithEncoding(const nsACString &input, const Encoding* encoding);
73
  bool Deserialize(const mozilla::ipc::URIParams&);
74
75
public:
76
  class Mutator final
77
      : public nsIURIMutator
78
      , public BaseURIMutator<NullPrincipalURI>
79
  {
80
    NS_DECL_ISUPPORTS
81
    NS_FORWARD_SAFE_NSIURISETTERS_RET(mURI)
82
83
    NS_IMETHOD Deserialize(const mozilla::ipc::URIParams& aParams) override
84
    {
85
      return InitFromIPCParams(aParams);
86
    }
87
88
    NS_IMETHOD Finalize(nsIURI** aURI) override
89
    {
90
      mURI.forget(aURI);
91
      return NS_OK;
92
    }
93
94
    NS_IMETHOD SetSpec(const nsACString & aSpec, nsIURIMutator** aMutator) override
95
    {
96
      if (aMutator) {
97
        nsCOMPtr<nsIURIMutator> mutator = this;
98
        mutator.forget(aMutator);
99
      }
100
      return NS_ERROR_NOT_IMPLEMENTED;
101
    }
102
103
0
    explicit Mutator() { }
104
  private:
105
    virtual ~Mutator() { }
106
107
    friend class NullPrincipalURI;
108
  };
109
110
  friend class BaseURIMutator<NullPrincipalURI>;
111
};
112
113
} // mozilla namespace
114
115
#endif // mozilla_NullPrincipalURI_h