This source file includes following definitions.
- queryUsageAndQuota
- requestQuota
#include "config.h"
#include "modules/quota/DeprecatedStorageQuota.h"
#include "core/dom/ExceptionCode.h"
#include "core/dom/ExecutionContext.h"
#include "modules/quota/DeprecatedStorageQuotaCallbacksImpl.h"
#include "modules/quota/StorageErrorCallback.h"
#include "modules/quota/StorageQuotaClient.h"
#include "modules/quota/StorageUsageCallback.h"
#include "platform/StorageQuotaCallbacks.h"
#include "platform/weborigin/KURL.h"
#include "platform/weborigin/SecurityOrigin.h"
#include "public/platform/Platform.h"
#include "public/platform/WebStorageQuotaCallbacks.h"
#include "public/platform/WebStorageQuotaType.h"
namespace WebCore {
DeprecatedStorageQuota::DeprecatedStorageQuota(Type type)
: m_type(type)
{
ScriptWrappable::init(this);
}
void DeprecatedStorageQuota::queryUsageAndQuota(ExecutionContext* executionContext, PassOwnPtr<StorageUsageCallback> successCallback, PassOwnPtr<StorageErrorCallback> errorCallback)
{
ASSERT(executionContext);
blink::WebStorageQuotaType storageType = static_cast<blink::WebStorageQuotaType>(m_type);
if (storageType != blink::WebStorageQuotaTypeTemporary && storageType != blink::WebStorageQuotaTypePersistent) {
executionContext->postTask(StorageErrorCallback::CallbackTask::create(errorCallback, NotSupportedError));
return;
}
SecurityOrigin* securityOrigin = executionContext->securityOrigin();
if (securityOrigin->isUnique()) {
executionContext->postTask(StorageErrorCallback::CallbackTask::create(errorCallback, NotSupportedError));
return;
}
KURL storagePartition = KURL(KURL(), securityOrigin->toString());
OwnPtr<StorageQuotaCallbacks> callbacks = DeprecatedStorageQuotaCallbacksImpl::create(successCallback, errorCallback);
blink::Platform::current()->queryStorageUsageAndQuota(storagePartition, storageType, callbacks.release());
}
void DeprecatedStorageQuota::requestQuota(ExecutionContext* executionContext, unsigned long long newQuotaInBytes, PassOwnPtr<StorageQuotaCallback> successCallback, PassOwnPtr<StorageErrorCallback> errorCallback)
{
ASSERT(executionContext);
blink::WebStorageQuotaType storageType = static_cast<blink::WebStorageQuotaType>(m_type);
if (storageType != blink::WebStorageQuotaTypeTemporary && storageType != blink::WebStorageQuotaTypePersistent) {
executionContext->postTask(StorageErrorCallback::CallbackTask::create(errorCallback, NotSupportedError));
return;
}
StorageQuotaClient* client = StorageQuotaClient::from(executionContext);
if (!client) {
executionContext->postTask(StorageErrorCallback::CallbackTask::create(errorCallback, NotSupportedError));
return;
}
client->requestQuota(executionContext, storageType, newQuotaInBytes, successCallback, errorCallback);
}
DeprecatedStorageQuota::~DeprecatedStorageQuota()
{
}
}