FetchDecodedImage.h (1661B)
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_FetchDecodedImage_h 8 #define mozilla_image_FetchDecodedImage_h 9 10 #include "mozilla/MozPromise.h" 11 #include "mozilla/gfx/Point.h" 12 #include "nsILoadInfo.h" 13 #include "nsIContentPolicy.h" 14 15 class imgIContainer; 16 class nsIChannel; 17 18 namespace mozilla::image { 19 20 using FetchDecodedImagePromise = 21 mozilla::MozPromise<already_AddRefed<imgIContainer>, nsresult, true>; 22 23 /* 24 * This method fetches and image URI and starts decoding the image soon as 25 * possible. Either resolves the promise with the decoded imgIContainer or 26 * rejects with an nsresult, for e.g. network failures or decoding errors. 27 * 28 * @param aURI URI of the image to download. 29 * @param aSize Size to decode the image at (if possible). Use zero width or 30 * height to prevent resizing. 31 */ 32 RefPtr<FetchDecodedImagePromise> FetchDecodedImage( 33 nsIURI* aURI, gfx::IntSize aSize, nsIPrincipal* aLoadingPrincipal, 34 nsSecurityFlags aSecurityFlags = 35 nsILoadInfo::SEC_ALLOW_CROSS_ORIGIN_SEC_CONTEXT_IS_NULL, 36 nsContentPolicyType aContentPolicyType = 37 nsIContentPolicy::TYPE_INTERNAL_IMAGE); 38 39 RefPtr<FetchDecodedImagePromise> FetchDecodedImage(nsIURI* aURI, 40 nsIChannel* aChannel, 41 gfx::IntSize aSize); 42 43 } // namespace mozilla::image 44 45 #endif // mozilla_image_FetchDecodedImage_h