ProcessMessageManager.cpp (1757B)
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 #include "mozilla/dom/ProcessMessageManager.h" 8 9 #include "mozilla/dom/MessageManagerBinding.h" 10 #include "mozilla/dom/ParentProcessMessageManager.h" 11 #include "nsContentUtils.h" 12 13 namespace mozilla::dom { 14 15 ProcessMessageManager::ProcessMessageManager( 16 ipc::MessageManagerCallback* aCallback, 17 ParentProcessMessageManager* aParentManager, MessageManagerFlags aFlags) 18 : MessageSender(aCallback, aParentManager, 19 aFlags | MessageManagerFlags::MM_CHROME | 20 MessageManagerFlags::MM_PROCESSMANAGER), 21 mPid(-1), 22 // aCallback is only specified if this is the in-process manager. 23 mInProcess(!!aCallback) { 24 MOZ_ASSERT(!(aFlags & ~(MessageManagerFlags::MM_GLOBAL | 25 MessageManagerFlags::MM_OWNSCALLBACK))); 26 27 // This is a bit hackish. We attach to the parent manager, but only if we have 28 // a callback (which is only for the in-process message manager). For other 29 // cases we wait until the child process is running (see 30 // MessageSender::InitWithCallback). 31 if (aParentManager && mCallback) { 32 aParentManager->AddChildManager(this); 33 } 34 } 35 36 JSObject* ProcessMessageManager::WrapObject(JSContext* aCx, 37 JS::Handle<JSObject*> aGivenProto) { 38 MOZ_ASSERT(nsContentUtils::IsSystemCaller(aCx)); 39 40 return ProcessMessageManager_Binding::Wrap(aCx, this, aGivenProto); 41 } 42 43 } // namespace mozilla::dom