Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(201)

Side by Side Diff: third_party/WebKit/Source/core/fileapi/Blob.cpp

Issue 2697723003: Replace [CallWith=ExecutionContext] with [CallWith=ScriptState] (Closed)
Patch Set: Window.{focus|close} both take ExecutionContext. Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 "core/fileapi/Blob.h" 31 #include "core/fileapi/Blob.h"
32 32
33 #include <memory>
33 #include "bindings/core/v8/ExceptionState.h" 34 #include "bindings/core/v8/ExceptionState.h"
35 #include "bindings/core/v8/ScriptState.h"
34 #include "core/dom/DOMURL.h" 36 #include "core/dom/DOMURL.h"
35 #include "core/dom/ExceptionCode.h" 37 #include "core/dom/ExceptionCode.h"
36 #include "core/dom/ExecutionContext.h" 38 #include "core/dom/ExecutionContext.h"
37 #include "core/fileapi/BlobPropertyBag.h" 39 #include "core/fileapi/BlobPropertyBag.h"
38 #include "core/frame/UseCounter.h" 40 #include "core/frame/UseCounter.h"
39 #include "platform/blob/BlobRegistry.h" 41 #include "platform/blob/BlobRegistry.h"
40 #include "platform/blob/BlobURL.h" 42 #include "platform/blob/BlobURL.h"
41 #include <memory>
42 43
43 namespace blink { 44 namespace blink {
44 45
45 namespace { 46 namespace {
46 47
47 class BlobURLRegistry final : public URLRegistry { 48 class BlobURLRegistry final : public URLRegistry {
48 public: 49 public:
49 // SecurityOrigin is passed together with KURL so that the registry can 50 // SecurityOrigin is passed together with KURL so that the registry can
50 // save it for entries from whose KURL the origin is not recoverable by 51 // save it for entries from whose KURL the origin is not recoverable by
51 // using BlobURL::getOrigin(). 52 // using BlobURL::getOrigin().
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 long long size = this->size(); 187 long long size = this->size();
187 clampSliceOffsets(size, start, end); 188 clampSliceOffsets(size, start, end);
188 189
189 long long length = end - start; 190 long long length = end - start;
190 std::unique_ptr<BlobData> blobData = BlobData::create(); 191 std::unique_ptr<BlobData> blobData = BlobData::create();
191 blobData->setContentType(contentType); 192 blobData->setContentType(contentType);
192 blobData->appendBlob(m_blobDataHandle, start, length); 193 blobData->appendBlob(m_blobDataHandle, start, length);
193 return Blob::create(BlobDataHandle::create(std::move(blobData), length)); 194 return Blob::create(BlobDataHandle::create(std::move(blobData), length));
194 } 195 }
195 196
196 void Blob::close(ExecutionContext* executionContext, 197 void Blob::close(ScriptState* scriptState, ExceptionState& exceptionState) {
197 ExceptionState& exceptionState) {
198 if (isClosed()) { 198 if (isClosed()) {
199 exceptionState.throwDOMException(InvalidStateError, 199 exceptionState.throwDOMException(InvalidStateError,
200 "Blob has been closed."); 200 "Blob has been closed.");
201 return; 201 return;
202 } 202 }
203 203
204 // Dereferencing a Blob that has been closed should result in 204 // Dereferencing a Blob that has been closed should result in
205 // a network error. Revoke URLs registered against it through 205 // a network error. Revoke URLs registered against it through
206 // its UUID. 206 // its UUID.
207 DOMURL::revokeObjectUUID(executionContext, uuid()); 207 DOMURL::revokeObjectUUID(scriptState->getExecutionContext(), uuid());
208 208
209 // A Blob enters a 'readability state' of closed, where it will report its 209 // A Blob enters a 'readability state' of closed, where it will report its
210 // size as zero. Blob and FileReader operations now throws on 210 // size as zero. Blob and FileReader operations now throws on
211 // being passed a Blob in that state. Downstream uses of closed Blobs 211 // being passed a Blob in that state. Downstream uses of closed Blobs
212 // (e.g., XHR.send()) consider them as empty. 212 // (e.g., XHR.send()) consider them as empty.
213 std::unique_ptr<BlobData> blobData = BlobData::create(); 213 std::unique_ptr<BlobData> blobData = BlobData::create();
214 blobData->setContentType(type()); 214 blobData->setContentType(type());
215 m_blobDataHandle = BlobDataHandle::create(std::move(blobData), 0); 215 m_blobDataHandle = BlobDataHandle::create(std::move(blobData), 0);
216 m_isClosed = true; 216 m_isClosed = true;
217 } 217 }
218 218
219 void Blob::appendTo(BlobData& blobData) const { 219 void Blob::appendTo(BlobData& blobData) const {
220 blobData.appendBlob(m_blobDataHandle, 0, m_blobDataHandle->size()); 220 blobData.appendBlob(m_blobDataHandle, 0, m_blobDataHandle->size());
221 } 221 }
222 222
223 URLRegistry& Blob::registry() const { 223 URLRegistry& Blob::registry() const {
224 return BlobURLRegistry::registry(); 224 return BlobURLRegistry::registry();
225 } 225 }
226 226
227 } // namespace blink 227 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/fileapi/Blob.h ('k') | third_party/WebKit/Source/core/fileapi/Blob.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698