WindowsUtilsParent.h (1761B)
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 7 #ifndef mozilla_dom_WindowsUtilsParent_h__ 8 #define mozilla_dom_WindowsUtilsParent_h__ 9 10 #include "mozilla/ProcInfo.h" 11 #include "mozilla/dom/PWindowsUtilsParent.h" 12 #include "mozilla/ipc/Endpoint.h" 13 #include "mozilla/ipc/UtilityProcessParent.h" 14 15 namespace mozilla::dom { 16 17 // Main-process manager for utilities in the WindowsUtils utility process. 18 class WindowsUtilsParent final : public PWindowsUtilsParent { 19 NS_INLINE_DECL_THREADSAFE_REFCOUNTING(WindowsUtilsParent, override); 20 21 nsresult BindToUtilityProcess( 22 RefPtr<mozilla::ipc::UtilityProcessParent> aUtilityParent) { 23 Endpoint<PWindowsUtilsParent> parentEnd; 24 Endpoint<PWindowsUtilsChild> childEnd; 25 nsresult rv = PWindowsUtils::CreateEndpoints( 26 mozilla::ipc::EndpointProcInfo::Current(), 27 aUtilityParent->OtherEndpointProcInfo(), &parentEnd, &childEnd); 28 29 if (NS_FAILED(rv)) { 30 MOZ_ASSERT(false, "Protocol endpoints failure"); 31 return NS_ERROR_FAILURE; 32 } 33 34 if (!aUtilityParent->SendStartWindowsUtilsService(std::move(childEnd))) { 35 MOZ_ASSERT(false, "SendStartWindowsUtilsService failed"); 36 return NS_ERROR_FAILURE; 37 } 38 39 DebugOnly<bool> ok = parentEnd.Bind(this); 40 MOZ_ASSERT(ok); 41 return NS_OK; 42 } 43 44 UtilityActorName GetActorName() { return UtilityActorName::WindowsUtils; } 45 46 protected: 47 ~WindowsUtilsParent() = default; 48 }; 49 50 } // namespace mozilla::dom 51 52 #endif // mozilla_dom_WindowsUtilsParent_h__