Merge "Lock cache puts while running tests"
This commit is contained in:
commit
3161f1a3f2
@ -105,6 +105,8 @@ public final class ContentCache {
|
|||||||
private final String mLogTag;
|
private final String mLogTag;
|
||||||
// Cache statistics
|
// Cache statistics
|
||||||
private final Statistics mStats;
|
private final Statistics mStats;
|
||||||
|
/** If {@code true}, lock the cache for all writes */
|
||||||
|
private static boolean sLockCache;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A synchronized reference counter for arbitrary objects
|
* A synchronized reference counter for arbitrary objects
|
||||||
@ -465,7 +467,7 @@ public final class ContentCache {
|
|||||||
mStats.mStaleCount++;
|
mStats.mStaleCount++;
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
if (c != null && projection == mBaseProjection) {
|
if (c != null && projection == mBaseProjection && !sLockCache) {
|
||||||
if (Email.DEBUG && DEBUG_CACHE) {
|
if (Email.DEBUG && DEBUG_CACHE) {
|
||||||
Log.d(mLogTag, "============ Caching cursor for: " + id);
|
Log.d(mLogTag, "============ Caching cursor for: " + id);
|
||||||
}
|
}
|
||||||
@ -611,7 +613,7 @@ public final class ContentCache {
|
|||||||
if (Email.DEBUG && DEBUG_CACHE) {
|
if (Email.DEBUG && DEBUG_CACHE) {
|
||||||
Log.d(mLogTag, "=========== Unlocking cache for: " + id);
|
Log.d(mLogTag, "=========== Unlocking cache for: " + id);
|
||||||
}
|
}
|
||||||
if (values != null) {
|
if (values != null && !sLockCache) {
|
||||||
MatrixCursor cursor = getMatrixCursor(id, mBaseProjection, values);
|
MatrixCursor cursor = getMatrixCursor(id, mBaseProjection, values);
|
||||||
if (cursor != null) {
|
if (cursor != null) {
|
||||||
if (Email.DEBUG && DEBUG_CACHE) {
|
if (Email.DEBUG && DEBUG_CACHE) {
|
||||||
@ -727,6 +729,14 @@ public final class ContentCache {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Sets the cache lock. If the lock is {@code true}, also invalidates all cached items. */
|
||||||
|
public static void setLockCacheForTest(boolean lock) {
|
||||||
|
sLockCache = lock;
|
||||||
|
if (sLockCache) {
|
||||||
|
invalidateAllCachesForTest();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static class Statistics {
|
static class Statistics {
|
||||||
private final ContentCache mCache;
|
private final ContentCache mCache;
|
||||||
private final String mName;
|
private final String mName;
|
||||||
|
Loading…
Reference in New Issue
Block a user