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

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

Issue 2701153002: Pass ScriptState directly to TaskRunnerHelper::get() (Closed)
Patch Set: 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
« no previous file with comments | « third_party/WebKit/Source/modules/quota/DeprecatedStorageInfo.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 ScriptState* scriptState, 55 ScriptState* scriptState,
56 StorageUsageCallback* successCallback, 56 StorageUsageCallback* successCallback,
57 StorageErrorCallback* errorCallback) { 57 StorageErrorCallback* errorCallback) {
58 ExecutionContext* executionContext = scriptState->getExecutionContext(); 58 ExecutionContext* executionContext = scriptState->getExecutionContext();
59 ASSERT(executionContext); 59 ASSERT(executionContext);
60 60
61 WebStorageQuotaType storageType = static_cast<WebStorageQuotaType>(m_type); 61 WebStorageQuotaType storageType = static_cast<WebStorageQuotaType>(m_type);
62 if (storageType != WebStorageQuotaTypeTemporary && 62 if (storageType != WebStorageQuotaTypeTemporary &&
63 storageType != WebStorageQuotaTypePersistent) { 63 storageType != WebStorageQuotaTypePersistent) {
64 // Unknown storage type is requested. 64 // Unknown storage type is requested.
65 TaskRunnerHelper::get(TaskType::MiscPlatformAPI, executionContext) 65 TaskRunnerHelper::get(TaskType::MiscPlatformAPI, scriptState)
66 ->postTask(BLINK_FROM_HERE, StorageErrorCallback::createSameThreadTask( 66 ->postTask(BLINK_FROM_HERE, StorageErrorCallback::createSameThreadTask(
67 errorCallback, NotSupportedError)); 67 errorCallback, NotSupportedError));
68 return; 68 return;
69 } 69 }
70 70
71 SecurityOrigin* securityOrigin = executionContext->getSecurityOrigin(); 71 SecurityOrigin* securityOrigin = executionContext->getSecurityOrigin();
72 if (securityOrigin->isUnique()) { 72 if (securityOrigin->isUnique()) {
73 TaskRunnerHelper::get(TaskType::MiscPlatformAPI, executionContext) 73 TaskRunnerHelper::get(TaskType::MiscPlatformAPI, scriptState)
74 ->postTask(BLINK_FROM_HERE, StorageErrorCallback::createSameThreadTask( 74 ->postTask(BLINK_FROM_HERE, StorageErrorCallback::createSameThreadTask(
75 errorCallback, NotSupportedError)); 75 errorCallback, NotSupportedError));
76 return; 76 return;
77 } 77 }
78 78
79 KURL storagePartition = KURL(KURL(), securityOrigin->toString()); 79 KURL storagePartition = KURL(KURL(), securityOrigin->toString());
80 StorageQuotaCallbacks* callbacks = 80 StorageQuotaCallbacks* callbacks =
81 DeprecatedStorageQuotaCallbacksImpl::create(successCallback, 81 DeprecatedStorageQuotaCallbacksImpl::create(successCallback,
82 errorCallback); 82 errorCallback);
83 Platform::current()->queryStorageUsageAndQuota(storagePartition, storageType, 83 Platform::current()->queryStorageUsageAndQuota(storagePartition, storageType,
84 callbacks); 84 callbacks);
85 } 85 }
86 86
87 void DeprecatedStorageQuota::requestQuota(ScriptState* scriptState, 87 void DeprecatedStorageQuota::requestQuota(ScriptState* scriptState,
88 unsigned long long newQuotaInBytes, 88 unsigned long long newQuotaInBytes,
89 StorageQuotaCallback* successCallback, 89 StorageQuotaCallback* successCallback,
90 StorageErrorCallback* errorCallback) { 90 StorageErrorCallback* errorCallback) {
91 ExecutionContext* executionContext = scriptState->getExecutionContext(); 91 ExecutionContext* executionContext = scriptState->getExecutionContext();
92 ASSERT(executionContext); 92 ASSERT(executionContext);
93 93
94 WebStorageQuotaType storageType = static_cast<WebStorageQuotaType>(m_type); 94 WebStorageQuotaType storageType = static_cast<WebStorageQuotaType>(m_type);
95 if (storageType != WebStorageQuotaTypeTemporary && 95 if (storageType != WebStorageQuotaTypeTemporary &&
96 storageType != WebStorageQuotaTypePersistent) { 96 storageType != WebStorageQuotaTypePersistent) {
97 // Unknown storage type is requested. 97 // Unknown storage type is requested.
98 TaskRunnerHelper::get(TaskType::MiscPlatformAPI, executionContext) 98 TaskRunnerHelper::get(TaskType::MiscPlatformAPI, scriptState)
99 ->postTask(BLINK_FROM_HERE, StorageErrorCallback::createSameThreadTask( 99 ->postTask(BLINK_FROM_HERE, StorageErrorCallback::createSameThreadTask(
100 errorCallback, NotSupportedError)); 100 errorCallback, NotSupportedError));
101 return; 101 return;
102 } 102 }
103 103
104 StorageQuotaClient* client = StorageQuotaClient::from(executionContext); 104 StorageQuotaClient* client = StorageQuotaClient::from(executionContext);
105 if (!client) { 105 if (!client) {
106 TaskRunnerHelper::get(TaskType::MiscPlatformAPI, executionContext) 106 TaskRunnerHelper::get(TaskType::MiscPlatformAPI, scriptState)
107 ->postTask(BLINK_FROM_HERE, StorageErrorCallback::createSameThreadTask( 107 ->postTask(BLINK_FROM_HERE, StorageErrorCallback::createSameThreadTask(
108 errorCallback, NotSupportedError)); 108 errorCallback, NotSupportedError));
109 return; 109 return;
110 } 110 }
111 111
112 client->requestQuota(scriptState, storageType, newQuotaInBytes, 112 client->requestQuota(scriptState, storageType, newQuotaInBytes,
113 successCallback, errorCallback); 113 successCallback, errorCallback);
114 } 114 }
115 115
116 } // namespace blink 116 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/modules/quota/DeprecatedStorageInfo.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698