tor-browser

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

InputChannelThrottleQueueChild.cpp (976B)


      1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
      2 /* vim:set ts=4 sw=4 sts=4 et cin: */
      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 "InputChannelThrottleQueueChild.h"
      8 #include "nsThreadUtils.h"
      9 
     10 namespace mozilla {
     11 namespace net {
     12 
     13 NS_IMPL_ISUPPORTS_INHERITED0(InputChannelThrottleQueueChild, ThrottleQueue)
     14 
     15 NS_IMETHODIMP
     16 InputChannelThrottleQueueChild::RecordRead(uint32_t aBytesRead) {
     17  ThrottleQueue::RecordRead(aBytesRead);
     18 
     19  RefPtr<InputChannelThrottleQueueChild> self = this;
     20  NS_DispatchToMainThread(NS_NewRunnableFunction(
     21      "InputChannelThrottleQueueChild::RecordRead", [self, aBytesRead]() {
     22        if (self->CanSend()) {
     23          (void)self->SendRecordRead(aBytesRead);
     24        }
     25      }));
     26  return NS_OK;
     27 }
     28 
     29 }  // namespace net
     30 }  // namespace mozilla