tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

ProcessActor.cpp (1297B)


      1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
      2 /* vim:set ts=2 sw=2 sts=2 et cindent: */
      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/ProcessActor.h"
      8 
      9 #include "mozilla/ContentBlockingAllowList.h"
     10 #include "mozilla/Logging.h"
     11 #include "mozilla/dom/JSActorService.h"
     12 #include "mozilla/dom/JSProcessActorChild.h"
     13 #include "mozilla/dom/JSProcessActorParent.h"
     14 #include "mozilla/dom/JSProcessActorProtocol.h"
     15 #include "nsContentUtils.h"
     16 
     17 namespace mozilla::dom {
     18 
     19 already_AddRefed<JSActorProtocol> ProcessActor::MatchingJSActorProtocol(
     20    JSActorService* aActorSvc, const nsACString& aName, ErrorResult& aRv) {
     21  RefPtr<JSProcessActorProtocol> proto =
     22      aActorSvc->GetJSProcessActorProtocol(aName);
     23  if (!proto) {
     24    aRv.ThrowNotFoundError(nsPrintfCString("No such JSProcessActor '%s'",
     25                                           PromiseFlatCString(aName).get()));
     26    return nullptr;
     27  }
     28 
     29  if (!proto->Matches(GetRemoteType(), aRv)) {
     30    MOZ_ASSERT(aRv.Failed());
     31    return nullptr;
     32  }
     33  MOZ_ASSERT(!aRv.Failed());
     34  return proto.forget();
     35 }
     36 
     37 }  // namespace mozilla::dom