| 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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 #include "public/platform/WebThreadSafeData.h" | 42 #include "public/platform/WebThreadSafeData.h" |
| 43 #include "wtf/Assertions.h" | 43 #include "wtf/Assertions.h" |
| 44 #include "wtf/HashMap.h" | 44 #include "wtf/HashMap.h" |
| 45 #include "wtf/MainThread.h" | 45 #include "wtf/MainThread.h" |
| 46 #include "wtf/RefPtr.h" | 46 #include "wtf/RefPtr.h" |
| 47 #include "wtf/ThreadSpecific.h" | 47 #include "wtf/ThreadSpecific.h" |
| 48 #include "wtf/Threading.h" | 48 #include "wtf/Threading.h" |
| 49 #include "wtf/text/StringHash.h" | 49 #include "wtf/text/StringHash.h" |
| 50 #include "wtf/text/WTFString.h" | 50 #include "wtf/text/WTFString.h" |
| 51 | 51 |
| 52 using blink::WebBlobData; | |
| 53 using blink::WebBlobRegistry; | |
| 54 using blink::WebThreadSafeData; | |
| 55 using WTF::ThreadSpecific; | |
| 56 | |
| 57 namespace blink { | 52 namespace blink { |
| 58 | 53 |
| 59 class BlobOriginCache : public SecurityOriginCache { | 54 class BlobOriginCache : public SecurityOriginCache { |
| 60 public: | 55 public: |
| 61 BlobOriginCache(); | 56 BlobOriginCache(); |
| 62 virtual SecurityOrigin* cachedOrigin(const KURL&) OVERRIDE; | 57 virtual SecurityOrigin* cachedOrigin(const KURL&) OVERRIDE; |
| 63 }; | 58 }; |
| 64 | 59 |
| 65 struct BlobRegistryContext { | 60 struct BlobRegistryContext { |
| 66 WTF_MAKE_FAST_ALLOCATED; | 61 WTF_MAKE_FAST_ALLOCATED; |
| (...skipping 30 matching lines...) Expand all Loading... |
| 97 | 92 |
| 98 KURL url; | 93 KURL url; |
| 99 KURL srcURL; | 94 KURL srcURL; |
| 100 OwnPtr<BlobData> blobData; | 95 OwnPtr<BlobData> blobData; |
| 101 PassRefPtr<RawData> streamData; | 96 PassRefPtr<RawData> streamData; |
| 102 String type; | 97 String type; |
| 103 }; | 98 }; |
| 104 | 99 |
| 105 static WebBlobRegistry* blobRegistry() | 100 static WebBlobRegistry* blobRegistry() |
| 106 { | 101 { |
| 107 return blink::Platform::current()->blobRegistry(); | 102 return Platform::current()->blobRegistry(); |
| 108 } | 103 } |
| 109 | 104 |
| 110 typedef HashMap<String, RefPtr<SecurityOrigin> > BlobURLOriginMap; | 105 typedef HashMap<String, RefPtr<SecurityOrigin> > BlobURLOriginMap; |
| 111 static ThreadSpecific<BlobURLOriginMap>& originMap() | 106 static ThreadSpecific<BlobURLOriginMap>& originMap() |
| 112 { | 107 { |
| 113 // We want to create the BlobOriginCache exactly once because it is shared b
y all the threads. | 108 // We want to create the BlobOriginCache exactly once because it is shared b
y all the threads. |
| 114 AtomicallyInitializedStatic(BlobOriginCache*, cache = new BlobOriginCache); | 109 AtomicallyInitializedStatic(BlobOriginCache*, cache = new BlobOriginCache); |
| 115 (void)cache; // BlobOriginCache's constructor does the interesting work. | 110 (void)cache; // BlobOriginCache's constructor does the interesting work. |
| 116 | 111 |
| 117 AtomicallyInitializedStatic(ThreadSpecific<BlobURLOriginMap>*, map = new Thr
eadSpecific<BlobURLOriginMap>); | 112 AtomicallyInitializedStatic(ThreadSpecific<BlobURLOriginMap>*, map = new Thr
eadSpecific<BlobURLOriginMap>); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 128 } | 123 } |
| 129 | 124 |
| 130 static void removeFromOriginMap(const KURL& url) | 125 static void removeFromOriginMap(const KURL& url) |
| 131 { | 126 { |
| 132 if (BlobURL::getOrigin(url) == "null") | 127 if (BlobURL::getOrigin(url) == "null") |
| 133 originMap()->remove(url.string()); | 128 originMap()->remove(url.string()); |
| 134 } | 129 } |
| 135 | 130 |
| 136 void BlobRegistry::registerBlobData(const String& uuid, PassOwnPtr<BlobData> dat
a) | 131 void BlobRegistry::registerBlobData(const String& uuid, PassOwnPtr<BlobData> dat
a) |
| 137 { | 132 { |
| 138 blobRegistry()->registerBlobData(uuid, blink::WebBlobData(data)); | 133 blobRegistry()->registerBlobData(uuid, WebBlobData(data)); |
| 139 } | 134 } |
| 140 | 135 |
| 141 void BlobRegistry::addBlobDataRef(const String& uuid) | 136 void BlobRegistry::addBlobDataRef(const String& uuid) |
| 142 { | 137 { |
| 143 blobRegistry()->addBlobDataRef(uuid); | 138 blobRegistry()->addBlobDataRef(uuid); |
| 144 } | 139 } |
| 145 | 140 |
| 146 void BlobRegistry::removeBlobDataRef(const String& uuid) | 141 void BlobRegistry::removeBlobDataRef(const String& uuid) |
| 147 { | 142 { |
| 148 blobRegistry()->removeBlobDataRef(uuid); | 143 blobRegistry()->removeBlobDataRef(uuid); |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 282 } | 277 } |
| 283 | 278 |
| 284 SecurityOrigin* BlobOriginCache::cachedOrigin(const KURL& url) | 279 SecurityOrigin* BlobOriginCache::cachedOrigin(const KURL& url) |
| 285 { | 280 { |
| 286 if (url.protocolIs("blob")) | 281 if (url.protocolIs("blob")) |
| 287 return originMap()->get(url.string()); | 282 return originMap()->get(url.string()); |
| 288 return 0; | 283 return 0; |
| 289 } | 284 } |
| 290 | 285 |
| 291 } // namespace blink | 286 } // namespace blink |
| OLD | NEW |