Bug 1684463 - [devtools] Part 1: Shorten the _createAttribute function by refactoring...
[gecko.git] / layout / style / URLExtraData.cpp
blob76e414164bede65d28622a83141e08977b739a5c
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/. */
7 /* thread-safe container of information for resolving url values */
9 #include "mozilla/URLExtraData.h"
11 #include "mozilla/NullPrincipalURI.h"
12 #include "nsProxyRelease.h"
13 #include "ReferrerInfo.h"
15 namespace mozilla {
17 StaticRefPtr<URLExtraData> URLExtraData::sDummy;
18 StaticRefPtr<URLExtraData> URLExtraData::sDummyChrome;
20 /* static */
21 void URLExtraData::Init() {
22 RefPtr<nsIURI> baseURI = new NullPrincipalURI();
23 nsCOMPtr<nsIReferrerInfo> referrerInfo = new dom::ReferrerInfo(nullptr);
24 sDummy = new URLExtraData(do_AddRef(baseURI), do_AddRef(referrerInfo),
25 NullPrincipal::CreateWithoutOriginAttributes());
27 sDummyChrome =
28 new URLExtraData(baseURI.forget(), referrerInfo.forget(),
29 NullPrincipal::CreateWithoutOriginAttributes());
30 sDummyChrome->mIsChrome = true;
33 /* static */
34 void URLExtraData::Shutdown() {
35 sDummy = nullptr;
36 sDummyChrome = nullptr;
39 URLExtraData::~URLExtraData() {
40 if (!NS_IsMainThread()) {
41 NS_ReleaseOnMainThread("URLExtraData::mPrincipal", mPrincipal.forget());
45 StaticRefPtr<URLExtraData>
46 URLExtraData::sShared[size_t(UserAgentStyleSheetID::Count)];
48 } // namespace mozilla