OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2014 Google Inc. All rights reserved. | 2 * Copyright (C) 2014 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 14 matching lines...) Expand all Loading... |
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 "config.h" | 31 #include "config.h" |
32 #include "StorageQuotaClientImpl.h" | 32 #include "StorageQuotaClientImpl.h" |
33 | 33 |
34 #include "WebFrameClient.h" | 34 #include "WebFrameClient.h" |
35 #include "WebFrameImpl.h" | 35 #include "WebLocalFrameImpl.h" |
36 #include "bindings/v8/NewScriptState.h" | 36 #include "bindings/v8/NewScriptState.h" |
37 #include "bindings/v8/ScriptPromise.h" | 37 #include "bindings/v8/ScriptPromise.h" |
38 #include "bindings/v8/ScriptPromiseResolverWithContext.h" | 38 #include "bindings/v8/ScriptPromiseResolverWithContext.h" |
39 #include "core/dom/DOMError.h" | 39 #include "core/dom/DOMError.h" |
40 #include "core/dom/Document.h" | 40 #include "core/dom/Document.h" |
41 #include "core/dom/ExceptionCode.h" | 41 #include "core/dom/ExceptionCode.h" |
42 #include "core/dom/ExecutionContext.h" | 42 #include "core/dom/ExecutionContext.h" |
43 #include "modules/quota/DeprecatedStorageQuotaCallbacksImpl.h" | 43 #include "modules/quota/DeprecatedStorageQuotaCallbacksImpl.h" |
44 #include "modules/quota/StorageErrorCallback.h" | 44 #include "modules/quota/StorageErrorCallback.h" |
45 #include "modules/quota/StorageQuotaCallback.h" | 45 #include "modules/quota/StorageQuotaCallback.h" |
(...skipping 14 matching lines...) Expand all Loading... |
60 StorageQuotaClientImpl::~StorageQuotaClientImpl() | 60 StorageQuotaClientImpl::~StorageQuotaClientImpl() |
61 { | 61 { |
62 } | 62 } |
63 | 63 |
64 void StorageQuotaClientImpl::requestQuota(ExecutionContext* executionContext, We
bStorageQuotaType storageType, unsigned long long newQuotaInBytes, PassOwnPtr<St
orageQuotaCallback> successCallback, PassOwnPtr<StorageErrorCallback> errorCallb
ack) | 64 void StorageQuotaClientImpl::requestQuota(ExecutionContext* executionContext, We
bStorageQuotaType storageType, unsigned long long newQuotaInBytes, PassOwnPtr<St
orageQuotaCallback> successCallback, PassOwnPtr<StorageErrorCallback> errorCallb
ack) |
65 { | 65 { |
66 ASSERT(executionContext); | 66 ASSERT(executionContext); |
67 | 67 |
68 if (executionContext->isDocument()) { | 68 if (executionContext->isDocument()) { |
69 Document* document = toDocument(executionContext); | 69 Document* document = toDocument(executionContext); |
70 WebFrameImpl* webFrame = WebFrameImpl::fromFrame(document->frame()); | 70 WebLocalFrameImpl* webFrame = WebLocalFrameImpl::fromFrame(document->fra
me()); |
71 OwnPtr<StorageQuotaCallbacks> callbacks = DeprecatedStorageQuotaCallback
sImpl::create(successCallback, errorCallback); | 71 OwnPtr<StorageQuotaCallbacks> callbacks = DeprecatedStorageQuotaCallback
sImpl::create(successCallback, errorCallback); |
72 webFrame->client()->requestStorageQuota(webFrame, storageType, newQuotaI
nBytes, callbacks.release()); | 72 webFrame->client()->requestStorageQuota(webFrame, storageType, newQuotaI
nBytes, callbacks.release()); |
73 } else { | 73 } else { |
74 // Requesting quota in Worker is not supported. | 74 // Requesting quota in Worker is not supported. |
75 executionContext->postTask(StorageErrorCallback::CallbackTask::create(er
rorCallback, NotSupportedError)); | 75 executionContext->postTask(StorageErrorCallback::CallbackTask::create(er
rorCallback, NotSupportedError)); |
76 } | 76 } |
77 } | 77 } |
78 | 78 |
79 ScriptPromise StorageQuotaClientImpl::requestPersistentQuota(ExecutionContext* e
xecutionContext, unsigned long long newQuotaInBytes) | 79 ScriptPromise StorageQuotaClientImpl::requestPersistentQuota(ExecutionContext* e
xecutionContext, unsigned long long newQuotaInBytes) |
80 { | 80 { |
81 ASSERT(executionContext); | 81 ASSERT(executionContext); |
82 | 82 |
83 RefPtr<ScriptPromiseResolverWithContext> resolver = ScriptPromiseResolverWit
hContext::create(NewScriptState::current(toIsolate(executionContext))); | 83 RefPtr<ScriptPromiseResolverWithContext> resolver = ScriptPromiseResolverWit
hContext::create(NewScriptState::current(toIsolate(executionContext))); |
84 ScriptPromise promise = resolver->promise(); | 84 ScriptPromise promise = resolver->promise(); |
85 | 85 |
86 if (executionContext->isDocument()) { | 86 if (executionContext->isDocument()) { |
87 Document* document = toDocument(executionContext); | 87 Document* document = toDocument(executionContext); |
88 WebFrameImpl* webFrame = WebFrameImpl::fromFrame(document->frame()); | 88 WebLocalFrameImpl* webFrame = WebLocalFrameImpl::fromFrame(document->fra
me()); |
89 OwnPtr<StorageQuotaCallbacks> callbacks = StorageQuotaCallbacksImpl::cre
ate(resolver); | 89 OwnPtr<StorageQuotaCallbacks> callbacks = StorageQuotaCallbacksImpl::cre
ate(resolver); |
90 webFrame->client()->requestStorageQuota(webFrame, WebStorageQuotaTypePer
sistent, newQuotaInBytes, callbacks.release()); | 90 webFrame->client()->requestStorageQuota(webFrame, WebStorageQuotaTypePer
sistent, newQuotaInBytes, callbacks.release()); |
91 } else { | 91 } else { |
92 // Requesting quota in Worker is not supported. | 92 // Requesting quota in Worker is not supported. |
93 resolver->reject(DOMError::create(NotSupportedError)); | 93 resolver->reject(DOMError::create(NotSupportedError)); |
94 } | 94 } |
95 | 95 |
96 return promise; | 96 return promise; |
97 } | 97 } |
98 | 98 |
99 StorageQuotaClientImpl::StorageQuotaClientImpl() | 99 StorageQuotaClientImpl::StorageQuotaClientImpl() |
100 { | 100 { |
101 } | 101 } |
102 | 102 |
103 } // namespace blink | 103 } // namespace blink |
OLD | NEW |