Bug 937601 - HTTP cache v2: onCacheEntryCheck not called for R/O callbacks, r=michal

This commit is contained in:
Honza Bambas 2014-01-08 20:36:57 +01:00
parent 22a8993159
commit a88c0cbad6
3 changed files with 45 additions and 13 deletions

View File

@ -514,20 +514,23 @@ bool CacheEntry::InvokeCallback(Callback & aCallback)
// mRecheckAfterWrite flag already set means the callback has already passed
// the onCacheEntryCheck call. Until the current write is not finished this
// callback will be bypassed.
if (!aCallback.mReadOnly && !aCallback.mRecheckAfterWrite) {
if (mState == EMPTY) {
// Advance to writing state, we expect to invoke the callback and let
// it fill content of this entry. Must set and check the state here
// to prevent more then one
mState = WRITING;
LOG((" advancing to WRITING state"));
}
if (!aCallback.mRecheckAfterWrite) {
if (!aCallback.mCallback) {
// We can be given no callback only in case of recreate, it is ok
// to advance to WRITING state since the caller of recreate is expected
// to write this entry now.
return true;
if (!aCallback.mReadOnly) {
if (mState == EMPTY) {
// Advance to writing state, we expect to invoke the callback and let
// it fill content of this entry. Must set and check the state here
// to prevent more then one
mState = WRITING;
LOG((" advancing to WRITING state"));
}
if (!aCallback.mCallback) {
// We can be given no callback only in case of recreate, it is ok
// to advance to WRITING state since the caller of recreate is expected
// to write this entry now.
return true;
}
}
if (mState == READY) {

View File

@ -0,0 +1,28 @@
function run_test()
{
do_get_profile();
// Open for write, write
asyncOpenCacheEntry("http://ro/", "disk", Ci.nsICacheStorage.OPEN_NORMALLY, null,
new OpenCallback(NEW, "a1m", "a1d", function(entry) {
// Open for read and check
asyncOpenCacheEntry("http://ro/", "disk", Ci.nsICacheStorage.OPEN_READONLY, null,
new OpenCallback(NORMAL, "a1m", "a1d", function(entry) {
// Open for rewrite (truncate), write different meta and data
asyncOpenCacheEntry("http://ro/", "disk", Ci.nsICacheStorage.OPEN_TRUNCATE, null,
new OpenCallback(NEW, "a2m", "a2d", function(entry) {
// Open for read and check
asyncOpenCacheEntry("http://ro/", "disk", Ci.nsICacheStorage.OPEN_READONLY, null,
new OpenCallback(NORMAL, "a2m", "a2d", function(entry) {
finish_cache2_test();
})
);
})
);
})
);
})
);
do_test_pending();
}

View File

@ -18,6 +18,7 @@ support-files =
test_link.url
[test_cache2-01-basic.js]
[test_cache2-01a-basic-readonly.js]
[test_cache2-01b-basic-datasize.js]
[test_cache2-01c-basic-hasmeta-only.js]
[test_cache2-01d-basic-not-wanted.js]