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

Unified Diff: third_party/WebKit/Source/bindings/core/v8/V8StringResource.h

Issue 2232083002: Fix incorrect usage of StringImpl::sizeInBytes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: size_teeee 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/bindings/core/v8/V8StringResource.h
diff --git a/third_party/WebKit/Source/bindings/core/v8/V8StringResource.h b/third_party/WebKit/Source/bindings/core/v8/V8StringResource.h
index b65cfad6b6ec892d1bc79b622ffebcca6b34d412..9194e8565726528186a6b52d33f8f43780970283 100644
--- a/third_party/WebKit/Source/bindings/core/v8/V8StringResource.h
+++ b/third_party/WebKit/Source/bindings/core/v8/V8StringResource.h
@@ -48,7 +48,7 @@ public:
m_threadId = WTF::currentThread();
#endif
ASSERT(!string.isNull());
- v8::Isolate::GetCurrent()->AdjustAmountOfExternalAllocatedMemory(memoryConsumption(string));
+ v8::Isolate::GetCurrent()->AdjustAmountOfExternalAllocatedMemory(string.charactersSizeInBytes());
}
explicit WebCoreStringResourceBase(const AtomicString& string)
@@ -59,7 +59,7 @@ public:
m_threadId = WTF::currentThread();
#endif
ASSERT(!string.isNull());
- v8::Isolate::GetCurrent()->AdjustAmountOfExternalAllocatedMemory(memoryConsumption(string));
+ v8::Isolate::GetCurrent()->AdjustAmountOfExternalAllocatedMemory(string.charactersSizeInBytes());
}
virtual ~WebCoreStringResourceBase()
@@ -67,10 +67,10 @@ public:
#if ENABLE(ASSERT)
ASSERT(m_threadId == WTF::currentThread());
#endif
- int reducedExternalMemory = -memoryConsumption(m_plainString);
+ int64_t reducedExternalMemory = m_plainString.charactersSizeInBytes();
if (m_plainString.impl() != m_atomicString.impl() && !m_atomicString.isNull())
- reducedExternalMemory -= memoryConsumption(m_atomicString);
- v8::Isolate::GetCurrent()->AdjustAmountOfExternalAllocatedMemory(reducedExternalMemory);
+ reducedExternalMemory += m_atomicString.charactersSizeInBytes();
+ v8::Isolate::GetCurrent()->AdjustAmountOfExternalAllocatedMemory(-reducedExternalMemory);
}
const String& webcoreString() { return m_plainString; }
@@ -84,7 +84,7 @@ public:
m_atomicString = AtomicString(m_plainString);
ASSERT(!m_atomicString.isNull());
if (m_plainString.impl() != m_atomicString.impl())
- v8::Isolate::GetCurrent()->AdjustAmountOfExternalAllocatedMemory(memoryConsumption(m_atomicString.getString()));
+ v8::Isolate::GetCurrent()->AdjustAmountOfExternalAllocatedMemory(m_atomicString.charactersSizeInBytes());
}
return m_atomicString;
}
@@ -100,10 +100,6 @@ protected:
AtomicString m_atomicString;
private:
- static int memoryConsumption(const String& string)
- {
- return string.length() * (string.is8Bit() ? sizeof(LChar) : sizeof(UChar));
- }
#if ENABLE(ASSERT)
WTF::ThreadIdentifier m_threadId;
#endif
« no previous file with comments | « mojo/public/cpp/bindings/lib/string_traits_wtf.cc ('k') | third_party/WebKit/Source/core/fetch/ScriptResource.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698