OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "core/fileapi/URLFileAPI.h" | 5 #include "core/fileapi/URLFileAPI.h" |
6 | 6 |
7 #include "bindings/core/v8/ExceptionState.h" | 7 #include "bindings/core/v8/ExceptionState.h" |
8 #include "core/dom/DOMURL.h" | 8 #include "core/dom/DOMURL.h" |
9 #include "core/dom/ExecutionContext.h" | 9 #include "core/dom/ExecutionContext.h" |
10 #include "core/fileapi/Blob.h" | 10 #include "core/fileapi/Blob.h" |
11 #include "core/frame/Deprecation.h" | |
12 #include "core/frame/UseCounter.h" | |
13 #include "core/html/PublicURLManager.h" | 11 #include "core/html/PublicURLManager.h" |
14 | 12 |
15 namespace blink { | 13 namespace blink { |
16 | 14 |
17 // static | 15 // static |
18 String URLFileAPI::createObjectURL(ExecutionContext* executionContext, Blob* blo
b, ExceptionState& exceptionState) | 16 String URLFileAPI::createObjectURL(ExecutionContext* executionContext, Blob* blo
b, ExceptionState& exceptionState) |
19 { | 17 { |
20 DCHECK(blob); | 18 DCHECK(blob); |
21 DCHECK(executionContext); | 19 DCHECK(executionContext); |
22 | 20 |
23 if (executionContext->isServiceWorkerGlobalScope()) | |
24 Deprecation::countDeprecation(executionContext, UseCounter::URLMethodCre
ateObjectURLServiceWorker); | |
25 | |
26 if (blob->isClosed()) { | 21 if (blob->isClosed()) { |
27 exceptionState.throwDOMException(InvalidStateError, String(blob->isFile(
) ? "File" : "Blob") + " has been closed."); | 22 exceptionState.throwDOMException(InvalidStateError, String(blob->isFile(
) ? "File" : "Blob") + " has been closed."); |
28 return String(); | 23 return String(); |
29 } | 24 } |
30 return DOMURL::createPublicURL(executionContext, blob, blob->uuid()); | 25 return DOMURL::createPublicURL(executionContext, blob, blob->uuid()); |
31 } | 26 } |
32 | 27 |
33 // static | 28 // static |
34 void URLFileAPI::revokeObjectURL(ExecutionContext* executionContext, const Strin
g& urlString) | 29 void URLFileAPI::revokeObjectURL(ExecutionContext* executionContext, const Strin
g& urlString) |
35 { | 30 { |
36 DCHECK(executionContext); | 31 DCHECK(executionContext); |
37 | 32 |
38 if (executionContext->isServiceWorkerGlobalScope()) | |
39 Deprecation::countDeprecation(executionContext, UseCounter::URLMethodRev
okeObjectURLServiceWorker); | |
40 | |
41 KURL url(KURL(), urlString); | 33 KURL url(KURL(), urlString); |
42 executionContext->removeURLFromMemoryCache(url); | 34 executionContext->removeURLFromMemoryCache(url); |
43 executionContext->publicURLManager().revoke(url); | 35 executionContext->publicURLManager().revoke(url); |
44 } | 36 } |
45 | 37 |
46 } // namespace blink | 38 } // namespace blink |
OLD | NEW |