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

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

Issue 2583013002: Specify TaskType of posted Task explicitly in Quota API (13) (Closed)
Patch Set: rebase Created 3 years, 11 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 14 matching lines...) Expand all
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 "core/dom/ExceptionCode.h" 33 #include "core/dom/ExceptionCode.h"
34 #include "core/dom/ExecutionContext.h" 34 #include "core/dom/ExecutionContext.h"
35 #include "core/dom/TaskRunnerHelper.h"
35 #include "modules/quota/DeprecatedStorageQuotaCallbacksImpl.h" 36 #include "modules/quota/DeprecatedStorageQuotaCallbacksImpl.h"
36 #include "modules/quota/StorageErrorCallback.h" 37 #include "modules/quota/StorageErrorCallback.h"
37 #include "modules/quota/StorageQuotaClient.h" 38 #include "modules/quota/StorageQuotaClient.h"
38 #include "modules/quota/StorageUsageCallback.h" 39 #include "modules/quota/StorageUsageCallback.h"
39 #include "platform/StorageQuotaCallbacks.h" 40 #include "platform/StorageQuotaCallbacks.h"
40 #include "platform/weborigin/KURL.h" 41 #include "platform/weborigin/KURL.h"
41 #include "platform/weborigin/SecurityOrigin.h" 42 #include "platform/weborigin/SecurityOrigin.h"
42 #include "public/platform/Platform.h" 43 #include "public/platform/Platform.h"
43 #include "public/platform/WebStorageQuotaCallbacks.h" 44 #include "public/platform/WebStorageQuotaCallbacks.h"
44 #include "public/platform/WebStorageQuotaType.h" 45 #include "public/platform/WebStorageQuotaType.h"
45 #include "public/platform/WebTraceLocation.h" 46 #include "public/platform/WebTraceLocation.h"
46 47
47 namespace blink { 48 namespace blink {
48 49
49 DeprecatedStorageQuota::DeprecatedStorageQuota(Type type) : m_type(type) {} 50 DeprecatedStorageQuota::DeprecatedStorageQuota(Type type) : m_type(type) {}
50 51
51 void DeprecatedStorageQuota::queryUsageAndQuota( 52 void DeprecatedStorageQuota::queryUsageAndQuota(
52 ExecutionContext* executionContext, 53 ExecutionContext* executionContext,
53 StorageUsageCallback* successCallback, 54 StorageUsageCallback* successCallback,
54 StorageErrorCallback* errorCallback) { 55 StorageErrorCallback* errorCallback) {
55 ASSERT(executionContext); 56 ASSERT(executionContext);
56 57
57 WebStorageQuotaType storageType = static_cast<WebStorageQuotaType>(m_type); 58 WebStorageQuotaType storageType = static_cast<WebStorageQuotaType>(m_type);
58 if (storageType != WebStorageQuotaTypeTemporary && 59 if (storageType != WebStorageQuotaTypeTemporary &&
59 storageType != WebStorageQuotaTypePersistent) { 60 storageType != WebStorageQuotaTypePersistent) {
60 // Unknown storage type is requested. 61 // Unknown storage type is requested.
61 executionContext->postTask(BLINK_FROM_HERE, 62 executionContext->postTask(TaskType::MiscPlatformAPI, BLINK_FROM_HERE,
62 StorageErrorCallback::createSameThreadTask( 63 StorageErrorCallback::createSameThreadTask(
63 errorCallback, NotSupportedError)); 64 errorCallback, NotSupportedError));
64 return; 65 return;
65 } 66 }
66 67
67 SecurityOrigin* securityOrigin = executionContext->getSecurityOrigin(); 68 SecurityOrigin* securityOrigin = executionContext->getSecurityOrigin();
68 if (securityOrigin->isUnique()) { 69 if (securityOrigin->isUnique()) {
69 executionContext->postTask(BLINK_FROM_HERE, 70 executionContext->postTask(TaskType::MiscPlatformAPI, BLINK_FROM_HERE,
70 StorageErrorCallback::createSameThreadTask( 71 StorageErrorCallback::createSameThreadTask(
71 errorCallback, NotSupportedError)); 72 errorCallback, NotSupportedError));
72 return; 73 return;
73 } 74 }
74 75
75 KURL storagePartition = KURL(KURL(), securityOrigin->toString()); 76 KURL storagePartition = KURL(KURL(), securityOrigin->toString());
76 StorageQuotaCallbacks* callbacks = 77 StorageQuotaCallbacks* callbacks =
77 DeprecatedStorageQuotaCallbacksImpl::create(successCallback, 78 DeprecatedStorageQuotaCallbacksImpl::create(successCallback,
78 errorCallback); 79 errorCallback);
79 Platform::current()->queryStorageUsageAndQuota(storagePartition, storageType, 80 Platform::current()->queryStorageUsageAndQuota(storagePartition, storageType,
80 callbacks); 81 callbacks);
81 } 82 }
82 83
83 void DeprecatedStorageQuota::requestQuota(ExecutionContext* executionContext, 84 void DeprecatedStorageQuota::requestQuota(ExecutionContext* executionContext,
84 unsigned long long newQuotaInBytes, 85 unsigned long long newQuotaInBytes,
85 StorageQuotaCallback* successCallback, 86 StorageQuotaCallback* successCallback,
86 StorageErrorCallback* errorCallback) { 87 StorageErrorCallback* errorCallback) {
87 ASSERT(executionContext); 88 ASSERT(executionContext);
88 89
89 WebStorageQuotaType storageType = static_cast<WebStorageQuotaType>(m_type); 90 WebStorageQuotaType storageType = static_cast<WebStorageQuotaType>(m_type);
90 if (storageType != WebStorageQuotaTypeTemporary && 91 if (storageType != WebStorageQuotaTypeTemporary &&
91 storageType != WebStorageQuotaTypePersistent) { 92 storageType != WebStorageQuotaTypePersistent) {
92 // Unknown storage type is requested. 93 // Unknown storage type is requested.
93 executionContext->postTask(BLINK_FROM_HERE, 94 executionContext->postTask(TaskType::MiscPlatformAPI, BLINK_FROM_HERE,
94 StorageErrorCallback::createSameThreadTask( 95 StorageErrorCallback::createSameThreadTask(
95 errorCallback, NotSupportedError)); 96 errorCallback, NotSupportedError));
96 return; 97 return;
97 } 98 }
98 99
99 StorageQuotaClient* client = StorageQuotaClient::from(executionContext); 100 StorageQuotaClient* client = StorageQuotaClient::from(executionContext);
100 if (!client) { 101 if (!client) {
101 executionContext->postTask(BLINK_FROM_HERE, 102 executionContext->postTask(TaskType::MiscPlatformAPI, BLINK_FROM_HERE,
102 StorageErrorCallback::createSameThreadTask( 103 StorageErrorCallback::createSameThreadTask(
103 errorCallback, NotSupportedError)); 104 errorCallback, NotSupportedError));
104 return; 105 return;
105 } 106 }
106 107
107 client->requestQuota(executionContext, storageType, newQuotaInBytes, 108 client->requestQuota(executionContext, storageType, newQuotaInBytes,
108 successCallback, errorCallback); 109 successCallback, errorCallback);
109 } 110 }
110 111
111 } // namespace blink 112 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698