tor-browser

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

WorkerChannelInfo.cpp (1890B)


      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 "WorkerChannelInfo.h"
      8 
      9 #include "mozilla/dom/BrowsingContext.h"
     10 
     11 namespace mozilla::dom {
     12 
     13 // WorkerChannelLoadInfo
     14 
     15 NS_IMPL_ISUPPORTS(WorkerChannelLoadInfo, nsIWorkerChannelLoadInfo)
     16 
     17 NS_IMETHODIMP
     18 WorkerChannelLoadInfo::GetWorkerAssociatedBrowsingContextID(uint64_t* aResult) {
     19  *aResult = mWorkerAssociatedBrowsingContextID;
     20  return NS_OK;
     21 }
     22 
     23 NS_IMETHODIMP
     24 WorkerChannelLoadInfo::SetWorkerAssociatedBrowsingContextID(uint64_t aID) {
     25  mWorkerAssociatedBrowsingContextID = aID;
     26  return NS_OK;
     27 }
     28 
     29 NS_IMETHODIMP
     30 WorkerChannelLoadInfo::GetWorkerAssociatedBrowsingContext(
     31    dom::BrowsingContext** aResult) {
     32  *aResult = BrowsingContext::Get(mWorkerAssociatedBrowsingContextID).take();
     33  return NS_OK;
     34 }
     35 
     36 // WorkerChannelInfo
     37 
     38 NS_IMPL_ISUPPORTS(WorkerChannelInfo, nsIWorkerChannelInfo)
     39 
     40 WorkerChannelInfo::WorkerChannelInfo(uint64_t aChannelID,
     41                                     uint64_t aBrowsingContextID)
     42    : mChannelID(aChannelID) {
     43  mLoadInfo = new WorkerChannelLoadInfo();
     44  mLoadInfo->SetWorkerAssociatedBrowsingContextID(aBrowsingContextID);
     45 }
     46 
     47 NS_IMETHODIMP
     48 WorkerChannelInfo::SetLoadInfo(nsIWorkerChannelLoadInfo* aLoadInfo) {
     49  MOZ_ASSERT(aLoadInfo);
     50  mLoadInfo = aLoadInfo;
     51  return NS_OK;
     52 }
     53 
     54 NS_IMETHODIMP
     55 WorkerChannelInfo::GetLoadInfo(nsIWorkerChannelLoadInfo** aLoadInfo) {
     56  *aLoadInfo = do_AddRef(mLoadInfo).take();
     57  return NS_OK;
     58 }
     59 
     60 NS_IMETHODIMP
     61 WorkerChannelInfo::GetChannelId(uint64_t* aChannelID) {
     62  NS_ENSURE_ARG_POINTER(aChannelID);
     63  *aChannelID = mChannelID;
     64  return NS_OK;
     65 }
     66 
     67 }  // end of namespace mozilla::dom