| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2012 Motorola Mobility Inc. | 2 * Copyright (C) 2012 Motorola Mobility Inc. |
| 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 | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * | 7 * |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. 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 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
| 23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 24 */ | 24 */ |
| 25 | 25 |
| 26 #ifndef PublicURLManager_h | 26 #ifndef PublicURLManager_h |
| 27 #define PublicURLManager_h | 27 #define PublicURLManager_h |
| 28 | 28 |
| 29 #include "core/dom/ActiveDOMObject.h" | 29 #include "core/dom/ActiveDOMObject.h" |
| 30 #include "platform/heap/Handle.h" | 30 #include "platform/heap/Handle.h" |
| 31 #include "wtf/HashMap.h" | 31 #include "wtf/HashMap.h" |
| 32 #include "wtf/HashSet.h" | |
| 33 #include "wtf/text/WTFString.h" | 32 #include "wtf/text/WTFString.h" |
| 34 | 33 |
| 35 namespace blink { | 34 namespace blink { |
| 36 | 35 |
| 37 class KURL; | 36 class KURL; |
| 38 class ExecutionContext; | 37 class ExecutionContext; |
| 39 class SecurityOrigin; | |
| 40 class URLRegistry; | 38 class URLRegistry; |
| 41 class URLRegistrable; | 39 class URLRegistrable; |
| 42 | 40 |
| 43 class PublicURLManager final : public GarbageCollectedFinalized<PublicURLManager
>, public ActiveDOMObject { | 41 class PublicURLManager final : public GarbageCollectedFinalized<PublicURLManager
>, public ActiveDOMObject { |
| 44 USING_GARBAGE_COLLECTED_MIXIN(PublicURLManager); | 42 USING_GARBAGE_COLLECTED_MIXIN(PublicURLManager); |
| 45 public: | 43 public: |
| 46 static PublicURLManager* create(ExecutionContext*); | 44 static PublicURLManager* create(ExecutionContext*); |
| 47 | 45 |
| 48 void registerURL(SecurityOrigin*, const KURL&, URLRegistrable*, const String
& uuid = String()); | 46 // Generates a new Blob URL and registers the URLRegistrable to the |
| 47 // corresponding URLRegistry with the Blob URL. Returns the serialization |
| 48 // of the Blob URL. |
| 49 // |
| 50 // |uuid| can be used for revoke() to revoke all URLs associated with the |
| 51 // |uuid|. It's not the UUID generated and appended to the BlobURL, but an |
| 52 // identifier for the object to which URL(s) are generated e.g. ones |
| 53 // returned by blink::Blob::uuid(). |
| 54 String registerURL(ExecutionContext*, URLRegistrable*, const String& uuid); |
| 55 // Revokes the given URL. |
| 49 void revoke(const KURL&); | 56 void revoke(const KURL&); |
| 57 // Revokes all URLs associated with |uuid|. |
| 50 void revoke(const String& uuid); | 58 void revoke(const String& uuid); |
| 51 | 59 |
| 52 // ActiveDOMObject interface. | 60 // ActiveDOMObject interface. |
| 53 void stop() override; | 61 void stop() override; |
| 54 | 62 |
| 55 DECLARE_VIRTUAL_TRACE(); | 63 DECLARE_VIRTUAL_TRACE(); |
| 56 | 64 |
| 57 private: | 65 private: |
| 58 explicit PublicURLManager(ExecutionContext*); | 66 explicit PublicURLManager(ExecutionContext*); |
| 59 | 67 |
| 60 // One or more URLs can be associated with the same unique ID. | 68 // One or more URLs can be associated with the same unique ID. |
| 61 // Objects need be revoked by unique ID in some cases. | 69 // Objects need be revoked by unique ID in some cases. |
| 62 typedef String URLString; | 70 typedef String URLString; |
| 63 typedef HashMap<URLString, String> URLMap; | 71 typedef HashMap<URLString, String> URLMap; |
| 72 // Map from URLRegistry instances to the maps which store association |
| 73 // between URLs registered with the URLRegistry and UUIDs assigned for |
| 74 // each of the URLs. |
| 64 typedef HashMap<URLRegistry*, URLMap> RegistryURLMap; | 75 typedef HashMap<URLRegistry*, URLMap> RegistryURLMap; |
| 65 | 76 |
| 66 RegistryURLMap m_registryToURL; | 77 RegistryURLMap m_registryToURL; |
| 67 bool m_isStopped; | 78 bool m_isStopped; |
| 68 }; | 79 }; |
| 69 | 80 |
| 70 } // namespace blink | 81 } // namespace blink |
| 71 | 82 |
| 72 #endif // PublicURLManager_h | 83 #endif // PublicURLManager_h |
| OLD | NEW |