| 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 30 matching lines...) Expand all Loading... |
| 41 | 41 |
| 42 namespace WebCore { | 42 namespace WebCore { |
| 43 | 43 |
| 44 class KURL; | 44 class KURL; |
| 45 class ResourceError; | 45 class ResourceError; |
| 46 class ResourceHandle; | 46 class ResourceHandle; |
| 47 class ResourceHandleClient; | 47 class ResourceHandleClient; |
| 48 class ResourceRequest; | 48 class ResourceRequest; |
| 49 class ResourceResponse; | 49 class ResourceResponse; |
| 50 | 50 |
| 51 // BlobRegistryImpl is not thread-safe. It should only be called from main threa
d. | 51 #if PLATFORM(CHROMIUM) |
| 52 error error error |
| 53 #endif |
| 54 |
| 52 class BlobRegistryImpl : public BlobRegistry { | 55 class BlobRegistryImpl : public BlobRegistry { |
| 53 WTF_MAKE_FAST_ALLOCATED; | 56 WTF_MAKE_FAST_ALLOCATED; |
| 54 public: | 57 public: |
| 55 virtual ~BlobRegistryImpl() { } | 58 virtual ~BlobRegistryImpl() { } |
| 56 | 59 |
| 57 virtual void registerBlobURL(const KURL&, PassOwnPtr<BlobData>); | 60 // BlobData registration: may be called on any thread. |
| 58 virtual void registerBlobURL(const KURL&, const KURL& srcURL); | 61 virtual void registerBlobData(const String& uuid, PassOwnPtr<BlobData>); |
| 59 virtual void unregisterBlobURL(const KURL&); | 62 virtual void addBlobDataRef(const String& uuid); |
| 60 virtual bool loadResourceSynchronously(const ResourceRequest&, ResourceError
&, ResourceResponse&, Vector<char>& data); | 63 virtual void removeBlobDataRef(const String& uuid); |
| 61 | 64 |
| 65 // Public Blob URL registration: may be called on any thread. |
| 66 virtual void registerPublicBlobURL(SecurityOrigin*, const KURL&, PassRefPtr<
BlobDataHandle>); |
| 67 virtual void revokePublicBlobURL(const KURL&); |
| 68 virtual PassRefPtr<SecurityOrigin> cachedUniqueOrigin(const KURL&); |
| 69 |
| 70 // Extra methods that are not defined in the base class to support BlobURL r
esource loading |
| 71 // and Form uploads that include blobs as file input elements. In-process im
plementations need |
| 72 // direct access to the underlying data for these functions, but not all por
ts need this. |
| 73 // Chromium ports perform these functions out-of-process). |
| 74 // TODO: fix up callsites that currently use FromURL that need to use FromUU
ID in other ports. |
| 75 PassRefPtr<BlobStorageData> getBlobDataFromUUID(const String&) const; |
| 62 PassRefPtr<BlobStorageData> getBlobDataFromURL(const KURL&) const; | 76 PassRefPtr<BlobStorageData> getBlobDataFromURL(const KURL&) const; |
| 63 | 77 bool loadResourceSynchronously(const ResourceRequest&, ResourceError&, Resou
rceResponse&, Vector<char>& data); |
| 64 PassRefPtr<ResourceHandle> createResourceHandle(const ResourceRequest&, Reso
urceHandleClient*); | 78 PassRefPtr<ResourceHandle> createResourceHandle(const ResourceRequest&, Reso
urceHandleClient*); |
| 65 | 79 |
| 66 private: | 80 private: |
| 81 class URLRegistrationHelper; |
| 82 typedef HashMap<String, RefPtr<BlobDataHandle> > BlobURLMap; |
| 83 typedef HashMap<String, std::pair<int, RefPtr<BlobStorageData> > > BlobMap; |
| 84 |
| 67 bool shouldLoadResource(const ResourceRequest& request) const; | 85 bool shouldLoadResource(const ResourceRequest& request) const; |
| 68 void appendStorageItems(BlobStorageData*, const BlobDataItemList&); | 86 void appendStorageItems(BlobStorageData*, const BlobDataItemList&); |
| 69 void appendStorageItems(BlobStorageData*, const BlobDataItemList&, long long
offset, long long length); | 87 void appendStorageItems(BlobStorageData*, const BlobDataItemList&, long long
offset, long long length); |
| 70 | 88 |
| 71 HashMap<String, RefPtr<BlobStorageData> > m_blobs; | 89 // The url map is only accessed on the main thread. |
| 90 BlobURLMap m_publicURLs; |
| 91 |
| 92 // The blob map is accessed on multiple threads, the mutex protects it from
concurrent access. |
| 93 mutable Mutex m_mutex; |
| 94 BlobMap m_blobs; |
| 72 }; | 95 }; |
| 73 | 96 |
| 74 } // namespace WebCore | 97 } // namespace WebCore |
| 75 | 98 |
| 76 #endif // BlobRegistryImpl_h | 99 #endif // BlobRegistryImpl_h |
| OLD | NEW |