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 22 matching lines...) Expand all Loading... |
33 | 33 |
34 #include "platform/ThreadSafeFunctional.h" | 34 #include "platform/ThreadSafeFunctional.h" |
35 #include "platform/blob/BlobData.h" | 35 #include "platform/blob/BlobData.h" |
36 #include "platform/blob/BlobURL.h" | 36 #include "platform/blob/BlobURL.h" |
37 #include "platform/weborigin/SecurityOrigin.h" | 37 #include "platform/weborigin/SecurityOrigin.h" |
38 #include "platform/weborigin/SecurityOriginCache.h" | 38 #include "platform/weborigin/SecurityOriginCache.h" |
39 #include "public/platform/Platform.h" | 39 #include "public/platform/Platform.h" |
40 #include "public/platform/WebBlobData.h" | 40 #include "public/platform/WebBlobData.h" |
41 #include "public/platform/WebBlobRegistry.h" | 41 #include "public/platform/WebBlobRegistry.h" |
42 #include "public/platform/WebString.h" | 42 #include "public/platform/WebString.h" |
| 43 #include "public/platform/WebTaskRunner.h" |
43 #include "public/platform/WebTraceLocation.h" | 44 #include "public/platform/WebTraceLocation.h" |
44 #include "wtf/Assertions.h" | 45 #include "wtf/Assertions.h" |
45 #include "wtf/HashMap.h" | 46 #include "wtf/HashMap.h" |
46 #include "wtf/MainThread.h" | 47 #include "wtf/MainThread.h" |
47 #include "wtf/RefPtr.h" | 48 #include "wtf/RefPtr.h" |
48 #include "wtf/ThreadSpecific.h" | 49 #include "wtf/ThreadSpecific.h" |
49 #include "wtf/Threading.h" | 50 #include "wtf/Threading.h" |
50 #include "wtf/text/StringHash.h" | 51 #include "wtf/text/StringHash.h" |
51 #include "wtf/text/WTFString.h" | 52 #include "wtf/text/WTFString.h" |
52 | 53 |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 { | 121 { |
121 if (WebBlobRegistry* registry = blobRegistry()) | 122 if (WebBlobRegistry* registry = blobRegistry()) |
122 registry->registerStreamURL(url, type); | 123 registry->registerStreamURL(url, type); |
123 } | 124 } |
124 | 125 |
125 void BlobRegistry::registerStreamURL(const KURL& url, const String& type) | 126 void BlobRegistry::registerStreamURL(const KURL& url, const String& type) |
126 { | 127 { |
127 if (isMainThread()) | 128 if (isMainThread()) |
128 registerStreamURLTask(url, type); | 129 registerStreamURLTask(url, type); |
129 else | 130 else |
130 Platform::current()->mainThread()->postTask(FROM_HERE, threadSafeBind(&r
egisterStreamURLTask, url, type)); | 131 Platform::current()->mainThread()->taskRunner()->postTask(FROM_HERE, thr
eadSafeBind(®isterStreamURLTask, url, type)); |
131 } | 132 } |
132 | 133 |
133 static void registerStreamURLFromTask(const KURL& url, const KURL& srcURL) | 134 static void registerStreamURLFromTask(const KURL& url, const KURL& srcURL) |
134 { | 135 { |
135 if (WebBlobRegistry* registry = blobRegistry()) | 136 if (WebBlobRegistry* registry = blobRegistry()) |
136 registry->registerStreamURL(url, srcURL); | 137 registry->registerStreamURL(url, srcURL); |
137 } | 138 } |
138 | 139 |
139 void BlobRegistry::registerStreamURL(SecurityOrigin* origin, const KURL& url, co
nst KURL& srcURL) | 140 void BlobRegistry::registerStreamURL(SecurityOrigin* origin, const KURL& url, co
nst KURL& srcURL) |
140 { | 141 { |
141 saveToOriginMap(origin, url); | 142 saveToOriginMap(origin, url); |
142 | 143 |
143 if (isMainThread()) | 144 if (isMainThread()) |
144 registerStreamURLFromTask(url, srcURL); | 145 registerStreamURLFromTask(url, srcURL); |
145 else | 146 else |
146 Platform::current()->mainThread()->postTask(FROM_HERE, threadSafeBind(&r
egisterStreamURLFromTask, url, srcURL)); | 147 Platform::current()->mainThread()->taskRunner()->postTask(FROM_HERE, thr
eadSafeBind(®isterStreamURLFromTask, url, srcURL)); |
147 } | 148 } |
148 | 149 |
149 static void addDataToStreamTask(const KURL& url, PassRefPtr<RawData> streamData) | 150 static void addDataToStreamTask(const KURL& url, PassRefPtr<RawData> streamData) |
150 { | 151 { |
151 if (WebBlobRegistry* registry = blobRegistry()) | 152 if (WebBlobRegistry* registry = blobRegistry()) |
152 registry->addDataToStream(url, streamData->data(), streamData->length())
; | 153 registry->addDataToStream(url, streamData->data(), streamData->length())
; |
153 } | 154 } |
154 | 155 |
155 void BlobRegistry::addDataToStream(const KURL& url, PassRefPtr<RawData> streamDa
ta) | 156 void BlobRegistry::addDataToStream(const KURL& url, PassRefPtr<RawData> streamDa
ta) |
156 { | 157 { |
157 if (isMainThread()) | 158 if (isMainThread()) |
158 addDataToStreamTask(url, streamData); | 159 addDataToStreamTask(url, streamData); |
159 else | 160 else |
160 Platform::current()->mainThread()->postTask(FROM_HERE, threadSafeBind(&a
ddDataToStreamTask, url, streamData)); | 161 Platform::current()->mainThread()->taskRunner()->postTask(FROM_HERE, thr
eadSafeBind(&addDataToStreamTask, url, streamData)); |
161 } | 162 } |
162 | 163 |
163 static void flushStreamTask(const KURL& url) | 164 static void flushStreamTask(const KURL& url) |
164 { | 165 { |
165 if (WebBlobRegistry* registry = blobRegistry()) | 166 if (WebBlobRegistry* registry = blobRegistry()) |
166 registry->flushStream(url); | 167 registry->flushStream(url); |
167 } | 168 } |
168 | 169 |
169 void BlobRegistry::flushStream(const KURL& url) | 170 void BlobRegistry::flushStream(const KURL& url) |
170 { | 171 { |
171 if (isMainThread()) | 172 if (isMainThread()) |
172 flushStreamTask(url); | 173 flushStreamTask(url); |
173 else | 174 else |
174 Platform::current()->mainThread()->postTask(FROM_HERE, threadSafeBind(&f
lushStreamTask, url)); | 175 Platform::current()->mainThread()->taskRunner()->postTask(FROM_HERE, thr
eadSafeBind(&flushStreamTask, url)); |
175 } | 176 } |
176 | 177 |
177 static void finalizeStreamTask(const KURL& url) | 178 static void finalizeStreamTask(const KURL& url) |
178 { | 179 { |
179 if (WebBlobRegistry* registry = blobRegistry()) | 180 if (WebBlobRegistry* registry = blobRegistry()) |
180 registry->finalizeStream(url); | 181 registry->finalizeStream(url); |
181 } | 182 } |
182 | 183 |
183 void BlobRegistry::finalizeStream(const KURL& url) | 184 void BlobRegistry::finalizeStream(const KURL& url) |
184 { | 185 { |
185 if (isMainThread()) | 186 if (isMainThread()) |
186 finalizeStreamTask(url); | 187 finalizeStreamTask(url); |
187 else | 188 else |
188 Platform::current()->mainThread()->postTask(FROM_HERE, threadSafeBind(&f
inalizeStreamTask, url)); | 189 Platform::current()->mainThread()->taskRunner()->postTask(FROM_HERE, thr
eadSafeBind(&finalizeStreamTask, url)); |
189 } | 190 } |
190 | 191 |
191 static void abortStreamTask(const KURL& url) | 192 static void abortStreamTask(const KURL& url) |
192 { | 193 { |
193 if (WebBlobRegistry* registry = blobRegistry()) | 194 if (WebBlobRegistry* registry = blobRegistry()) |
194 registry->abortStream(url); | 195 registry->abortStream(url); |
195 } | 196 } |
196 | 197 |
197 void BlobRegistry::abortStream(const KURL& url) | 198 void BlobRegistry::abortStream(const KURL& url) |
198 { | 199 { |
199 if (isMainThread()) | 200 if (isMainThread()) |
200 abortStreamTask(url); | 201 abortStreamTask(url); |
201 else | 202 else |
202 Platform::current()->mainThread()->postTask(FROM_HERE, threadSafeBind(&a
bortStreamTask, url)); | 203 Platform::current()->mainThread()->taskRunner()->postTask(FROM_HERE, thr
eadSafeBind(&abortStreamTask, url)); |
203 } | 204 } |
204 | 205 |
205 static void unregisterStreamURLTask(const KURL& url) | 206 static void unregisterStreamURLTask(const KURL& url) |
206 { | 207 { |
207 if (WebBlobRegistry* registry = blobRegistry()) | 208 if (WebBlobRegistry* registry = blobRegistry()) |
208 registry->unregisterStreamURL(url); | 209 registry->unregisterStreamURL(url); |
209 } | 210 } |
210 | 211 |
211 void BlobRegistry::unregisterStreamURL(const KURL& url) | 212 void BlobRegistry::unregisterStreamURL(const KURL& url) |
212 { | 213 { |
213 removeFromOriginMap(url); | 214 removeFromOriginMap(url); |
214 | 215 |
215 if (isMainThread()) | 216 if (isMainThread()) |
216 unregisterStreamURLTask(url); | 217 unregisterStreamURLTask(url); |
217 else | 218 else |
218 Platform::current()->mainThread()->postTask(FROM_HERE, threadSafeBind(&u
nregisterStreamURLTask, url)); | 219 Platform::current()->mainThread()->taskRunner()->postTask(FROM_HERE, thr
eadSafeBind(&unregisterStreamURLTask, url)); |
219 } | 220 } |
220 | 221 |
221 BlobOriginCache::BlobOriginCache() | 222 BlobOriginCache::BlobOriginCache() |
222 { | 223 { |
223 SecurityOrigin::setCache(this); | 224 SecurityOrigin::setCache(this); |
224 } | 225 } |
225 | 226 |
226 SecurityOrigin* BlobOriginCache::cachedOrigin(const KURL& url) | 227 SecurityOrigin* BlobOriginCache::cachedOrigin(const KURL& url) |
227 { | 228 { |
228 if (url.protocolIs("blob")) | 229 if (url.protocolIs("blob")) |
229 return originMap()->get(url.string()); | 230 return originMap()->get(url.string()); |
230 return 0; | 231 return 0; |
231 } | 232 } |
232 | 233 |
233 } // namespace blink | 234 } // namespace blink |
OLD | NEW |