tor-browser

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

nsIBaseChannel.idl (1942B)


      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 "nsISupports.idl"
      6 
      7 %{C++
      8 #include "mozilla/dom/MimeType.h"
      9 #include "mozilla/net/ContentRange.h"
     10 %}
     11 
     12 /**
     13 * The nsIBaseChannel interface allows C++ code to query the interface
     14 * of channels safely to gain access to content range functionality.
     15 * This allows subclasses to optionally handle range-requests on their
     16 * types using fetch/XMLHttpRequest even if they are not accessed via
     17 * HTTP and therefore normally do not have support for headers.
     18 */
     19 
     20 native ContentRangeRef(RefPtr<mozilla::net::ContentRange>);
     21 native MimeTypeRef(RefPtr<TMimeType<char>>);
     22 
     23 [uuid(036d5cd7-9a53-40e3-9c72-c2ffaa15aa2b)]
     24 interface nsIBaseChannel : nsISupports {
     25 
     26  /**
     27   * Used by fetch and XMLHttpRequest to get only the range specified in the
     28   * Range request header (if given) for the response body (e.g, for blob URLs)
     29   */
     30  attribute ContentRangeRef contentRange;
     31 
     32  /**
     33   * Used by fetch and XMLHttpRequest to get the standards-compliant value they
     34   * should set for the Content-Type header on response (if nullptr, they will
     35   * use Firefox-specific values from nsIChannel::GetContentType and GetCharset).
     36   */
     37  attribute MimeTypeRef fullMimeType;
     38 
     39 %{C++
     40  RefPtr<mozilla::net::ContentRange> ContentRange() {
     41    RefPtr<mozilla::net::ContentRange> range;
     42    (void)GetContentRange(&range);
     43    return range;
     44  }
     45 
     46  bool SetContentRangeFromHeader(const nsACString& aHeader, uint64_t aSize) {
     47    RefPtr<mozilla::net::ContentRange> range =
     48      new mozilla::net::ContentRange(aHeader, aSize);
     49    if (!range->IsValid()) {
     50      return false;
     51    }
     52    SetContentRange(range);
     53    return true;
     54  }
     55 
     56  RefPtr<CMimeType> FullMimeType() {
     57    RefPtr<CMimeType> type;
     58    (void)GetFullMimeType(&type);
     59    return type;
     60  }
     61 %}
     62 
     63 };