зеркало из https://github.com/mozilla/gecko-dev.git
Backed out changeset ce8f00cca9dd (bug 1000338) for XPC-2 test failures
This commit is contained in:
Родитель
acf110f884
Коммит
f61f2f49c9
|
@ -759,11 +759,6 @@ void CacheEntry::InvokeAvailableCallback(Callback const & aCallback)
|
|||
return;
|
||||
}
|
||||
|
||||
if (NS_SUCCEEDED(mFileStatus)) {
|
||||
// Let the last-fetched and fetch-count properties be updated.
|
||||
mFile->OnFetched();
|
||||
}
|
||||
|
||||
if (mIsDoomed || aCallback.mNotWanted) {
|
||||
LOG((" doomed or not wanted, notifying OCEA with NS_ERROR_CACHE_KEY_NOT_FOUND"));
|
||||
aCallback.mCallback->OnCacheEntryAvailable(
|
||||
|
|
|
@ -910,6 +910,27 @@ CacheFile::GetExpirationTime(uint32_t *_retval)
|
|||
return mMetadata->GetExpirationTime(_retval);
|
||||
}
|
||||
|
||||
nsresult
|
||||
CacheFile::SetLastModified(uint32_t aLastModified)
|
||||
{
|
||||
CacheFileAutoLock lock(this);
|
||||
MOZ_ASSERT(mMetadata);
|
||||
NS_ENSURE_TRUE(mMetadata, NS_ERROR_UNEXPECTED);
|
||||
|
||||
PostWriteTimer();
|
||||
return mMetadata->SetLastModified(aLastModified);
|
||||
}
|
||||
|
||||
nsresult
|
||||
CacheFile::GetLastModified(uint32_t *_retval)
|
||||
{
|
||||
CacheFileAutoLock lock(this);
|
||||
MOZ_ASSERT(mMetadata);
|
||||
NS_ENSURE_TRUE(mMetadata, NS_ERROR_UNEXPECTED);
|
||||
|
||||
return mMetadata->GetLastModified(_retval);
|
||||
}
|
||||
|
||||
nsresult
|
||||
CacheFile::SetFrecency(uint32_t aFrecency)
|
||||
{
|
||||
|
@ -935,16 +956,6 @@ CacheFile::GetFrecency(uint32_t *_retval)
|
|||
return mMetadata->GetFrecency(_retval);
|
||||
}
|
||||
|
||||
nsresult
|
||||
CacheFile::GetLastModified(uint32_t *_retval)
|
||||
{
|
||||
CacheFileAutoLock lock(this);
|
||||
MOZ_ASSERT(mMetadata);
|
||||
NS_ENSURE_TRUE(mMetadata, NS_ERROR_UNEXPECTED);
|
||||
|
||||
return mMetadata->GetLastModified(_retval);
|
||||
}
|
||||
|
||||
nsresult
|
||||
CacheFile::GetLastFetched(uint32_t *_retval)
|
||||
{
|
||||
|
@ -965,18 +976,6 @@ CacheFile::GetFetchCount(uint32_t *_retval)
|
|||
return mMetadata->GetFetchCount(_retval);
|
||||
}
|
||||
|
||||
nsresult
|
||||
CacheFile::OnFetched()
|
||||
{
|
||||
CacheFileAutoLock lock(this);
|
||||
MOZ_ASSERT(mMetadata);
|
||||
NS_ENSURE_TRUE(mMetadata, NS_ERROR_UNEXPECTED);
|
||||
|
||||
PostWriteTimer();
|
||||
|
||||
return mMetadata->OnFetched();
|
||||
}
|
||||
|
||||
void
|
||||
CacheFile::Lock()
|
||||
{
|
||||
|
|
|
@ -90,14 +90,12 @@ public:
|
|||
nsresult ElementsSize(uint32_t *_retval);
|
||||
nsresult SetExpirationTime(uint32_t aExpirationTime);
|
||||
nsresult GetExpirationTime(uint32_t *_retval);
|
||||
nsresult SetLastModified(uint32_t aLastModified);
|
||||
nsresult GetLastModified(uint32_t *_retval);
|
||||
nsresult SetFrecency(uint32_t aFrecency);
|
||||
nsresult GetFrecency(uint32_t *_retval);
|
||||
nsresult GetLastModified(uint32_t *_retval);
|
||||
nsresult GetLastFetched(uint32_t *_retval);
|
||||
nsresult GetFetchCount(uint32_t *_retval);
|
||||
// Called by upper layers to indicated the entry has been fetched,
|
||||
// i.e. delivered to the consumer.
|
||||
nsresult OnFetched();
|
||||
|
||||
bool DataSize(int64_t* aSize);
|
||||
void Key(nsACString& aKey) { aKey = mKey; }
|
||||
|
|
|
@ -27,8 +27,6 @@ namespace net {
|
|||
|
||||
#define kCacheEntryVersion 1
|
||||
|
||||
#define NOW_SECONDS() (uint32_t(PR_Now() / PR_USEC_PER_SEC))
|
||||
|
||||
NS_IMPL_ISUPPORTS(CacheFileMetadata, CacheFileIOListener)
|
||||
|
||||
CacheFileMetadata::CacheFileMetadata(CacheFileHandle *aHandle, const nsACString &aKey)
|
||||
|
@ -84,6 +82,7 @@ CacheFileMetadata::CacheFileMetadata(bool aMemoryOnly, const nsACString &aKey)
|
|||
memset(&mMetaHdr, 0, sizeof(CacheFileMetadataHeader));
|
||||
mMetaHdr.mVersion = kCacheEntryVersion;
|
||||
mMetaHdr.mExpirationTime = nsICacheEntry::NO_EXPIRATION_TIME;
|
||||
mMetaHdr.mFetchCount = 1;
|
||||
mKey = aKey;
|
||||
mMetaHdr.mKeySize = mKey.Length();
|
||||
|
||||
|
@ -505,7 +504,7 @@ CacheFileMetadata::SetExpirationTime(uint32_t aExpirationTime)
|
|||
LOG(("CacheFileMetadata::SetExpirationTime() [this=%p, expirationTime=%d]",
|
||||
this, aExpirationTime));
|
||||
|
||||
MarkDirty(false);
|
||||
MarkDirty();
|
||||
mMetaHdr.mExpirationTime = aExpirationTime;
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -517,13 +516,31 @@ CacheFileMetadata::GetExpirationTime(uint32_t *_retval)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
CacheFileMetadata::SetLastModified(uint32_t aLastModified)
|
||||
{
|
||||
LOG(("CacheFileMetadata::SetLastModified() [this=%p, lastModified=%d]",
|
||||
this, aLastModified));
|
||||
|
||||
MarkDirty();
|
||||
mMetaHdr.mLastModified = aLastModified;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
CacheFileMetadata::GetLastModified(uint32_t *_retval)
|
||||
{
|
||||
*_retval = mMetaHdr.mLastModified;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
CacheFileMetadata::SetFrecency(uint32_t aFrecency)
|
||||
{
|
||||
LOG(("CacheFileMetadata::SetFrecency() [this=%p, frecency=%f]",
|
||||
this, (double)aFrecency));
|
||||
|
||||
MarkDirty(false);
|
||||
MarkDirty();
|
||||
mMetaHdr.mFrecency = aFrecency;
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -535,13 +552,6 @@ CacheFileMetadata::GetFrecency(uint32_t *_retval)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
CacheFileMetadata::GetLastModified(uint32_t *_retval)
|
||||
{
|
||||
*_retval = mMetaHdr.mLastModified;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
CacheFileMetadata::GetLastFetched(uint32_t *_retval)
|
||||
{
|
||||
|
@ -556,25 +566,6 @@ CacheFileMetadata::GetFetchCount(uint32_t *_retval)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
CacheFileMetadata::OnFetched()
|
||||
{
|
||||
MarkDirty(false);
|
||||
|
||||
mMetaHdr.mLastFetched = NOW_SECONDS();
|
||||
++mMetaHdr.mFetchCount;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void
|
||||
CacheFileMetadata::MarkDirty(bool aUpdateLastModified)
|
||||
{
|
||||
mIsDirty = true;
|
||||
if (aUpdateLastModified) {
|
||||
mMetaHdr.mLastModified = NOW_SECONDS();
|
||||
}
|
||||
}
|
||||
|
||||
nsresult
|
||||
CacheFileMetadata::OnFileOpened(CacheFileHandle *aHandle, nsresult aResult)
|
||||
{
|
||||
|
@ -730,7 +721,7 @@ CacheFileMetadata::InitEmptyMetadata()
|
|||
}
|
||||
mOffset = 0;
|
||||
mMetaHdr.mVersion = kCacheEntryVersion;
|
||||
mMetaHdr.mFetchCount = 0;
|
||||
mMetaHdr.mFetchCount = 1;
|
||||
mMetaHdr.mExpirationTime = nsICacheEntry::NO_EXPIRATION_TIME;
|
||||
mMetaHdr.mKeySize = mKey.Length();
|
||||
|
||||
|
@ -841,6 +832,7 @@ CacheFileMetadata::ParseMetadata(uint32_t aMetaOffset, uint32_t aBufOffset,
|
|||
}
|
||||
|
||||
|
||||
mMetaHdr.mFetchCount++;
|
||||
MarkDirty();
|
||||
|
||||
mElementsSize = metaposOffset - elementsOffset;
|
||||
|
|
|
@ -138,18 +138,16 @@ public:
|
|||
|
||||
nsresult SetExpirationTime(uint32_t aExpirationTime);
|
||||
nsresult GetExpirationTime(uint32_t *_retval);
|
||||
nsresult SetLastModified(uint32_t aLastModified);
|
||||
nsresult GetLastModified(uint32_t *_retval);
|
||||
nsresult SetFrecency(uint32_t aFrecency);
|
||||
nsresult GetFrecency(uint32_t *_retval);
|
||||
nsresult GetLastModified(uint32_t *_retval);
|
||||
nsresult GetLastFetched(uint32_t *_retval);
|
||||
nsresult GetFetchCount(uint32_t *_retval);
|
||||
// Called by upper layers to indicate the entry this metadata belongs
|
||||
// with has been fetched, i.e. delivered to the consumer.
|
||||
nsresult OnFetched();
|
||||
|
||||
int64_t Offset() { return mOffset; }
|
||||
uint32_t ElementsSize() { return mElementsSize; }
|
||||
void MarkDirty(bool aUpdateLastModified = true);
|
||||
void MarkDirty() { mIsDirty = true; }
|
||||
bool IsDirty() { return mIsDirty; }
|
||||
uint32_t MemoryUsage() { return sizeof(CacheFileMetadata) + mHashArraySize + mBufSize; }
|
||||
|
||||
|
|
|
@ -1,39 +0,0 @@
|
|||
function run_test()
|
||||
{
|
||||
do_get_profile();
|
||||
function NowSeconds() {
|
||||
return parseInt((new Date()).getTime() / 1000);
|
||||
}
|
||||
function do_check_time(t, min, max) {
|
||||
do_check_true(t >= min);
|
||||
do_check_true(t <= max);
|
||||
}
|
||||
|
||||
var timeStart = NowSeconds();
|
||||
|
||||
asyncOpenCacheEntry("http://t/", "disk", Ci.nsICacheStorage.OPEN_NORMALLY, null,
|
||||
new OpenCallback(NEW, "m", "d", function(entry) {
|
||||
|
||||
var firstOpen = NowSeconds();
|
||||
do_check_eq(entry.fetchCount, 1);
|
||||
do_check_time(entry.lastFetched, timeStart, firstOpen);
|
||||
do_check_time(entry.lastModified, timeStart, firstOpen);
|
||||
|
||||
do_timeout(2000, () => {
|
||||
asyncOpenCacheEntry("http://t/", "disk", Ci.nsICacheStorage.OPEN_NORMALLY, null,
|
||||
new OpenCallback(NORMAL, "m", "d", function(entry) {
|
||||
|
||||
var secondOpen = NowSeconds();
|
||||
do_check_eq(entry.fetchCount, 2);
|
||||
do_check_time(entry.lastFetched, firstOpen, secondOpen);
|
||||
do_check_time(entry.lastModified, timeStart, firstOpen);
|
||||
|
||||
finish_cache2_test();
|
||||
})
|
||||
);
|
||||
})
|
||||
})
|
||||
);
|
||||
|
||||
do_test_pending();
|
||||
}
|
|
@ -59,7 +59,6 @@ support-files =
|
|||
# GC, that this patch is dependent on, doesn't work well on Android.
|
||||
skip-if = os == "android"
|
||||
[test_cache2-27-force-valid-for.js]
|
||||
[test_cache2-28-last-access-attrs.js]
|
||||
[test_304_responses.js]
|
||||
[test_cacheForOfflineUse_no-store.js]
|
||||
[test_307_redirect.js]
|
||||
|
|
Загрузка…
Ссылка в новой задаче