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