This source file includes following definitions.
- instance
- getDatabaseSizeAndSpaceAvailableToOrigin
- updateDatabaseSize
- updateSpaceAvailableToOrigin
- resetSpaceAvailableToOrigin
#include "config.h"
#include "modules/webdatabase/QuotaTracker.h"
#include "public/platform/Platform.h"
#include "wtf/StdLibExtras.h"
#include "wtf/Threading.h"
namespace WebCore {
QuotaTracker& QuotaTracker::instance()
{
AtomicallyInitializedStatic(QuotaTracker&, tracker = *new QuotaTracker);
return tracker;
}
void QuotaTracker::getDatabaseSizeAndSpaceAvailableToOrigin(
const String& originIdentifier, const String& databaseName,
unsigned long long* databaseSize, unsigned long long* spaceAvailable)
{
{
MutexLocker lockData(m_dataGuard);
ASSERT(m_databaseSizes.contains(originIdentifier));
HashMap<String, SizeMap>::const_iterator it = m_databaseSizes.find(originIdentifier);
ASSERT(it->value.contains(databaseName));
*databaseSize = it->value.get(databaseName);
if (m_spaceAvailableToOrigins.contains(originIdentifier)) {
*spaceAvailable = m_spaceAvailableToOrigins.get(originIdentifier);
return;
}
}
*spaceAvailable = blink::Platform::current()->databaseGetSpaceAvailableForOrigin(originIdentifier);
}
void QuotaTracker::updateDatabaseSize(
const String& originIdentifier, const String& databaseName,
unsigned long long databaseSize)
{
MutexLocker lockData(m_dataGuard);
HashMap<String, SizeMap>::ValueType* it = m_databaseSizes.add(originIdentifier, SizeMap()).storedValue;
it->value.set(databaseName, databaseSize);
}
void QuotaTracker::updateSpaceAvailableToOrigin(const String& originIdentifier, unsigned long long spaceAvailable)
{
MutexLocker lockData(m_dataGuard);
m_spaceAvailableToOrigins.set(originIdentifier, spaceAvailable);
}
void QuotaTracker::resetSpaceAvailableToOrigin(const String& originIdentifier)
{
MutexLocker lockData(m_dataGuard);
m_spaceAvailableToOrigins.remove(originIdentifier);
}
}