tor-browser

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

nsIconChannel.h (1737B)


      1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
      2 *
      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 #ifndef mozilla_image_encoders_icon_win_nsIconChannel_h
      8 #define mozilla_image_encoders_icon_win_nsIconChannel_h
      9 
     10 #include "mozilla/MozPromise.h"
     11 
     12 #include "nsCOMPtr.h"
     13 #include "nsString.h"
     14 #include "nsIChannel.h"
     15 #include "nsILoadGroup.h"
     16 #include "nsILoadInfo.h"
     17 #include "nsIInterfaceRequestor.h"
     18 #include "nsIInterfaceRequestorUtils.h"
     19 #include "nsIURI.h"
     20 #include "nsIInputStreamPump.h"
     21 #include "nsIStreamListener.h"
     22 
     23 namespace mozilla::ipc {
     24 class ByteBuf;
     25 }
     26 
     27 class nsIconChannel final : public nsIChannel, public nsIStreamListener {
     28 public:
     29  using ByteBufPromise =
     30      mozilla::MozPromise<mozilla::ipc::ByteBuf, nsresult, true>;
     31 
     32  NS_DECL_THREADSAFE_ISUPPORTS
     33  NS_DECL_NSIREQUEST
     34  NS_DECL_NSICHANNEL
     35  NS_DECL_NSIREQUESTOBSERVER
     36  NS_DECL_NSISTREAMLISTENER
     37 
     38  nsIconChannel();
     39 
     40  nsresult Init(nsIURI* uri, nsILoadInfo* aLoadInfo);
     41 
     42  /// Obtains an icon in Windows ICO format as a ByteBuf instead
     43  /// of a channel. For use with IPC.
     44  static RefPtr<ByteBufPromise> GetIconAsync(nsIURI* aURI);
     45 
     46 private:
     47  ~nsIconChannel();
     48 
     49  nsresult StartAsyncOpen();
     50 
     51  nsCOMPtr<nsIURI> mUrl;
     52  nsCOMPtr<nsIURI> mOriginalURI;
     53  nsCOMPtr<nsILoadGroup> mLoadGroup;
     54  nsCOMPtr<nsIInterfaceRequestor> mCallbacks;
     55  nsCOMPtr<nsISupports> mOwner;
     56  nsCOMPtr<nsILoadInfo> mLoadInfo;
     57 
     58  nsCOMPtr<nsIInputStreamPump> mPump;
     59  nsCOMPtr<nsIStreamListener> mListener;
     60 
     61  bool mCanceled = false;
     62 };
     63 
     64 #endif  // mozilla_image_encoders_icon_win_nsIconChannel_h