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/. */
5 #ifndef mozilla_services_AppServicesLoggerComponents_h_
6 #define mozilla_services_AppServicesLoggerComponents_h_
8 #include "mozIAppServicesLogger.h"
13 // Implemented in Rust, in the `app_services_logger` crate.
14 nsresult
NS_NewAppServicesLogger(mozIAppServicesLogger
** aResult
);
19 namespace appservices
{
21 // The C++ constructor for a `services.appServicesLogger` service. This wrapper
22 // exists because `components.conf` requires a component class constructor to
23 // return an `already_AddRefed<T>`, but Rust doesn't have such a type. So we
24 // call the Rust constructor using a `nsCOMPtr` (which is compatible with Rust's
25 // `xpcom::RefPtr`) out param, and return that.
26 already_AddRefed
<mozIAppServicesLogger
> NewLogService() {
27 nsCOMPtr
<mozIAppServicesLogger
> logger
;
28 nsresult rv
= NS_NewAppServicesLogger(getter_AddRefs(logger
));
29 if (NS_WARN_IF(NS_FAILED(rv
))) {
32 return logger
.forget();
35 } // namespace appservices
36 } // namespace mozilla
38 #endif // mozilla_services_AppServicesLoggerComponents_h_