| 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 12 matching lines...) Expand all Loading... |
| 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 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 #include "platform/blob/BlobRegistry.h" | 31 #include "platform/blob/BlobRegistry.h" |
| 32 | 32 |
| 33 #include "platform/ThreadSafeFunctional.h" | 33 #include "platform/CrossThreadFunctional.h" |
| 34 #include "platform/blob/BlobData.h" | 34 #include "platform/blob/BlobData.h" |
| 35 #include "platform/blob/BlobURL.h" | 35 #include "platform/blob/BlobURL.h" |
| 36 #include "platform/weborigin/SecurityOrigin.h" | 36 #include "platform/weborigin/SecurityOrigin.h" |
| 37 #include "platform/weborigin/SecurityOriginCache.h" | 37 #include "platform/weborigin/SecurityOriginCache.h" |
| 38 #include "public/platform/Platform.h" | 38 #include "public/platform/Platform.h" |
| 39 #include "public/platform/WebBlobData.h" | 39 #include "public/platform/WebBlobData.h" |
| 40 #include "public/platform/WebBlobRegistry.h" | 40 #include "public/platform/WebBlobRegistry.h" |
| 41 #include "public/platform/WebString.h" | 41 #include "public/platform/WebString.h" |
| 42 #include "public/platform/WebTaskRunner.h" | 42 #include "public/platform/WebTaskRunner.h" |
| 43 #include "public/platform/WebTraceLocation.h" | 43 #include "public/platform/WebTraceLocation.h" |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 { | 120 { |
| 121 if (WebBlobRegistry* registry = blobRegistry()) | 121 if (WebBlobRegistry* registry = blobRegistry()) |
| 122 registry->registerStreamURL(url, type); | 122 registry->registerStreamURL(url, type); |
| 123 } | 123 } |
| 124 | 124 |
| 125 void BlobRegistry::registerStreamURL(const KURL& url, const String& type) | 125 void BlobRegistry::registerStreamURL(const KURL& url, const String& type) |
| 126 { | 126 { |
| 127 if (isMainThread()) | 127 if (isMainThread()) |
| 128 registerStreamURLTask(url, type); | 128 registerStreamURLTask(url, type); |
| 129 else | 129 else |
| 130 Platform::current()->mainThread()->getWebTaskRunner()->postTask(BLINK_FR
OM_HERE, threadSafeBind(®isterStreamURLTask, url, type)); | 130 Platform::current()->mainThread()->getWebTaskRunner()->postTask(BLINK_FR
OM_HERE, crossThreadBind(®isterStreamURLTask, url, type)); |
| 131 } | 131 } |
| 132 | 132 |
| 133 static void registerStreamURLFromTask(const KURL& url, const KURL& srcURL) | 133 static void registerStreamURLFromTask(const KURL& url, const KURL& srcURL) |
| 134 { | 134 { |
| 135 if (WebBlobRegistry* registry = blobRegistry()) | 135 if (WebBlobRegistry* registry = blobRegistry()) |
| 136 registry->registerStreamURL(url, srcURL); | 136 registry->registerStreamURL(url, srcURL); |
| 137 } | 137 } |
| 138 | 138 |
| 139 void BlobRegistry::registerStreamURL(SecurityOrigin* origin, const KURL& url, co
nst KURL& srcURL) | 139 void BlobRegistry::registerStreamURL(SecurityOrigin* origin, const KURL& url, co
nst KURL& srcURL) |
| 140 { | 140 { |
| 141 saveToOriginMap(origin, url); | 141 saveToOriginMap(origin, url); |
| 142 | 142 |
| 143 if (isMainThread()) | 143 if (isMainThread()) |
| 144 registerStreamURLFromTask(url, srcURL); | 144 registerStreamURLFromTask(url, srcURL); |
| 145 else | 145 else |
| 146 Platform::current()->mainThread()->getWebTaskRunner()->postTask(BLINK_FR
OM_HERE, threadSafeBind(®isterStreamURLFromTask, url, srcURL)); | 146 Platform::current()->mainThread()->getWebTaskRunner()->postTask(BLINK_FR
OM_HERE, crossThreadBind(®isterStreamURLFromTask, url, srcURL)); |
| 147 } | 147 } |
| 148 | 148 |
| 149 static void addDataToStreamTask(const KURL& url, PassRefPtr<RawData> streamData) | 149 static void addDataToStreamTask(const KURL& url, PassRefPtr<RawData> streamData) |
| 150 { | 150 { |
| 151 if (WebBlobRegistry* registry = blobRegistry()) | 151 if (WebBlobRegistry* registry = blobRegistry()) |
| 152 registry->addDataToStream(url, streamData->data(), streamData->length())
; | 152 registry->addDataToStream(url, streamData->data(), streamData->length())
; |
| 153 } | 153 } |
| 154 | 154 |
| 155 void BlobRegistry::addDataToStream(const KURL& url, PassRefPtr<RawData> streamDa
ta) | 155 void BlobRegistry::addDataToStream(const KURL& url, PassRefPtr<RawData> streamDa
ta) |
| 156 { | 156 { |
| 157 if (isMainThread()) | 157 if (isMainThread()) |
| 158 addDataToStreamTask(url, streamData); | 158 addDataToStreamTask(url, streamData); |
| 159 else | 159 else |
| 160 Platform::current()->mainThread()->getWebTaskRunner()->postTask(BLINK_FR
OM_HERE, threadSafeBind(&addDataToStreamTask, url, streamData)); | 160 Platform::current()->mainThread()->getWebTaskRunner()->postTask(BLINK_FR
OM_HERE, crossThreadBind(&addDataToStreamTask, url, streamData)); |
| 161 } | 161 } |
| 162 | 162 |
| 163 static void flushStreamTask(const KURL& url) | 163 static void flushStreamTask(const KURL& url) |
| 164 { | 164 { |
| 165 if (WebBlobRegistry* registry = blobRegistry()) | 165 if (WebBlobRegistry* registry = blobRegistry()) |
| 166 registry->flushStream(url); | 166 registry->flushStream(url); |
| 167 } | 167 } |
| 168 | 168 |
| 169 void BlobRegistry::flushStream(const KURL& url) | 169 void BlobRegistry::flushStream(const KURL& url) |
| 170 { | 170 { |
| 171 if (isMainThread()) | 171 if (isMainThread()) |
| 172 flushStreamTask(url); | 172 flushStreamTask(url); |
| 173 else | 173 else |
| 174 Platform::current()->mainThread()->getWebTaskRunner()->postTask(BLINK_FR
OM_HERE, threadSafeBind(&flushStreamTask, url)); | 174 Platform::current()->mainThread()->getWebTaskRunner()->postTask(BLINK_FR
OM_HERE, crossThreadBind(&flushStreamTask, url)); |
| 175 } | 175 } |
| 176 | 176 |
| 177 static void finalizeStreamTask(const KURL& url) | 177 static void finalizeStreamTask(const KURL& url) |
| 178 { | 178 { |
| 179 if (WebBlobRegistry* registry = blobRegistry()) | 179 if (WebBlobRegistry* registry = blobRegistry()) |
| 180 registry->finalizeStream(url); | 180 registry->finalizeStream(url); |
| 181 } | 181 } |
| 182 | 182 |
| 183 void BlobRegistry::finalizeStream(const KURL& url) | 183 void BlobRegistry::finalizeStream(const KURL& url) |
| 184 { | 184 { |
| 185 if (isMainThread()) | 185 if (isMainThread()) |
| 186 finalizeStreamTask(url); | 186 finalizeStreamTask(url); |
| 187 else | 187 else |
| 188 Platform::current()->mainThread()->getWebTaskRunner()->postTask(BLINK_FR
OM_HERE, threadSafeBind(&finalizeStreamTask, url)); | 188 Platform::current()->mainThread()->getWebTaskRunner()->postTask(BLINK_FR
OM_HERE, crossThreadBind(&finalizeStreamTask, url)); |
| 189 } | 189 } |
| 190 | 190 |
| 191 static void abortStreamTask(const KURL& url) | 191 static void abortStreamTask(const KURL& url) |
| 192 { | 192 { |
| 193 if (WebBlobRegistry* registry = blobRegistry()) | 193 if (WebBlobRegistry* registry = blobRegistry()) |
| 194 registry->abortStream(url); | 194 registry->abortStream(url); |
| 195 } | 195 } |
| 196 | 196 |
| 197 void BlobRegistry::abortStream(const KURL& url) | 197 void BlobRegistry::abortStream(const KURL& url) |
| 198 { | 198 { |
| 199 if (isMainThread()) | 199 if (isMainThread()) |
| 200 abortStreamTask(url); | 200 abortStreamTask(url); |
| 201 else | 201 else |
| 202 Platform::current()->mainThread()->getWebTaskRunner()->postTask(BLINK_FR
OM_HERE, threadSafeBind(&abortStreamTask, url)); | 202 Platform::current()->mainThread()->getWebTaskRunner()->postTask(BLINK_FR
OM_HERE, crossThreadBind(&abortStreamTask, url)); |
| 203 } | 203 } |
| 204 | 204 |
| 205 static void unregisterStreamURLTask(const KURL& url) | 205 static void unregisterStreamURLTask(const KURL& url) |
| 206 { | 206 { |
| 207 if (WebBlobRegistry* registry = blobRegistry()) | 207 if (WebBlobRegistry* registry = blobRegistry()) |
| 208 registry->unregisterStreamURL(url); | 208 registry->unregisterStreamURL(url); |
| 209 } | 209 } |
| 210 | 210 |
| 211 void BlobRegistry::unregisterStreamURL(const KURL& url) | 211 void BlobRegistry::unregisterStreamURL(const KURL& url) |
| 212 { | 212 { |
| 213 removeFromOriginMap(url); | 213 removeFromOriginMap(url); |
| 214 | 214 |
| 215 if (isMainThread()) | 215 if (isMainThread()) |
| 216 unregisterStreamURLTask(url); | 216 unregisterStreamURLTask(url); |
| 217 else | 217 else |
| 218 Platform::current()->mainThread()->getWebTaskRunner()->postTask(BLINK_FR
OM_HERE, threadSafeBind(&unregisterStreamURLTask, url)); | 218 Platform::current()->mainThread()->getWebTaskRunner()->postTask(BLINK_FR
OM_HERE, crossThreadBind(&unregisterStreamURLTask, url)); |
| 219 } | 219 } |
| 220 | 220 |
| 221 BlobOriginCache::BlobOriginCache() | 221 BlobOriginCache::BlobOriginCache() |
| 222 { | 222 { |
| 223 SecurityOrigin::setCache(this); | 223 SecurityOrigin::setCache(this); |
| 224 } | 224 } |
| 225 | 225 |
| 226 SecurityOrigin* BlobOriginCache::cachedOrigin(const KURL& url) | 226 SecurityOrigin* BlobOriginCache::cachedOrigin(const KURL& url) |
| 227 { | 227 { |
| 228 if (url.protocolIs("blob")) | 228 if (url.protocolIs("blob")) |
| 229 return originMap()->get(url.getString()); | 229 return originMap()->get(url.getString()); |
| 230 return 0; | 230 return 0; |
| 231 } | 231 } |
| 232 | 232 |
| 233 } // namespace blink | 233 } // namespace blink |
| OLD | NEW |