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

Side by Side Diff: third_party/WebKit/Source/modules/quota/DeprecatedStorageQuota.cpp

Issue 2656343002: Replace [CallWith=ExecutionContext] with [CallWith=ScriptState] (Closed)
Patch Set: Few more Created 3 years, 10 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) 2011 Google Inc. All rights reserved. 2 * Copyright (C) 2011 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 "modules/quota/DeprecatedStorageQuota.h" 31 #include "modules/quota/DeprecatedStorageQuota.h"
32 32
33 #include "bindings/core/v8/ScriptState.h"
33 #include "core/dom/ExceptionCode.h" 34 #include "core/dom/ExceptionCode.h"
34 #include "core/dom/ExecutionContext.h" 35 #include "core/dom/ExecutionContext.h"
35 #include "core/dom/TaskRunnerHelper.h" 36 #include "core/dom/TaskRunnerHelper.h"
36 #include "modules/quota/DeprecatedStorageQuotaCallbacksImpl.h" 37 #include "modules/quota/DeprecatedStorageQuotaCallbacksImpl.h"
37 #include "modules/quota/StorageErrorCallback.h" 38 #include "modules/quota/StorageErrorCallback.h"
38 #include "modules/quota/StorageQuotaClient.h" 39 #include "modules/quota/StorageQuotaClient.h"
39 #include "modules/quota/StorageUsageCallback.h" 40 #include "modules/quota/StorageUsageCallback.h"
40 #include "platform/StorageQuotaCallbacks.h" 41 #include "platform/StorageQuotaCallbacks.h"
41 #include "platform/weborigin/KURL.h" 42 #include "platform/weborigin/KURL.h"
42 #include "platform/weborigin/SecurityOrigin.h" 43 #include "platform/weborigin/SecurityOrigin.h"
43 #include "public/platform/Platform.h" 44 #include "public/platform/Platform.h"
44 #include "public/platform/WebStorageQuotaCallbacks.h" 45 #include "public/platform/WebStorageQuotaCallbacks.h"
45 #include "public/platform/WebStorageQuotaType.h" 46 #include "public/platform/WebStorageQuotaType.h"
46 #include "public/platform/WebTraceLocation.h" 47 #include "public/platform/WebTraceLocation.h"
47 48
48 namespace blink { 49 namespace blink {
49 50
50 DeprecatedStorageQuota::DeprecatedStorageQuota(Type type) : m_type(type) {} 51 DeprecatedStorageQuota::DeprecatedStorageQuota(Type type) : m_type(type) {}
51 52
52 void DeprecatedStorageQuota::queryUsageAndQuota( 53 void DeprecatedStorageQuota::queryUsageAndQuota(
53 ExecutionContext* executionContext, 54 ScriptState* scriptState,
54 StorageUsageCallback* successCallback, 55 StorageUsageCallback* successCallback,
55 StorageErrorCallback* errorCallback) { 56 StorageErrorCallback* errorCallback) {
57 ExecutionContext* executionContext = scriptState->getExecutionContext();
56 ASSERT(executionContext); 58 ASSERT(executionContext);
57 59
58 WebStorageQuotaType storageType = static_cast<WebStorageQuotaType>(m_type); 60 WebStorageQuotaType storageType = static_cast<WebStorageQuotaType>(m_type);
59 if (storageType != WebStorageQuotaTypeTemporary && 61 if (storageType != WebStorageQuotaTypeTemporary &&
60 storageType != WebStorageQuotaTypePersistent) { 62 storageType != WebStorageQuotaTypePersistent) {
61 // Unknown storage type is requested. 63 // Unknown storage type is requested.
62 executionContext->postTask(TaskType::MiscPlatformAPI, BLINK_FROM_HERE, 64 executionContext->postTask(TaskType::MiscPlatformAPI, BLINK_FROM_HERE,
63 StorageErrorCallback::createSameThreadTask( 65 StorageErrorCallback::createSameThreadTask(
64 errorCallback, NotSupportedError)); 66 errorCallback, NotSupportedError));
65 return; 67 return;
66 } 68 }
67 69
68 SecurityOrigin* securityOrigin = executionContext->getSecurityOrigin(); 70 SecurityOrigin* securityOrigin = executionContext->getSecurityOrigin();
69 if (securityOrigin->isUnique()) { 71 if (securityOrigin->isUnique()) {
70 executionContext->postTask(TaskType::MiscPlatformAPI, BLINK_FROM_HERE, 72 executionContext->postTask(TaskType::MiscPlatformAPI, BLINK_FROM_HERE,
71 StorageErrorCallback::createSameThreadTask( 73 StorageErrorCallback::createSameThreadTask(
72 errorCallback, NotSupportedError)); 74 errorCallback, NotSupportedError));
73 return; 75 return;
74 } 76 }
75 77
76 KURL storagePartition = KURL(KURL(), securityOrigin->toString()); 78 KURL storagePartition = KURL(KURL(), securityOrigin->toString());
77 StorageQuotaCallbacks* callbacks = 79 StorageQuotaCallbacks* callbacks =
78 DeprecatedStorageQuotaCallbacksImpl::create(successCallback, 80 DeprecatedStorageQuotaCallbacksImpl::create(successCallback,
79 errorCallback); 81 errorCallback);
80 Platform::current()->queryStorageUsageAndQuota(storagePartition, storageType, 82 Platform::current()->queryStorageUsageAndQuota(storagePartition, storageType,
81 callbacks); 83 callbacks);
82 } 84 }
83 85
84 void DeprecatedStorageQuota::requestQuota(ExecutionContext* executionContext, 86 void DeprecatedStorageQuota::requestQuota(ScriptState* scriptState,
85 unsigned long long newQuotaInBytes, 87 unsigned long long newQuotaInBytes,
86 StorageQuotaCallback* successCallback, 88 StorageQuotaCallback* successCallback,
87 StorageErrorCallback* errorCallback) { 89 StorageErrorCallback* errorCallback) {
90 ExecutionContext* executionContext = scriptState->getExecutionContext();
88 ASSERT(executionContext); 91 ASSERT(executionContext);
89 92
90 WebStorageQuotaType storageType = static_cast<WebStorageQuotaType>(m_type); 93 WebStorageQuotaType storageType = static_cast<WebStorageQuotaType>(m_type);
91 if (storageType != WebStorageQuotaTypeTemporary && 94 if (storageType != WebStorageQuotaTypeTemporary &&
92 storageType != WebStorageQuotaTypePersistent) { 95 storageType != WebStorageQuotaTypePersistent) {
93 // Unknown storage type is requested. 96 // Unknown storage type is requested.
94 executionContext->postTask(TaskType::MiscPlatformAPI, BLINK_FROM_HERE, 97 executionContext->postTask(TaskType::MiscPlatformAPI, BLINK_FROM_HERE,
95 StorageErrorCallback::createSameThreadTask( 98 StorageErrorCallback::createSameThreadTask(
96 errorCallback, NotSupportedError)); 99 errorCallback, NotSupportedError));
97 return; 100 return;
98 } 101 }
99 102
100 StorageQuotaClient* client = StorageQuotaClient::from(executionContext); 103 StorageQuotaClient* client = StorageQuotaClient::from(executionContext);
101 if (!client) { 104 if (!client) {
102 executionContext->postTask(TaskType::MiscPlatformAPI, BLINK_FROM_HERE, 105 executionContext->postTask(TaskType::MiscPlatformAPI, BLINK_FROM_HERE,
103 StorageErrorCallback::createSameThreadTask( 106 StorageErrorCallback::createSameThreadTask(
104 errorCallback, NotSupportedError)); 107 errorCallback, NotSupportedError));
105 return; 108 return;
106 } 109 }
107 110
108 client->requestQuota(executionContext, storageType, newQuotaInBytes, 111 client->requestQuota(scriptState, storageType, newQuotaInBytes,
109 successCallback, errorCallback); 112 successCallback, errorCallback);
110 } 113 }
111 114
112 } // namespace blink 115 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698