mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-28 15:23:51 +00:00
Bug 722845 - Part 0: Add private flag for cache entries/sessions/requests. r=michal.novotny
This commit is contained in:
parent
917eb08db2
commit
c45b403049
2
netwerk/cache/nsCacheEntry.cpp
vendored
2
netwerk/cache/nsCacheEntry.cpp
vendored
@ -41,6 +41,8 @@ nsCacheEntry::nsCacheEntry(nsCString * key,
|
||||
|
||||
if (streamBased) MarkStreamBased();
|
||||
SetStoragePolicy(storagePolicy);
|
||||
|
||||
MarkPublic();
|
||||
}
|
||||
|
||||
|
||||
|
10
netwerk/cache/nsCacheEntry.h
vendored
10
netwerk/cache/nsCacheEntry.h
vendored
@ -113,7 +113,8 @@ public:
|
||||
eActiveMask = 0x00002000,
|
||||
eInitializedMask = 0x00004000,
|
||||
eValidMask = 0x00008000,
|
||||
eBindingMask = 0x00010000
|
||||
eBindingMask = 0x00010000,
|
||||
ePrivateMask = 0x00020000
|
||||
};
|
||||
|
||||
void MarkBinding() { mFlags |= eBindingMask; }
|
||||
@ -129,6 +130,8 @@ public:
|
||||
void MarkStreamData() { mFlags |= eStreamDataMask; }
|
||||
void MarkValid() { mFlags |= eValidMask; }
|
||||
void MarkInvalid() { mFlags &= ~eValidMask; }
|
||||
void MarkPrivate() { mFlags |= ePrivateMask; }
|
||||
void MarkPublic() { mFlags &= ~ePrivateMask; }
|
||||
// void MarkAllowedInMemory() { mFlags |= eAllowedInMemoryMask; }
|
||||
// void MarkAllowedOnDisk() { mFlags |= eAllowedOnDiskMask; }
|
||||
|
||||
@ -145,6 +148,7 @@ public:
|
||||
!(PR_CLIST_IS_EMPTY(&mRequestQ) &&
|
||||
PR_CLIST_IS_EMPTY(&mDescriptorQ)); }
|
||||
bool IsNotInUse() { return !IsInUse(); }
|
||||
bool IsPrivate() { return (mFlags & ePrivateMask) != 0; }
|
||||
|
||||
|
||||
bool IsAllowedInMemory()
|
||||
@ -155,9 +159,9 @@ public:
|
||||
|
||||
bool IsAllowedOnDisk()
|
||||
{
|
||||
return (StoragePolicy() == nsICache::STORE_ANYWHERE) ||
|
||||
return !IsPrivate() && ((StoragePolicy() == nsICache::STORE_ANYWHERE) ||
|
||||
(StoragePolicy() == nsICache::STORE_ON_DISK) ||
|
||||
(StoragePolicy() == nsICache::STORE_ON_DISK_AS_FILE);
|
||||
(StoragePolicy() == nsICache::STORE_ON_DISK_AS_FILE));
|
||||
}
|
||||
|
||||
bool IsAllowedOffline()
|
||||
|
8
netwerk/cache/nsCacheRequest.h
vendored
8
netwerk/cache/nsCacheRequest.h
vendored
@ -45,6 +45,7 @@ private:
|
||||
SetStoragePolicy(session->StoragePolicy());
|
||||
if (session->IsStreamBased()) MarkStreamBased();
|
||||
if (session->WillDoomEntriesIfExpired()) MarkDoomEntriesIfExpired();
|
||||
if (session->IsPrivate()) MarkPrivate();
|
||||
if (blockingMode == nsICache::BLOCKING) MarkBlockingMode();
|
||||
MarkWaitingForValidation();
|
||||
NS_IF_ADDREF(mListener);
|
||||
@ -66,6 +67,7 @@ private:
|
||||
enum CacheRequestInfo {
|
||||
eStoragePolicyMask = 0x000000FF,
|
||||
eStreamBasedMask = 0x00000100,
|
||||
ePrivateMask = 0x00000200,
|
||||
eDoomEntriesIfExpiredMask = 0x00001000,
|
||||
eBlockingModeMask = 0x00010000,
|
||||
eWaitingForValidationMask = 0x00100000,
|
||||
@ -104,9 +106,13 @@ private:
|
||||
|
||||
nsCacheStoragePolicy StoragePolicy()
|
||||
{
|
||||
return (nsCacheStoragePolicy)(mInfo & 0xFF);
|
||||
return (nsCacheStoragePolicy)(mInfo & eStoragePolicyMask);
|
||||
}
|
||||
|
||||
void MarkPrivate() { mInfo |= ePrivateMask; }
|
||||
void MarkPublic() { mInfo &= ~ePrivateMask; }
|
||||
bool IsPrivate() { return (mInfo & ePrivateMask) != 0; }
|
||||
|
||||
void MarkWaitingForValidation() { mInfo |= eWaitingForValidationMask; }
|
||||
void DoneWaitingForValidation() { mInfo &= ~eWaitingForValidationMask; }
|
||||
bool WaitingForValidation()
|
||||
|
3
netwerk/cache/nsCacheService.cpp
vendored
3
netwerk/cache/nsCacheService.cpp
vendored
@ -1941,6 +1941,9 @@ nsCacheService::ActivateEntry(nsCacheRequest * request,
|
||||
request->StoragePolicy());
|
||||
if (!entry)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
if (request->IsPrivate())
|
||||
entry->MarkPrivate();
|
||||
|
||||
entry->Fetched();
|
||||
++mTotalEntries;
|
||||
|
17
netwerk/cache/nsCacheSession.cpp
vendored
17
netwerk/cache/nsCacheSession.cpp
vendored
@ -21,6 +21,8 @@ nsCacheSession::nsCacheSession(const char * clientID,
|
||||
if (streamBased) MarkStreamBased();
|
||||
else SetStoragePolicy(nsICache::STORE_IN_MEMORY);
|
||||
|
||||
MarkPublic();
|
||||
|
||||
MarkDoomEntriesIfExpired();
|
||||
}
|
||||
|
||||
@ -98,3 +100,18 @@ NS_IMETHODIMP nsCacheSession::DoomEntry(const nsACString &key,
|
||||
{
|
||||
return nsCacheService::DoomEntry(this, key, listener);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsCacheSession::GetIsPrivate(bool* aPrivate)
|
||||
{
|
||||
*aPrivate = IsPrivate();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsCacheSession::SetIsPrivate(bool aPrivate)
|
||||
{
|
||||
if (aPrivate)
|
||||
MarkPrivate();
|
||||
else
|
||||
MarkPublic();
|
||||
return NS_OK;
|
||||
}
|
||||
|
6
netwerk/cache/nsCacheSession.h
vendored
6
netwerk/cache/nsCacheSession.h
vendored
@ -26,7 +26,8 @@ public:
|
||||
enum SessionInfo {
|
||||
eStoragePolicyMask = 0x000000FF,
|
||||
eStreamBasedMask = 0x00000100,
|
||||
eDoomEntriesIfExpiredMask = 0x00001000
|
||||
eDoomEntriesIfExpiredMask = 0x00001000,
|
||||
ePrivateMask = 0x00010000
|
||||
};
|
||||
|
||||
void MarkStreamBased() { mInfo |= eStreamBasedMask; }
|
||||
@ -37,6 +38,9 @@ public:
|
||||
void ClearDoomEntriesIfExpired() { mInfo &= ~eDoomEntriesIfExpiredMask; }
|
||||
bool WillDoomEntriesIfExpired() { return (0 != (mInfo & eDoomEntriesIfExpiredMask)); }
|
||||
|
||||
void MarkPrivate() { mInfo |= ePrivateMask; }
|
||||
void MarkPublic() { mInfo &= ~ePrivateMask; }
|
||||
bool IsPrivate() { return (mInfo & ePrivateMask) != 0; }
|
||||
nsCacheStoragePolicy StoragePolicy()
|
||||
{
|
||||
return (nsCacheStoragePolicy)(mInfo & eStoragePolicyMask);
|
||||
|
6
netwerk/cache/nsICacheSession.idl
vendored
6
netwerk/cache/nsICacheSession.idl
vendored
@ -69,4 +69,10 @@ interface nsICacheSession : nsISupports
|
||||
* doesn't care about the result.
|
||||
*/
|
||||
void doomEntry(in ACString key, in nsICacheListener listener);
|
||||
|
||||
/**
|
||||
* Private entries will be doomed when the last private browsing session
|
||||
* finishes.
|
||||
*/
|
||||
attribute boolean isPrivate;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user