/src/mozilla-central/netwerk/protocol/data/nsDataHandler.h
Line | Count | Source (jump to first uncovered line) |
1 | | /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
2 | | /* This Source Code Form is subject to the terms of the Mozilla Public |
3 | | * License, v. 2.0. If a copy of the MPL was not distributed with this |
4 | | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
5 | | |
6 | | #ifndef nsDataHandler_h___ |
7 | | #define nsDataHandler_h___ |
8 | | |
9 | | #include "nsIProtocolHandler.h" |
10 | | #include "nsWeakReference.h" |
11 | | |
12 | | class nsDataHandler : public nsIProtocolHandler |
13 | | , public nsSupportsWeakReference |
14 | | { |
15 | 0 | virtual ~nsDataHandler() = default; |
16 | | |
17 | | public: |
18 | | NS_DECL_ISUPPORTS |
19 | | |
20 | | // nsIProtocolHandler methods: |
21 | | NS_DECL_NSIPROTOCOLHANDLER |
22 | | |
23 | | // nsDataHandler methods: |
24 | 1 | nsDataHandler() = default; |
25 | | |
26 | | // Define a Create method to be used with a factory: |
27 | | static MOZ_MUST_USE nsresult |
28 | | Create(nsISupports* aOuter, const nsIID& aIID, void* *aResult); |
29 | | |
30 | | // Parse a data: URI and return the individual parts |
31 | | // (the given spec will temporarily be modified but will be returned |
32 | | // to the original before returning) |
33 | | // contentCharset and dataBuffer can be nullptr if they are not needed. |
34 | | static MOZ_MUST_USE nsresult ParseURI(nsCString& spec, |
35 | | nsCString& contentType, |
36 | | nsCString* contentCharset, |
37 | | bool& isBase64, |
38 | | nsCString* dataBuffer); |
39 | | |
40 | | // Parse the path portion of a data: URI and return the individual parts. |
41 | | // |
42 | | // Note: The path is assumed *not* to have a ref portion. |
43 | | // |
44 | | // @arg aPath The path portion of the spec. Must not have ref portion. |
45 | | // @arg aContentType Out param, will hold the parsed content type. |
46 | | // @arg aContentCharset Optional, will hold the charset if specified. |
47 | | // @arg aIsBase64 Out param, indicates if the data is base64 encoded. |
48 | | // @arg aDataBuffer Optional, will reference the substring in |aPath| that |
49 | | // contains the data portion of the path. No copy is made. |
50 | | static MOZ_MUST_USE nsresult ParsePathWithoutRef( |
51 | | const nsACString& aPath, |
52 | | nsCString& aContentType, |
53 | | nsCString* aContentCharset, |
54 | | bool& aIsBase64, |
55 | | nsDependentCSubstring* aDataBuffer); |
56 | | }; |
57 | | |
58 | | #endif /* nsDataHandler_h___ */ |