Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(114)

Unified Diff: third_party/WebKit/Source/core/fetch/Resource.cpp

Issue 2253853002: Remove SharedBuffer::unlock() and keep Resource's SharedBuffer always locked (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/fetch/Resource.cpp
diff --git a/third_party/WebKit/Source/core/fetch/Resource.cpp b/third_party/WebKit/Source/core/fetch/Resource.cpp
index 96c1129075a39e2484a4907b38b952ff3223b79b..b403e003f19229a167f701a5658b470735f1d65e 100644
--- a/third_party/WebKit/Source/core/fetch/Resource.cpp
+++ b/third_party/WebKit/Source/core/fetch/Resource.cpp
@@ -556,19 +556,10 @@ bool Resource::unlock()
if (!m_data)
return false;
- if (!m_data->isLocked())
- return true;
-
if (!memoryCache()->contains(this) || hasClientsOrObservers() || !isLoaded() || !isSafeToUnlock())
return false;
- if (RuntimeEnabledFeatures::doNotUnlockSharedBufferEnabled())
- return false;
-
- DEFINE_THREAD_SAFE_STATIC_LOCAL(EnumerationHistogram, unlockHistogram, new EnumerationHistogram("Blink.SharedBuffer.Unlock", kLastResourceType));
- unlockHistogram.count(getType());
-
- m_data->unlock();
+ memoryCache()->remove(this);
haraken 2016/08/17 08:13:31 Would you help me understand why you need to proac
hiroshige 2016/08/17 09:02:38 Because the Resource is not expected to be reused
haraken 2016/08/17 09:10:25 Makes sense. I'm feeling that whether we call mem
return true;
}
@@ -676,7 +667,6 @@ static bool shouldSendCachedDataSynchronouslyForType(Resource::Type type)
void Resource::willAddClientOrObserver()
{
- ASSERT(!isPurgeable());
if (m_preloadResult == PreloadNotReferenced) {
if (isLoaded())
m_preloadResult = PreloadReferencedWhileComplete;
@@ -843,13 +833,12 @@ void Resource::onMemoryDump(WebMemoryDumpLevelOfDetail levelOfDetail, WebProcess
const String dumpName = getMemoryDumpName();
WebMemoryAllocatorDump* dump = memoryDump->createMemoryAllocatorDump(dumpName);
dump->addScalar("encoded_size", "bytes", m_encodedSize);
- if (m_data && m_data->isLocked())
+ if (m_data)
dump->addScalar("live_size", "bytes", m_encodedSize);
else
dump->addScalar("dead_size", "bytes", m_encodedSize);
if (m_data) {
- dump->addScalar("purgeable_size", "bytes", isPurgeable() ? encodedSize() + overheadSize() : 0);
m_data->onMemoryDump(dumpName, memoryDump);
}
@@ -983,38 +972,6 @@ bool Resource::canUseCacheValidator()
return m_response.hasCacheValidatorFields() || m_resourceRequest.hasCacheValidatorFields();
}
-bool Resource::isPurgeable() const
-{
- return m_data && !m_data->isLocked();
-}
-
-bool Resource::lock()
-{
- if (!m_data)
- return true;
- if (m_data->isLocked())
- return true;
-
- ASSERT(!hasClientsOrObservers());
-
- // If locking fails, our buffer has been purged. There's no point
- // in leaving a purged resource in MemoryCache.
- if (!m_data->lock()) {
- DEFINE_THREAD_SAFE_STATIC_LOCAL(EnumerationHistogram, failedLockHistogram, new EnumerationHistogram("Blink.SharedBuffer.FailedLock", kLastResourceType));
- failedLockHistogram.count(getType());
-
- m_data.clear();
- setEncodedSize(0);
- memoryCache()->remove(this);
- return false;
- }
-
- DEFINE_THREAD_SAFE_STATIC_LOCAL(EnumerationHistogram, successfulLockHistogram, new EnumerationHistogram("Blink.SharedBuffer.SuccessfulLock", kLastResourceType));
- successfulLockHistogram.count(getType());
-
- return true;
-}
-
size_t Resource::calculateOverheadSize() const
{
static const int kAverageClientsHashMapSize = 384;

Powered by Google App Engine
This is Rietveld 408576698