Skip to content
This repository has been archived by the owner on Aug 4, 2022. It is now read-only.

Commit

Permalink
Bug 746018 - Part 4 - More cache logging, r=jduell
Browse files Browse the repository at this point in the history
  • Loading branch information
Brian Smith committed May 31, 2012
1 parent 53f1ade commit 3f085df
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 8 deletions.
11 changes: 8 additions & 3 deletions netwerk/cache/nsCacheEntryDescriptor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,7 @@ nsInputStreamWrapper::LazyInit()
getter_AddRefs(mInput));

CACHE_LOG_DEBUG(("nsInputStreamWrapper::LazyInit "
"[entry=%p, wrapper=%p, mInput=%p, rv=%d",
"[entry=%p, wrapper=%p, mInput=%p, rv=%d]",
mDescriptor, this, mInput.get(), PRIntn(rv)));

if (NS_FAILED(rv)) return rv;
Expand Down Expand Up @@ -573,9 +573,14 @@ nsresult nsCacheEntryDescriptor::
nsInputStreamWrapper::Read(char *buf, PRUint32 count, PRUint32 *countRead)
{
nsresult rv = EnsureInit();
if (NS_FAILED(rv)) return rv;
if (NS_SUCCEEDED(rv))
rv = mInput->Read(buf, count, countRead);

return mInput->Read(buf, count, countRead);
CACHE_LOG_DEBUG(("nsInputStreamWrapper::Read "
"[entry=%p, wrapper=%p, mInput=%p, rv=%d]",
mDescriptor, this, mInput.get(), rv));

return rv;
}

nsresult nsCacheEntryDescriptor::
Expand Down
19 changes: 14 additions & 5 deletions netwerk/cache/nsDiskCacheBlockFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

#include "nsCache.h"
#include "nsDiskCache.h"
#include "nsDiskCacheBlockFile.h"
#include "mozilla/FileUtils.h"
Expand Down Expand Up @@ -31,14 +32,15 @@ nsDiskCacheBlockFile::Open(nsILocalFile * blockFile,

// open the file - restricted to user, the data could be confidential
nsresult rv = blockFile->OpenNSPRFileDesc(PR_RDWR | PR_CREATE_FILE, 00600, &mFD);
if (NS_FAILED(rv)) return rv; // unable to open or create file
if (NS_FAILED(rv)) {
CACHE_LOG_DEBUG(("CACHE: nsDiskCacheBlockFile::Open "
"[this=%p] unable to open or create file: %d",
this, rv));
return rv; // unable to open or create file
}

// allocate bit map buffer
mBitMap = new PRUint32[mBitMapWords];
if (!mBitMap) {
rv = NS_ERROR_OUT_OF_MEMORY;
goto error_exit;
}

// check if we just creating the file
mFileSize = PR_Available(mFD);
Expand Down Expand Up @@ -79,9 +81,13 @@ nsDiskCacheBlockFile::Open(nsILocalFile * blockFile,
goto error_exit;
}
}
CACHE_LOG_DEBUG(("CACHE: nsDiskCacheBlockFile::Open [this=%p] succeeded",
this));
return NS_OK;

error_exit:
CACHE_LOG_DEBUG(("CACHE: nsDiskCacheBlockFile::Open [this=%p] failed with "
"error %d", this, rv));
Close(false);
return rv;
}
Expand Down Expand Up @@ -234,6 +240,9 @@ nsDiskCacheBlockFile::ReadBlocks( void * buffer,
}
*bytesRead = PR_Read(mFD, buffer, bytesToRead);

CACHE_LOG_DEBUG(("CACHE: nsDiskCacheBlockFile::Read [this=%p] "
"returned %d / %d bytes", this, *bytesRead, bytesToRead));

return NS_OK;
}

Expand Down
6 changes: 6 additions & 0 deletions netwerk/cache/nsDiskCacheMap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ nsDiskCacheMap::Open(nsILocalFile * cacheDirectory)
if (!cacheFilesExist)
goto error_exit;

CACHE_LOG_DEBUG(("CACHE: nsDiskCacheMap::Open [this=%p] reading map", this));

// read the header
PRUint32 bytesRead = PR_Read(mMapFD, &mHeader, sizeof(nsDiskCacheHeader));
if (sizeof(nsDiskCacheHeader) != bytesRead) goto error_exit;
Expand Down Expand Up @@ -686,7 +688,11 @@ nsDiskCacheMap::ReadDiskCacheEntry(nsDiskCacheRecord * record)
getter_AddRefs(file));
NS_ENSURE_SUCCESS(rv, nsnull);

CACHE_LOG_DEBUG(("CACHE: nsDiskCacheMap::ReadDiskCacheEntry"
"[this=%p] reading disk cache entry", this));

PRFileDesc * fd = nsnull;

// open the file - restricted to user, the data could be confidential
rv = file->OpenNSPRFileDesc(PR_RDONLY, 00600, &fd);
NS_ENSURE_SUCCESS(rv, nsnull);
Expand Down
2 changes: 2 additions & 0 deletions netwerk/cache/nsDiskCacheStreams.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -703,6 +703,8 @@ nsDiskCacheStreamIO::OpenCacheFile(PRIntn flags, PRFileDesc ** fd)
{
NS_ENSURE_ARG_POINTER(fd);

CACHE_LOG_DEBUG(("nsDiskCacheStreamIO::OpenCacheFile"));

nsresult rv;
nsDiskCacheMap * cacheMap = mDevice->CacheMap();

Expand Down

0 comments on commit 3f085df

Please sign in to comment.