| OLD | NEW |
| 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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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, executionContext) |
| 66 ->postTask(BLINK_FROM_HERE, StorageErrorCallback::createSameThreadTask( | 66 ->postTask(BLINK_FROM_HERE, |
| 67 errorCallback, NotSupportedError)); | 67 StorageErrorCallback::createSameThreadTask( |
| 68 errorCallback, NotSupportedError)); |
| 68 return; | 69 return; |
| 69 } | 70 } |
| 70 | 71 |
| 71 SecurityOrigin* securityOrigin = executionContext->getSecurityOrigin(); | 72 SecurityOrigin* securityOrigin = executionContext->getSecurityOrigin(); |
| 72 if (securityOrigin->isUnique()) { | 73 if (securityOrigin->isUnique()) { |
| 73 TaskRunnerHelper::get(TaskType::MiscPlatformAPI, executionContext) | 74 TaskRunnerHelper::get(TaskType::MiscPlatformAPI, executionContext) |
| 74 ->postTask(BLINK_FROM_HERE, StorageErrorCallback::createSameThreadTask( | 75 ->postTask(BLINK_FROM_HERE, |
| 75 errorCallback, NotSupportedError)); | 76 StorageErrorCallback::createSameThreadTask( |
| 77 errorCallback, NotSupportedError)); |
| 76 return; | 78 return; |
| 77 } | 79 } |
| 78 | 80 |
| 79 KURL storagePartition = KURL(KURL(), securityOrigin->toString()); | 81 KURL storagePartition = KURL(KURL(), securityOrigin->toString()); |
| 80 StorageQuotaCallbacks* callbacks = | 82 StorageQuotaCallbacks* callbacks = |
| 81 DeprecatedStorageQuotaCallbacksImpl::create(successCallback, | 83 DeprecatedStorageQuotaCallbacksImpl::create(successCallback, |
| 82 errorCallback); | 84 errorCallback); |
| 83 Platform::current()->queryStorageUsageAndQuota(storagePartition, storageType, | 85 Platform::current()->queryStorageUsageAndQuota(storagePartition, storageType, |
| 84 callbacks); | 86 callbacks); |
| 85 } | 87 } |
| 86 | 88 |
| 87 void DeprecatedStorageQuota::requestQuota(ScriptState* scriptState, | 89 void DeprecatedStorageQuota::requestQuota(ScriptState* scriptState, |
| 88 unsigned long long newQuotaInBytes, | 90 unsigned long long newQuotaInBytes, |
| 89 StorageQuotaCallback* successCallback, | 91 StorageQuotaCallback* successCallback, |
| 90 StorageErrorCallback* errorCallback) { | 92 StorageErrorCallback* errorCallback) { |
| 91 ExecutionContext* executionContext = scriptState->getExecutionContext(); | 93 ExecutionContext* executionContext = scriptState->getExecutionContext(); |
| 92 ASSERT(executionContext); | 94 ASSERT(executionContext); |
| 93 | 95 |
| 94 WebStorageQuotaType storageType = static_cast<WebStorageQuotaType>(m_type); | 96 WebStorageQuotaType storageType = static_cast<WebStorageQuotaType>(m_type); |
| 95 if (storageType != WebStorageQuotaTypeTemporary && | 97 if (storageType != WebStorageQuotaTypeTemporary && |
| 96 storageType != WebStorageQuotaTypePersistent) { | 98 storageType != WebStorageQuotaTypePersistent) { |
| 97 // Unknown storage type is requested. | 99 // Unknown storage type is requested. |
| 98 TaskRunnerHelper::get(TaskType::MiscPlatformAPI, executionContext) | 100 TaskRunnerHelper::get(TaskType::MiscPlatformAPI, executionContext) |
| 99 ->postTask(BLINK_FROM_HERE, StorageErrorCallback::createSameThreadTask( | 101 ->postTask(BLINK_FROM_HERE, |
| 100 errorCallback, NotSupportedError)); | 102 StorageErrorCallback::createSameThreadTask( |
| 103 errorCallback, NotSupportedError)); |
| 101 return; | 104 return; |
| 102 } | 105 } |
| 103 | 106 |
| 104 StorageQuotaClient* client = StorageQuotaClient::from(executionContext); | 107 StorageQuotaClient* client = StorageQuotaClient::from(executionContext); |
| 105 if (!client) { | 108 if (!client) { |
| 106 TaskRunnerHelper::get(TaskType::MiscPlatformAPI, executionContext) | 109 TaskRunnerHelper::get(TaskType::MiscPlatformAPI, executionContext) |
| 107 ->postTask(BLINK_FROM_HERE, StorageErrorCallback::createSameThreadTask( | 110 ->postTask(BLINK_FROM_HERE, |
| 108 errorCallback, NotSupportedError)); | 111 StorageErrorCallback::createSameThreadTask( |
| 112 errorCallback, NotSupportedError)); |
| 109 return; | 113 return; |
| 110 } | 114 } |
| 111 | 115 |
| 112 client->requestQuota(scriptState, storageType, newQuotaInBytes, | 116 client->requestQuota(scriptState, storageType, newQuotaInBytes, |
| 113 successCallback, errorCallback); | 117 successCallback, errorCallback); |
| 114 } | 118 } |
| 115 | 119 |
| 116 } // namespace blink | 120 } // namespace blink |
| OLD | NEW |