#pragma once
#include <wtf/Markable.h>
#include <wtf/Threading.h>
#include <wtf/WallTime.h>
#include <wtf/text/WTFString.h>
namespace WebCore {
class DatabaseDetails {
public:
DatabaseDetails() = default;
DatabaseDetails(const DatabaseDetails& details)
: m_name(details.m_name)
, m_displayName(details.m_displayName)
, m_expectedUsage(details.m_expectedUsage)
, m_currentUsage(details.m_currentUsage)
, m_creationTime(details.m_creationTime)
, m_modificationTime(details.m_modificationTime)
#ifndef NDEBUG
, m_thread(details.m_thread.copyRef())
#endif
{
}
DatabaseDetails& operator=(const DatabaseDetails& details)
{
m_name = details.m_name;
m_displayName = details.m_displayName;
m_expectedUsage = details.m_expectedUsage;
m_currentUsage = details.m_currentUsage;
m_creationTime = details.m_creationTime;
m_modificationTime = details.m_modificationTime;
#ifndef NDEBUG
m_thread = details.m_thread.copyRef();
#endif
return *this;
}
DatabaseDetails(const String& databaseName, const String& displayName, unsigned long long expectedUsage, unsigned long long currentUsage, Optional<WallTime> creationTime, Optional<WallTime> modificationTime)
: m_name(databaseName)
, m_displayName(displayName)
, m_expectedUsage(expectedUsage)
, m_currentUsage(currentUsage)
, m_creationTime(creationTime)
, m_modificationTime(modificationTime)
{
}
const String& name() const { return m_name; }
const String& displayName() const { return m_displayName; }
uint64_t expectedUsage() const { return m_expectedUsage; }
uint64_t currentUsage() const { return m_currentUsage; }
Optional<WallTime> creationTime() const { return m_creationTime; }
Optional<WallTime> modificationTime() const { return m_modificationTime; }
#ifndef NDEBUG
Thread& thread() const { return m_thread.get(); }
#endif
private:
String m_name;
String m_displayName;
uint64_t m_expectedUsage { 0 };
uint64_t m_currentUsage { 0 };
Markable<WallTime, WallTime::MarkableTraits> m_creationTime;
Markable<WallTime, WallTime::MarkableTraits> m_modificationTime;
#ifndef NDEBUG
Ref<Thread> m_thread { Thread::current() };
#endif
};
}