| 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 19 matching lines...) Expand all Loading... |
| 30 | 30 |
| 31 #include "config.h" | 31 #include "config.h" |
| 32 | 32 |
| 33 #if ENABLE(BLOB) | 33 #if ENABLE(BLOB) |
| 34 | 34 |
| 35 #include "BlobRegistryProxy.h" | 35 #include "BlobRegistryProxy.h" |
| 36 | 36 |
| 37 #include "BlobData.h" | 37 #include "BlobData.h" |
| 38 #include "KURL.h" | 38 #include "KURL.h" |
| 39 #include "ResourceHandle.h" | 39 #include "ResourceHandle.h" |
| 40 #include "SecurityOrigin.h" |
| 40 #include <public/Platform.h> | 41 #include <public/Platform.h> |
| 41 #include <public/WebBlobData.h> | 42 #include <public/WebBlobData.h> |
| 42 #include <public/WebBlobRegistry.h> | 43 #include <public/WebBlobRegistry.h> |
| 43 #include <public/WebURL.h> | 44 #include <public/WebURL.h> |
| 44 #include <wtf/MainThread.h> | 45 #include <wtf/MainThread.h> |
| 45 #include <wtf/StdLibExtras.h> | 46 #include <wtf/StdLibExtras.h> |
| 46 | 47 |
| 47 // We are part of the WebKit implementation. | 48 // We are part of the WebKit implementation. |
| 48 using namespace WebKit; | 49 using namespace WebKit; |
| 49 | 50 |
| 50 namespace WebCore { | 51 namespace WebCore { |
| 51 | 52 |
| 53 // FIXME: ensure webkit::init causes this to be initalized. |
| 54 // Alternatively, remove the blobRegistry() accessor from WebKit::Platform and i
nstead |
| 55 // define a WebBlobRegistry::setBlobRegistry(WebBlobRegistry*) for embedders to
inject |
| 56 // and instance pointer into. Injecting these things is frustratingly messy? |
| 52 BlobRegistry& blobRegistry() | 57 BlobRegistry& blobRegistry() |
| 53 { | 58 { |
| 54 ASSERT(isMainThread()); | 59 // AtomicallyInitializedStatic(BlobRegistryProxy&, intance = *new BlobRegist
ryProxy); ?? |
| 55 DEFINE_STATIC_LOCAL(BlobRegistryProxy, instance, ()); | 60 DEFINE_STATIC_LOCAL(BlobRegistryProxy, instance, ()); |
| 56 return instance; | 61 return instance; |
| 57 } | 62 } |
| 58 | 63 |
| 59 BlobRegistryProxy::BlobRegistryProxy() | 64 BlobRegistryProxy::BlobRegistryProxy() |
| 60 : m_webBlobRegistry(WebKit::Platform::current()->blobRegistry()) | 65 : m_webBlobRegistry(WebKit::Platform::current()->blobRegistry()) |
| 61 { | 66 { |
| 67 //ASSERT(isMainThread()); // FIXME: restore this assertion or claim this is
ok. |
| 62 } | 68 } |
| 63 | 69 |
| 64 void BlobRegistryProxy::registerBlobURL(const KURL& url, PassOwnPtr<BlobData> bl
obData) | 70 void BlobRegistryProxy::registerBlobData(const String& uuid, PassOwnPtr<BlobData
> blobData) |
| 65 { | 71 { |
| 66 if (m_webBlobRegistry) { | 72 if (m_webBlobRegistry) { |
| 67 WebBlobData webBlobData(blobData); | 73 WebBlobData webBlobData(blobData); |
| 68 m_webBlobRegistry->registerBlobURL(url, webBlobData); | 74 m_webBlobRegistry->registerBlobData(uuid, webBlobData); |
| 69 } | 75 } |
| 70 } | 76 } |
| 71 | 77 |
| 72 void BlobRegistryProxy::registerBlobURL(const KURL& url, const KURL& srcURL) | 78 void BlobRegistryProxy::addBlobDataRef(const String& uuid) |
| 73 { | 79 { |
| 74 if (m_webBlobRegistry) | 80 if (m_webBlobRegistry) |
| 75 m_webBlobRegistry->registerBlobURL(url, srcURL); | 81 m_webBlobRegistry->addBlobDataRef(uuid); |
| 76 } | 82 } |
| 77 | 83 |
| 78 void BlobRegistryProxy::unregisterBlobURL(const KURL& url) | 84 void BlobRegistryProxy::removeBlobDataRef(const String& uuid) |
| 79 { | 85 { |
| 80 if (m_webBlobRegistry) | 86 if (m_webBlobRegistry) |
| 81 m_webBlobRegistry->unregisterBlobURL(url); | 87 m_webBlobRegistry->removeBlobDataRef(uuid); |
| 88 } |
| 89 |
| 90 void BlobRegistryProxy::registerPublicBlobURL(SecurityOrigin* origin, const KURL
& url, PassRefPtr<BlobDataHandle> blobDataHandle) |
| 91 { |
| 92 BlobRegistry::setCachedUniqueOrigin(url, origin); |
| 93 if (m_webBlobRegistry) |
| 94 m_webBlobRegistry->registerPublicBlobURL(url, blobDataHandle->uuid()); |
| 95 } |
| 96 |
| 97 void BlobRegistryProxy::revokePublicBlobURL(const KURL& url) |
| 98 { |
| 99 BlobRegistry::clearCachedUniqueOrigin(url); |
| 100 if (m_webBlobRegistry) |
| 101 m_webBlobRegistry->revokePublicBlobURL(url); |
| 102 } |
| 103 |
| 104 PassRefPtr<SecurityOrigin> BlobRegistryProxy::cachedUniqueOrigin(const KURL& url
) |
| 105 { |
| 106 return BlobRegistry::getCachedUniqueOrigin(url); |
| 82 } | 107 } |
| 83 | 108 |
| 84 } // namespace WebCore | 109 } // namespace WebCore |
| 85 | 110 |
| 86 #endif | 111 #endif |
| OLD | NEW |