Пример #1
0
unsigned long long OriginUsageRecord::diskUsage()
{
    // Use the last cached usage value if we have it
    if (m_diskUsage != unknownDiskUsage())
        return m_diskUsage;
    
    // stat() for the sizes known to be dirty
    HashSet<String>::iterator iUnknown = m_unknownSet.begin();
    HashSet<String>::iterator endUnknown = m_unknownSet.end();
    for (; iUnknown != endUnknown; ++iUnknown) {
        String path = m_databaseMap.get(*iUnknown).filename;
        ASSERT(!path.isEmpty());
                
        long long size;
        if (getFileSize(path, size))
            m_databaseMap.set(*iUnknown, DatabaseEntry(path, size));
        else {
            // When we can't determine the file size, we'll just have to assume the file is missing/inaccessible
            m_databaseMap.set(*iUnknown, DatabaseEntry(path, 0));
        }
    }
    m_unknownSet.clear();
    
    // Recalculate the cached usage value
    HashMap<String, DatabaseEntry>::iterator iDatabase = m_databaseMap.begin();
    HashMap<String, DatabaseEntry>::iterator endDatabase = m_databaseMap.end();
    
    m_diskUsage = 0;
    for (; iDatabase != endDatabase; ++iDatabase) {
        m_diskUsage += iDatabase->second.size;
    }

    return m_diskUsage;
}
Пример #2
0
unsigned long long OriginUsageRecord::diskUsage()
{
    // Use the last cached usage value if we have it.
    if (m_cachedDiskUsageIsValid)
        return m_cachedDiskUsage;

    // stat() for the sizes known to be dirty.
    HashSet<String>::iterator iUnknown = m_unknownSet.begin();
    HashSet<String>::iterator endUnknown = m_unknownSet.end();
    for (; iUnknown != endUnknown; ++iUnknown) {
        const String& path = m_databaseMap.get(*iUnknown).filename;
        ASSERT(!path.isEmpty());

        // When we can't determine the file size, we'll just have to assume the file is missing/inaccessible.
        long long size = SQLiteFileSystem::getDatabaseFileSize(path);
        m_databaseMap.set(*iUnknown, DatabaseEntry(path, size));
    }
    m_unknownSet.clear();

    // Recalculate the cached usage value.
    m_cachedDiskUsage = 0;
    HashMap<String, DatabaseEntry>::iterator iDatabase = m_databaseMap.begin();
    HashMap<String, DatabaseEntry>::iterator endDatabase = m_databaseMap.end();
    for (; iDatabase != endDatabase; ++iDatabase)
        m_cachedDiskUsage += iDatabase->second.size;

    m_cachedDiskUsageIsValid = true;
    return m_cachedDiskUsage;
}
Пример #3
0
void OriginUsageRecord::addDatabase(const String& identifier, const String& fullPath)
{
    ASSERT(!m_databaseMap.contains(identifier));
    
    m_databaseMap.set(identifier, DatabaseEntry(fullPath, unknownDiskUsage()));
    m_unknownSet.add(identifier);
     
    m_diskUsage = unknownDiskUsage();
}
Пример #4
0
void OriginUsageRecord::addDatabase(const String& identifier, const String& fullPath)
{
    ASSERT(!m_databaseMap.contains(identifier));
    ASSERT_ARG(identifier, identifier.impl()->hasOneRef() || identifier.isEmpty());
    ASSERT_ARG(fullPath, fullPath.impl()->hasOneRef() || fullPath.isEmpty());

    m_databaseMap.set(identifier, DatabaseEntry(fullPath));
    m_unknownSet.add(identifier);

    m_cachedDiskUsageIsValid = false;
}