Backed out changeset 4191b252db9b (bug 1886734) for causing build bustages @netwerk...
[gecko.git] / image / ImageFactory.h
blob1f9b6777398354fc3b557f37856d9032ba9821b2
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 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/. */
7 #ifndef mozilla_image_ImageFactory_h
8 #define mozilla_image_ImageFactory_h
10 #include "nsCOMPtr.h"
11 #include "nsProxyRelease.h"
12 #include "nsStringFwd.h"
14 class nsIRequest;
15 class nsIURI;
17 namespace mozilla {
18 namespace image {
20 class Image;
21 class MultipartImage;
22 class ProgressTracker;
24 class ImageFactory {
25 public:
26 /**
27 * Registers vars with Preferences. Should only be called on the main thread.
29 static void Initialize();
31 /**
32 * Creates a new image with the given properties.
33 * Can be called on or off the main thread.
35 * @param aRequest The associated request.
36 * @param aProgressTracker A status tracker for the image to use.
37 * @param aMimeType The mimetype of the image.
38 * @param aURI The URI of the image.
39 * @param aIsMultiPart Whether the image is part of a multipart request.
40 * @param aInnerWindowId The window this image belongs to.
42 static already_AddRefed<Image> CreateImage(nsIRequest* aRequest,
43 ProgressTracker* aProgressTracker,
44 const nsCString& aMimeType,
45 nsIURI* aURI, bool aIsMultiPart,
46 uint64_t aInnerWindowId);
47 /**
48 * Creates a new image which isn't associated with a URI or loaded through
49 * the usual image loading mechanism.
51 * @param aMimeType The mimetype of the image.
52 * @param aSizeHint The length of the source data for the image.
54 static already_AddRefed<Image> CreateAnonymousImage(
55 const nsCString& aMimeType, uint32_t aSizeHint = 0);
57 /**
58 * Creates a new multipart/x-mixed-replace image wrapper, and initializes it
59 * with the first part. Subsequent parts should be passed to the existing
60 * MultipartImage via MultipartImage::BeginTransitionToPart().
62 * @param aFirstPart An image containing the first part of the multipart
63 * stream.
64 * @param aProgressTracker A progress tracker for the multipart image.
66 static already_AddRefed<MultipartImage> CreateMultipartImage(
67 Image* aFirstPart, ProgressTracker* aProgressTracker);
69 private:
70 // Factory functions that create specific types of image containers.
71 static already_AddRefed<Image> CreateRasterImage(
72 nsIRequest* aRequest, ProgressTracker* aProgressTracker,
73 const nsCString& aMimeType, nsIURI* aURI, uint32_t aImageFlags,
74 uint64_t aInnerWindowId);
76 static already_AddRefed<Image> CreateVectorImage(
77 nsIRequest* aRequest, ProgressTracker* aProgressTracker,
78 const nsCString& aMimeType, nsIURI* aURI, uint32_t aImageFlags,
79 uint64_t aInnerWindowId);
81 // This is a static factory class, so disallow instantiation.
82 virtual ~ImageFactory() = 0;
85 } // namespace image
86 } // namespace mozilla
88 #endif // mozilla_image_ImageFactory_h