Bug 1829125 - Align the PHC area to the jemalloc chunk size r=glandium
[gecko.git] / services / common / app_services_logger / AppServicesLoggerComponents.h
blob015eae230b6a7b2c6b45cec80a5abf8af22a49d9
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"
9 #include "nsCOMPtr.h"
11 extern "C" {
13 // Implemented in Rust, in the `app_services_logger` crate.
14 nsresult NS_NewAppServicesLogger(mozIAppServicesLogger** aResult);
16 } // extern "C"
18 namespace mozilla {
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))) {
30 return nullptr;
32 return logger.forget();
35 } // namespace appservices
36 } // namespace mozilla
38 #endif // mozilla_services_AppServicesLoggerComponents_h_