tor-browser

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

nsIRaceCacheWithNetwork.idl (2589B)


      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 "nsISupports.idl"
      8 
      9 /**
     10 * This holds methods used to race the cache with the network for a specific
     11 * channel. This interface is was designed with nsHttpChannel in mind, and it's
     12 * expected this will be the only class implementing it.
     13 */
     14 [scriptable, builtinclass, uuid(4d963475-8b16-4c58-b804-8a23d49436c5)]
     15 interface nsIRaceCacheWithNetwork : nsISupports
     16 {
     17  /**
     18   * When set to false the channel will not attempt to race cache with network.
     19   */
     20  attribute boolean allowRacing;
     21 
     22  /****************************************************************************
     23   * TEST ONLY: The following methods are for testing purposes only. Do not use
     24   * them to do anything important in your code.
     25   ****************************************************************************
     26 
     27  /**
     28   * Triggers network activity after given timeout. If timeout is 0, network
     29   * activity is triggered immediately if asyncOpen has already been called.
     30   * Otherwise the delayed timer will be set when the normal call to
     31   * TriggerNetwork is made. If the cache.asyncOpenURI callbacks have already
     32   * been called, the network activity may have already been triggered
     33   * or the content may have already been delivered from the cache, so this
     34   * operation will have no effect.
     35   *
     36   * @param timeout
     37   *        - the delay in milliseconds until the network will be triggered.
     38   */
     39  void test_triggerNetwork(in long timeout);
     40 
     41  /**
     42   * Normally a HTTP channel would immediately call AsyncOpenURI leading to the
     43   * cache storage to lookup the cache entry and return it. In order to
     44   * simmulate real life conditions where fetching a cache entry takes a long
     45   * time, we set a timer to delay the operation.
     46   * Can only be called on the main thread.
     47   *
     48   * @param timeout
     49   *        - the delay in milliseconds until the cache open will be triggered.
     50   */
     51  void test_delayCacheEntryOpeningBy(in long timeout);
     52 
     53  /**
     54   * Immediatelly triggers AsyncOpenURI if the timer hasn't fired.
     55   * Can only be called on the main thread.
     56   * This is only called in tests to reliably trigger the opening of the cache
     57   * entry.
     58   * @throws NS_ERROR_NOT_AVAILABLE if opening the cache wasn't delayed.
     59   */
     60  void test_triggerDelayedOpenCacheEntry();
     61 };