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