| 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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 #include "public/platform/WebStorageQuotaCallbacks.h" | 44 #include "public/platform/WebStorageQuotaCallbacks.h" |
| 45 #include "public/platform/WebStorageQuotaType.h" | 45 #include "public/platform/WebStorageQuotaType.h" |
| 46 | 46 |
| 47 namespace blink { | 47 namespace blink { |
| 48 | 48 |
| 49 DeprecatedStorageQuota::DeprecatedStorageQuota(Type type) | 49 DeprecatedStorageQuota::DeprecatedStorageQuota(Type type) |
| 50 : m_type(type) | 50 : m_type(type) |
| 51 { | 51 { |
| 52 } | 52 } |
| 53 | 53 |
| 54 void DeprecatedStorageQuota::queryUsageAndQuota(ExecutionContext* executionConte
xt, PassOwnPtrWillBeRawPtr<StorageUsageCallback> successCallback, PassOwnPtrWill
BeRawPtr<StorageErrorCallback> errorCallback) | 54 void DeprecatedStorageQuota::queryUsageAndQuota(ExecutionContext* executionConte
xt, StorageUsageCallback* successCallback, StorageErrorCallback* errorCallback) |
| 55 { | 55 { |
| 56 ASSERT(executionContext); | 56 ASSERT(executionContext); |
| 57 | 57 |
| 58 WebStorageQuotaType storageType = static_cast<WebStorageQuotaType>(m_type); | 58 WebStorageQuotaType storageType = static_cast<WebStorageQuotaType>(m_type); |
| 59 if (storageType != WebStorageQuotaTypeTemporary && storageType != WebStorage
QuotaTypePersistent) { | 59 if (storageType != WebStorageQuotaTypeTemporary && storageType != WebStorage
QuotaTypePersistent) { |
| 60 // Unknown storage type is requested. | 60 // Unknown storage type is requested. |
| 61 executionContext->postTask(StorageErrorCallback::CallbackTask::create(er
rorCallback, NotSupportedError)); | 61 executionContext->postTask(StorageErrorCallback::CallbackTask::create(er
rorCallback, NotSupportedError)); |
| 62 return; | 62 return; |
| 63 } | 63 } |
| 64 | 64 |
| 65 SecurityOrigin* securityOrigin = executionContext->securityOrigin(); | 65 SecurityOrigin* securityOrigin = executionContext->securityOrigin(); |
| 66 if (securityOrigin->isUnique()) { | 66 if (securityOrigin->isUnique()) { |
| 67 executionContext->postTask(StorageErrorCallback::CallbackTask::create(er
rorCallback, NotSupportedError)); | 67 executionContext->postTask(StorageErrorCallback::CallbackTask::create(er
rorCallback, NotSupportedError)); |
| 68 return; | 68 return; |
| 69 } | 69 } |
| 70 | 70 |
| 71 KURL storagePartition = KURL(KURL(), securityOrigin->toString()); | 71 KURL storagePartition = KURL(KURL(), securityOrigin->toString()); |
| 72 OwnPtrWillBeRawPtr<StorageQuotaCallbacks> callbacks = DeprecatedStorageQuota
CallbacksImpl::create(successCallback, errorCallback); | 72 OwnPtrWillBeRawPtr<StorageQuotaCallbacks> callbacks = DeprecatedStorageQuota
CallbacksImpl::create(successCallback, errorCallback); |
| 73 Platform::current()->queryStorageUsageAndQuota(storagePartition, storageType
, callbacks.release()); | 73 Platform::current()->queryStorageUsageAndQuota(storagePartition, storageType
, callbacks.release()); |
| 74 } | 74 } |
| 75 | 75 |
| 76 void DeprecatedStorageQuota::requestQuota(ExecutionContext* executionContext, un
signed long long newQuotaInBytes, PassOwnPtrWillBeRawPtr<StorageQuotaCallback> s
uccessCallback, PassOwnPtrWillBeRawPtr<StorageErrorCallback> errorCallback) | 76 void DeprecatedStorageQuota::requestQuota(ExecutionContext* executionContext, un
signed long long newQuotaInBytes, StorageQuotaCallback* successCallback, Storage
ErrorCallback* errorCallback) |
| 77 { | 77 { |
| 78 ASSERT(executionContext); | 78 ASSERT(executionContext); |
| 79 | 79 |
| 80 WebStorageQuotaType storageType = static_cast<WebStorageQuotaType>(m_type); | 80 WebStorageQuotaType storageType = static_cast<WebStorageQuotaType>(m_type); |
| 81 if (storageType != WebStorageQuotaTypeTemporary && storageType != WebStorage
QuotaTypePersistent) { | 81 if (storageType != WebStorageQuotaTypeTemporary && storageType != WebStorage
QuotaTypePersistent) { |
| 82 // Unknown storage type is requested. | 82 // Unknown storage type is requested. |
| 83 executionContext->postTask(StorageErrorCallback::CallbackTask::create(er
rorCallback, NotSupportedError)); | 83 executionContext->postTask(StorageErrorCallback::CallbackTask::create(er
rorCallback, NotSupportedError)); |
| 84 return; | 84 return; |
| 85 } | 85 } |
| 86 | 86 |
| 87 StorageQuotaClient* client = StorageQuotaClient::from(executionContext); | 87 StorageQuotaClient* client = StorageQuotaClient::from(executionContext); |
| 88 if (!client) { | 88 if (!client) { |
| 89 executionContext->postTask(StorageErrorCallback::CallbackTask::create(er
rorCallback, NotSupportedError)); | 89 executionContext->postTask(StorageErrorCallback::CallbackTask::create(er
rorCallback, NotSupportedError)); |
| 90 return; | 90 return; |
| 91 } | 91 } |
| 92 | 92 |
| 93 client->requestQuota(executionContext, storageType, newQuotaInBytes, success
Callback, errorCallback); | 93 client->requestQuota(executionContext, storageType, newQuotaInBytes, success
Callback, errorCallback); |
| 94 } | 94 } |
| 95 | 95 |
| 96 } // namespace blink | 96 } // namespace blink |
| OLD | NEW |