| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2010 Google Inc. All rights reserved. | 2 * Copyright (C) 2010 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 */ | 29 */ |
| 30 | 30 |
| 31 #ifndef BlobRegistry_h | 31 #ifndef BlobRegistry_h |
| 32 #define BlobRegistry_h | 32 #define BlobRegistry_h |
| 33 | 33 |
| 34 #include <wtf/PassOwnPtr.h> | 34 #include <wtf/PassOwnPtr.h> |
| 35 #include <wtf/PassRefPtr.h> | 35 #include <wtf/PassRefPtr.h> |
| 36 #include <wtf/text/WTFString.h> |
| 36 #include <wtf/Vector.h> | 37 #include <wtf/Vector.h> |
| 37 | 38 |
| 38 namespace WebCore { | 39 namespace WebCore { |
| 39 | 40 |
| 40 class BlobData; | 41 class BlobData; |
| 41 class BlobRegistry; | 42 class BlobDataHandle; |
| 42 class KURL; | 43 class KURL; |
| 43 class ResourceError; | 44 class ResourceError; |
| 44 class ResourceHandle; | 45 class ResourceHandle; |
| 45 class ResourceHandleClient; | 46 class ResourceHandleClient; |
| 46 class ResourceRequest; | 47 class ResourceRequest; |
| 47 class ResourceResponse; | 48 class ResourceResponse; |
| 49 class SecurityOrigin; |
| 48 | 50 |
| 49 // Returns a single instance of BlobRegistry. | |
| 50 BlobRegistry& blobRegistry(); | |
| 51 | |
| 52 // BlobRegistry is not thread-safe. It should only be called from main thread. | |
| 53 class BlobRegistry { | 51 class BlobRegistry { |
| 54 public: | 52 public: |
| 55 // Registers a blob URL referring to the specified blob data. | 53 // BlobData registration: may be called on any thread. |
| 56 virtual void registerBlobURL(const KURL&, PassOwnPtr<BlobData>) = 0; | 54 virtual void registerBlobData(const String& uuid, PassOwnPtr<BlobData>) = 0; |
| 57 | 55 virtual void addBlobDataRef(const String& uuid) = 0; |
| 58 // Registers a blob URL referring to the blob data identified by the specifi
ed srcURL. | 56 virtual void removeBlobDataRef(const String& uuid) = 0; |
| 59 virtual void registerBlobURL(const KURL&, const KURL& srcURL) = 0; | |
| 60 | 57 |
| 61 virtual void unregisterBlobURL(const KURL&) = 0; | 58 // Public Blob URL registration: may be called on any thread. |
| 62 virtual bool loadResourceSynchronously(const ResourceRequest&, ResourceError
&, ResourceResponse&, Vector<char>& data) = 0; | 59 virtual void registerPublicBlobURL(SecurityOrigin*, const KURL&, PassRefPtr<
BlobDataHandle>) = 0; |
| 60 virtual void revokePublicBlobURL(const KURL&) = 0; |
| 61 virtual PassRefPtr<SecurityOrigin> cachedUniqueOrigin(const KURL&) = 0; |
| 63 | 62 |
| 64 protected: | 63 protected: |
| 65 virtual ~BlobRegistry() { } | 64 // Helpers for derivatives to maintain a mapping from Blob URL to unique sec
urity origins. This mapping is thead-specific. |
| 65 static void setCachedUniqueOrigin(const KURL&, SecurityOrigin*); |
| 66 static void clearCachedUniqueOrigin(const KURL&); |
| 67 static PassRefPtr<SecurityOrigin> getCachedUniqueOrigin(const KURL&); |
| 66 }; | 68 }; |
| 67 | 69 |
| 70 BlobRegistry& blobRegistry(); |
| 71 |
| 68 } // namespace WebCore | 72 } // namespace WebCore |
| 69 | 73 |
| 70 #endif // BlobRegistry_h | 74 #endif // BlobRegistry_h |
| OLD | NEW |