tor-browser

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

BackgroundDataBridgeChild.cpp (1817B)


      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/. */
      4 
      5 #include "mozilla/net/BackgroundDataBridgeChild.h"
      6 #include "mozilla/net/HttpBackgroundChannelChild.h"
      7 
      8 namespace mozilla {
      9 namespace net {
     10 
     11 BackgroundDataBridgeChild::BackgroundDataBridgeChild(
     12    HttpBackgroundChannelChild* aBgChild)
     13    : mBgChild(aBgChild) {
     14  MOZ_ASSERT(aBgChild);
     15 }
     16 
     17 BackgroundDataBridgeChild::~BackgroundDataBridgeChild() = default;
     18 
     19 void BackgroundDataBridgeChild::ActorDestroy(ActorDestroyReason aWhy) {
     20  mBgChild = nullptr;
     21 }
     22 
     23 mozilla::ipc::IPCResult BackgroundDataBridgeChild::RecvOnTransportAndData(
     24    const uint64_t& offset, const uint32_t& count, const nsACString& data,
     25    const TimeStamp& aOnDataAvailableStartTime) {
     26  if (!mBgChild) {
     27    return IPC_OK();
     28  }
     29 
     30  if (mBgChild->ChannelClosed()) {
     31    Close();
     32    return IPC_OK();
     33  }
     34 
     35  return mBgChild->RecvOnTransportAndData(NS_OK, NS_NET_STATUS_RECEIVING_FROM,
     36                                          offset, count, data, true,
     37                                          aOnDataAvailableStartTime);
     38 }
     39 
     40 mozilla::ipc::IPCResult BackgroundDataBridgeChild::RecvOnStopRequest(
     41    nsresult aStatus, const ResourceTimingStructArgs& aTiming,
     42    const TimeStamp& aLastActiveTabOptHit,
     43    const nsHttpHeaderArray& aResponseTrailers,
     44    const TimeStamp& aOnStopRequestStartTime) {
     45  if (!mBgChild) {
     46    return IPC_OK();
     47  }
     48 
     49  if (mBgChild->ChannelClosed()) {
     50    Close();
     51    return IPC_OK();
     52  }
     53 
     54  return mBgChild->RecvOnStopRequest(
     55      aStatus, aTiming, aLastActiveTabOptHit, aResponseTrailers,
     56      nsTArray<ConsoleReportCollected>(), true, aOnStopRequestStartTime);
     57 }
     58 
     59 }  // namespace net
     60 }  // namespace mozilla