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

Issue 2232083002: Fix incorrect usage of StringImpl::sizeInBytes. (Closed)

Created:
4 years, 4 months ago by esprehn
Modified:
4 years, 4 months ago
CC:
apavlov+blink_chromium.org, blink-reviews, blink-reviews-bindings_chromium.org, blink-reviews-wtf_chromium.org, caseq+blink_chromium.org, chromium-reviews, devtools-reviews_chromium.org, gavinp+loader_chromium.org, Nate Chapin, kozyatinskiy+blink_chromium.org, loading-reviews+fetch_chromium.org, loading-reviews_chromium.org, lushnikov+blink_chromium.org, Mikhail, pfeldman+blink_chromium.org, tyoshino+watch_chromium.org
Base URL:
https://chromium.googlesource.com/chromium/src.git@master
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

Fix incorrect usage of StringImpl::sizeInBytes. Confusingly StringImpl::sizeInBytes and String::sizeInBytes return totally different things! - StringImpl's method returns the size of the storage for the characters *plus* the size of the StringImpl object overhead. - String's method returns just the size of the storage for the characters. This patch makes them both return the size of the storage for the characters which is actually what everyone wants and renames the method charactersSizeInBytes(). Thankfully the only confused caller was NetworkResourcesData in the inspector. I also removed the memoryConsumption() method in StringResource which was just duplicating this method and added a method to AtomicString so it has the same API as String. I also switched to size_t for the return value of charactersSizeInBytes() because the length of a string can be nearly UINT_MAX, and sizeof(UChar) is 2, which means a very large string could have caused overflow here on 64bit machines. Finally I fixed a potential integer overflow in StringResource where we were negating the unsigned value returned from sizeInBytes() and assigning to an int, then subtracting from it the size of the AtomicString if it exists. Committed: https://crrev.com/3d24a7c4d0c8ede0dffb89b1e7d9e3340f7e7546 Cr-Commit-Position: refs/heads/master@{#411351}

Patch Set 1 #

Patch Set 2 : Fix mojo. #

Patch Set 3 : size_teeee #

Unified diffs Side-by-side diffs Delta from patch set Stats (+34 lines, -51 lines) Patch
M mojo/public/cpp/bindings/lib/string_traits_wtf.cc View 1 2 2 chunks +2 lines, -3 lines 0 comments Download
M third_party/WebKit/Source/bindings/core/v8/V8StringResource.h View 1 2 5 chunks +6 lines, -10 lines 0 comments Download
M third_party/WebKit/Source/core/fetch/ScriptResource.cpp View 2 chunks +2 lines, -2 lines 0 comments Download
M third_party/WebKit/Source/core/inspector/NetworkResourcesData.h View 1 2 1 chunk +2 lines, -2 lines 0 comments Download
M third_party/WebKit/Source/core/inspector/NetworkResourcesData.cpp View 1 2 5 chunks +7 lines, -12 lines 0 comments Download
M third_party/WebKit/Source/core/loader/BeaconLoader.cpp View 1 chunk +1 line, -1 line 0 comments Download
M third_party/WebKit/Source/platform/inspector_protocol/String16STL.h View 1 2 1 chunk +1 line, -1 line 0 comments Download
M third_party/WebKit/Source/platform/inspector_protocol/String16WTF.h View 1 2 1 chunk +1 line, -1 line 0 comments Download
M third_party/WebKit/Source/platform/v8_inspector/V8DebuggerScript.cpp View 1 2 1 chunk +4 lines, -3 lines 0 comments Download
M third_party/WebKit/Source/wtf/text/AtomicString.h View 1 2 1 chunk +2 lines, -0 lines 0 comments Download
M third_party/WebKit/Source/wtf/text/StringImpl.h View 1 chunk +4 lines, -1 line 0 comments Download
M third_party/WebKit/Source/wtf/text/StringImpl.cpp View 1 chunk +0 lines, -8 lines 0 comments Download
M third_party/WebKit/Source/wtf/text/WTFString.h View 1 2 2 chunks +2 lines, -7 lines 0 comments Download

Messages

Total messages: 25 (19 generated)
esprehn
4 years, 4 months ago (2016-08-11 06:16:13 UTC) #15
haraken
LGTM
4 years, 4 months ago (2016-08-11 12:13:20 UTC) #18
yzshen1
On 2016/08/11 12:13:20, haraken wrote: > LGTM LGTM!
4 years, 4 months ago (2016-08-11 16:20:37 UTC) #19
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.org/2232083002/40001
4 years, 4 months ago (2016-08-11 16:25:58 UTC) #22
commit-bot: I haz the power
Committed patchset #3 (id:40001)
4 years, 4 months ago (2016-08-11 16:30:01 UTC) #23
commit-bot: I haz the power
4 years, 4 months ago (2016-08-11 16:33:08 UTC) #25
Message was sent while issue was closed.
Patchset 3 (id:??) landed as
https://crrev.com/3d24a7c4d0c8ede0dffb89b1e7d9e3340f7e7546
Cr-Commit-Position: refs/heads/master@{#411351}

Powered by Google App Engine
This is Rietveld 408576698