| 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 20 matching lines...) Expand all Loading... |
| 31 #include "config.h" | 31 #include "config.h" |
| 32 | 32 |
| 33 #include "modules/quota/DeprecatedStorageInfo.h" | 33 #include "modules/quota/DeprecatedStorageInfo.h" |
| 34 | 34 |
| 35 #include "core/dom/ExceptionCode.h" | 35 #include "core/dom/ExceptionCode.h" |
| 36 #include "core/dom/ExecutionContext.h" | 36 #include "core/dom/ExecutionContext.h" |
| 37 #include "modules/quota/DeprecatedStorageQuota.h" | 37 #include "modules/quota/DeprecatedStorageQuota.h" |
| 38 #include "modules/quota/StorageErrorCallback.h" | 38 #include "modules/quota/StorageErrorCallback.h" |
| 39 #include "modules/quota/StorageQuotaCallback.h" | 39 #include "modules/quota/StorageQuotaCallback.h" |
| 40 #include "modules/quota/StorageUsageCallback.h" | 40 #include "modules/quota/StorageUsageCallback.h" |
| 41 #include "public/platform/WebTraceLocation.h" | |
| 42 | 41 |
| 43 namespace blink { | 42 namespace blink { |
| 44 | 43 |
| 45 DeprecatedStorageInfo::DeprecatedStorageInfo() | 44 DeprecatedStorageInfo::DeprecatedStorageInfo() |
| 46 { | 45 { |
| 47 } | 46 } |
| 48 | 47 |
| 49 void DeprecatedStorageInfo::queryUsageAndQuota(ExecutionContext* executionContex
t, int storageType, StorageUsageCallback* successCallback, StorageErrorCallback*
errorCallback) | 48 void DeprecatedStorageInfo::queryUsageAndQuota(ExecutionContext* executionContex
t, int storageType, StorageUsageCallback* successCallback, StorageErrorCallback*
errorCallback) |
| 50 { | 49 { |
| 51 // Dispatching the request to DeprecatedStorageQuota, as this interface is d
eprecated in favor of DeprecatedStorageQuota. | 50 // Dispatching the request to DeprecatedStorageQuota, as this interface is d
eprecated in favor of DeprecatedStorageQuota. |
| 52 DeprecatedStorageQuota* storageQuota = getStorageQuota(storageType); | 51 DeprecatedStorageQuota* storageQuota = getStorageQuota(storageType); |
| 53 if (!storageQuota) { | 52 if (!storageQuota) { |
| 54 // Unknown storage type is requested. | 53 // Unknown storage type is requested. |
| 55 executionContext->postTask(FROM_HERE, StorageErrorCallback::CallbackTask
::create(errorCallback, NotSupportedError)); | 54 executionContext->postTask(StorageErrorCallback::CallbackTask::create(er
rorCallback, NotSupportedError)); |
| 56 return; | 55 return; |
| 57 } | 56 } |
| 58 storageQuota->queryUsageAndQuota(executionContext, successCallback, errorCal
lback); | 57 storageQuota->queryUsageAndQuota(executionContext, successCallback, errorCal
lback); |
| 59 } | 58 } |
| 60 | 59 |
| 61 void DeprecatedStorageInfo::requestQuota(ExecutionContext* executionContext, int
storageType, unsigned long long newQuotaInBytes, StorageQuotaCallback* successC
allback, StorageErrorCallback* errorCallback) | 60 void DeprecatedStorageInfo::requestQuota(ExecutionContext* executionContext, int
storageType, unsigned long long newQuotaInBytes, StorageQuotaCallback* successC
allback, StorageErrorCallback* errorCallback) |
| 62 { | 61 { |
| 63 // Dispatching the request to DeprecatedStorageQuota, as this interface is d
eprecated in favor of DeprecatedStorageQuota. | 62 // Dispatching the request to DeprecatedStorageQuota, as this interface is d
eprecated in favor of DeprecatedStorageQuota. |
| 64 DeprecatedStorageQuota* storageQuota = getStorageQuota(storageType); | 63 DeprecatedStorageQuota* storageQuota = getStorageQuota(storageType); |
| 65 if (!storageQuota) { | 64 if (!storageQuota) { |
| 66 // Unknown storage type is requested. | 65 // Unknown storage type is requested. |
| 67 executionContext->postTask(FROM_HERE, StorageErrorCallback::CallbackTask
::create(errorCallback, NotSupportedError)); | 66 executionContext->postTask(StorageErrorCallback::CallbackTask::create(er
rorCallback, NotSupportedError)); |
| 68 return; | 67 return; |
| 69 } | 68 } |
| 70 storageQuota->requestQuota(executionContext, newQuotaInBytes, successCallbac
k, errorCallback); | 69 storageQuota->requestQuota(executionContext, newQuotaInBytes, successCallbac
k, errorCallback); |
| 71 } | 70 } |
| 72 | 71 |
| 73 DeprecatedStorageQuota* DeprecatedStorageInfo::getStorageQuota(int storageType) | 72 DeprecatedStorageQuota* DeprecatedStorageInfo::getStorageQuota(int storageType) |
| 74 { | 73 { |
| 75 switch (storageType) { | 74 switch (storageType) { |
| 76 case TEMPORARY: | 75 case TEMPORARY: |
| 77 if (!m_temporaryStorage) | 76 if (!m_temporaryStorage) |
| 78 m_temporaryStorage = DeprecatedStorageQuota::create(DeprecatedStorag
eQuota::Temporary); | 77 m_temporaryStorage = DeprecatedStorageQuota::create(DeprecatedStorag
eQuota::Temporary); |
| 79 return m_temporaryStorage.get(); | 78 return m_temporaryStorage.get(); |
| 80 case PERSISTENT: | 79 case PERSISTENT: |
| 81 if (!m_persistentStorage) | 80 if (!m_persistentStorage) |
| 82 m_persistentStorage = DeprecatedStorageQuota::create(DeprecatedStora
geQuota::Persistent); | 81 m_persistentStorage = DeprecatedStorageQuota::create(DeprecatedStora
geQuota::Persistent); |
| 83 return m_persistentStorage.get(); | 82 return m_persistentStorage.get(); |
| 84 } | 83 } |
| 85 return 0; | 84 return 0; |
| 86 } | 85 } |
| 87 | 86 |
| 88 DEFINE_TRACE(DeprecatedStorageInfo) | 87 DEFINE_TRACE(DeprecatedStorageInfo) |
| 89 { | 88 { |
| 90 visitor->trace(m_temporaryStorage); | 89 visitor->trace(m_temporaryStorage); |
| 91 visitor->trace(m_persistentStorage); | 90 visitor->trace(m_persistentStorage); |
| 92 } | 91 } |
| 93 | 92 |
| 94 } // namespace blink | 93 } // namespace blink |
| OLD | NEW |