diff options
Diffstat (limited to 'src/3rdparty/webkit/WebCore/loader/appcache/ApplicationCacheResource.cpp')
-rw-r--r-- | src/3rdparty/webkit/WebCore/loader/appcache/ApplicationCacheResource.cpp | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/3rdparty/webkit/WebCore/loader/appcache/ApplicationCacheResource.cpp b/src/3rdparty/webkit/WebCore/loader/appcache/ApplicationCacheResource.cpp index 4beb76a93..03c5c8359 100644 --- a/src/3rdparty/webkit/WebCore/loader/appcache/ApplicationCacheResource.cpp +++ b/src/3rdparty/webkit/WebCore/loader/appcache/ApplicationCacheResource.cpp @@ -35,6 +35,7 @@ ApplicationCacheResource::ApplicationCacheResource(const KURL& url, const Resour : SubstituteResource(url, response, data) , m_type(type) , m_storageID(0) + , m_estimatedSizeInStorage(0) { } @@ -44,6 +45,28 @@ void ApplicationCacheResource::addType(unsigned type) m_type |= type; } +int64_t ApplicationCacheResource::estimatedSizeInStorage() +{ + if (m_estimatedSizeInStorage) + return m_estimatedSizeInStorage; + + if (data()) + m_estimatedSizeInStorage = data()->size(); + + HTTPHeaderMap::const_iterator end = response().httpHeaderFields().end(); + for (HTTPHeaderMap::const_iterator it = response().httpHeaderFields().begin(); it != end; ++it) + m_estimatedSizeInStorage += (it->first.length() + it->second.length() + 2) * sizeof(UChar); + + m_estimatedSizeInStorage += url().string().length() * sizeof(UChar); + m_estimatedSizeInStorage += sizeof(int); // response().m_httpStatusCode + m_estimatedSizeInStorage += response().url().string().length() * sizeof(UChar); + m_estimatedSizeInStorage += sizeof(unsigned); // dataId + m_estimatedSizeInStorage += response().mimeType().length() * sizeof(UChar); + m_estimatedSizeInStorage += response().textEncodingName().length() * sizeof(UChar); + + return m_estimatedSizeInStorage; +} + #ifndef NDEBUG void ApplicationCacheResource::dumpType(unsigned type) { |