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/. */
6 #include "mozilla/ClearOnShutdown.h"
7 #include "mozilla/StaticPtr.h"
11 // This anonymous namespace prevents outside C++ code from improperly accessing
12 // these implementation details.
15 // Implemented in Rust.
16 void new_bits_service(nsIBits
** result
);
19 static mozilla::StaticRefPtr
<nsIBits
> sBitsService
;
22 already_AddRefed
<nsIBits
> GetBitsService() {
23 nsCOMPtr
<nsIBits
> bitsService
;
26 bitsService
= sBitsService
;
28 new_bits_service(getter_AddRefs(bitsService
));
29 sBitsService
= bitsService
;
30 mozilla::ClearOnShutdown(&sBitsService
);
33 return bitsService
.forget();