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

Issue 9854031: Replace size_t with int in a few media classes. (Closed)

Created:
8 years, 9 months ago by scherkus (not reviewing)
Modified:
8 years, 9 months ago
CC:
chromium-reviews, feature-media-reviews_chromium.org, darin-cc_chromium.org
Visibility:
Public.

Description

Replace size_t with int in a few media classes. This addressed TODOs in DataSource::Read() and AudioRendererAlgorithmBase, which led to converting Buffer and SeekableBuffer as well. Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=129140

Patch Set 1 #

Patch Set 2 : fixes #

Patch Set 3 : foo #

Patch Set 4 : fix player_x11 #

Patch Set 5 : tests #

Patch Set 6 : tests #

Total comments: 2

Patch Set 7 : rebase #

Patch Set 8 : rebase #

Unified diffs Side-by-side diffs Delta from patch set Stats (+233 lines, -250 lines) Patch
M media/audio/linux/alsa_output.cc View 1 3 2 chunks +6 lines, -6 lines 0 comments Download
M media/audio/linux/alsa_output_unittest.cc View 1 2 3 4 8 chunks +8 lines, -8 lines 0 comments Download
M media/audio/mac/audio_low_latency_input_mac_unittest.cc View 3 3 chunks +4 lines, -4 lines 0 comments Download
M media/audio/win/audio_low_latency_input_win_unittest.cc View 1 3 1 chunk +1 line, -1 line 0 comments Download
M media/base/buffers.h View 1 2 3 4 5 6 1 chunk +1 line, -1 line 0 comments Download
M media/base/buffers_unittest.cc View 1 2 3 4 5 6 7 3 chunks +4 lines, -4 lines 0 comments Download
M media/base/data_buffer.h View 3 3 chunks +8 lines, -8 lines 0 comments Download
M media/base/data_buffer.cc View 1 2 3 4 5 6 4 chunks +7 lines, -7 lines 0 comments Download
M media/base/data_buffer_unittest.cc View 1 2 3 4 5 6 1 chunk +4 lines, -4 lines 0 comments Download
M media/base/data_source.h View 3 2 chunks +3 lines, -6 lines 0 comments Download
M media/base/data_source.cc View 3 1 chunk +1 line, -1 line 0 comments Download
M media/base/mock_filters.h View 3 1 chunk +1 line, -1 line 0 comments Download
M media/base/seekable_buffer.h View 3 5 chunks +23 lines, -23 lines 0 comments Download
M media/base/seekable_buffer.cc View 3 12 chunks +27 lines, -27 lines 0 comments Download
M media/base/seekable_buffer_unittest.cc View 3 12 chunks +46 lines, -46 lines 0 comments Download
M media/crypto/aes_decryptor_unittest.cc View 3 1 chunk +1 line, -1 line 0 comments Download
M media/filters/audio_renderer_algorithm_base.h View 3 8 chunks +12 lines, -14 lines 0 comments Download
M media/filters/audio_renderer_algorithm_base.cc View 3 13 chunks +28 lines, -28 lines 0 comments Download
M media/filters/ffmpeg_demuxer.h View 3 2 chunks +5 lines, -9 lines 0 comments Download
M media/filters/ffmpeg_demuxer.cc View 1 2 3 4 5 6 3 chunks +7 lines, -11 lines 0 comments Download
M media/filters/ffmpeg_demuxer_unittest.cc View 3 3 chunks +6 lines, -6 lines 0 comments Download
M media/filters/file_data_source.h View 3 1 chunk +1 line, -1 line 0 comments Download
M media/filters/file_data_source.cc View 3 2 chunks +2 lines, -2 lines 0 comments Download
M media/filters/file_data_source_unittest.cc View 3 1 chunk +1 line, -1 line 0 comments Download
M media/tools/player_x11/data_source_logger.h View 1 2 3 1 chunk +1 line, -1 line 0 comments Download
M media/tools/player_x11/data_source_logger.cc View 1 2 3 2 chunks +3 lines, -3 lines 0 comments Download
M webkit/media/buffered_data_source.h View 3 1 chunk +2 lines, -5 lines 0 comments Download
M webkit/media/buffered_data_source.cc View 3 3 chunks +3 lines, -4 lines 0 comments Download
M webkit/media/buffered_data_source_unittest.cc View 3 2 chunks +2 lines, -2 lines 0 comments Download
M webkit/media/buffered_resource_loader_unittest.cc View 3 6 chunks +15 lines, -15 lines 0 comments Download

Messages

Total messages: 12 (0 generated)
scherkus (not reviewing)
fischman: based on size_t vs int discussions in STO vrk: FYI as I fixed your ...
8 years, 9 months ago (2012-03-26 22:35:24 UTC) #1
Ami GONE FROM CHROMIUM
LGTM % q. http://codereview.chromium.org/9854031/diff/11002/media/base/data_source.h File media/base/data_source.h (right): http://codereview.chromium.org/9854031/diff/11002/media/base/data_source.h#newcode43 media/base/data_source.h:43: virtual void Read(int64 position, int size, ...
8 years, 9 months ago (2012-03-26 23:01:20 UTC) #2
scherkus (not reviewing)
https://chromiumcodereview.appspot.com/9854031/diff/11002/media/base/data_source.h File media/base/data_source.h (right): https://chromiumcodereview.appspot.com/9854031/diff/11002/media/base/data_source.h#newcode43 media/base/data_source.h:43: virtual void Read(int64 position, int size, uint8* data, On ...
8 years, 9 months ago (2012-03-26 23:19:39 UTC) #3
xhwang
Does this mean we prefer to using int than size_t for general sizes and even ...
8 years, 9 months ago (2012-03-26 23:21:08 UTC) #4
scherkus (not reviewing)
On 2012/03/26 23:21:08, xhwang wrote: > Does this mean we prefer to using int than ...
8 years, 9 months ago (2012-03-26 23:27:39 UTC) #5
Ami GONE FROM CHROMIUM
> > The only time we should be using unsigned integers is when dealing with ...
8 years, 9 months ago (2012-03-26 23:37:00 UTC) #6
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/scherkus@chromium.org/9854031/6061
8 years, 9 months ago (2012-03-27 00:12:17 UTC) #7
commit-bot: I haz the power
Try job failure for 9854031-6061 (retry) on linux_chromeos for step "compile" (clobber build). It's a ...
8 years, 9 months ago (2012-03-27 00:44:55 UTC) #8
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/scherkus@chromium.org/9854031/9049
8 years, 9 months ago (2012-03-27 01:03:48 UTC) #9
commit-bot: I haz the power
Try job failure for 9854031-9049 (retry) on win_rel for step "ui_tests". It's a second try, ...
8 years, 9 months ago (2012-03-27 03:46:23 UTC) #10
Peter Kasting
I asked Andrew over IM to revert this patch if possible. The rest of Chrome ...
8 years, 9 months ago (2012-03-27 19:02:28 UTC) #11
Ami GONE FROM CHROMIUM
8 years, 9 months ago (2012-03-27 20:26:08 UTC) #12
> The rest of Chrome not only allows but explicitly encourages size_t where
> applicable

The "applicable" here refers to the style guide's mention of "counts of objects
or bytes in memory".  Presumably the rationale is that such quantities are
naturally bound by the arch's limits, so size_t is guaranteed to be sufficient
(avoids overflow).

The cost of this guaranteed-not-overflowable approach is significantly increased
subtlety around subtraction (unsigned subtraction can result in wrap-around).
Buffer management in particular is prone to this sort of subtraction, so it
seems worthwhile to avoid the subtlety when possible.  In the code in question
we know the sizes we deal with are bound pretty small, and certainly fit in 31
bits, so the trade-off is worthwhile.

A different supporting point: the guide encourages use of size_t when that fits
with the surrounding eco-system (STL, syscalls, etc); this patch demonstrates
that s/size_t/int/g increases compatibility with the surrounding eco-system
involved here (static_cast<>'s are removed, not added).

I'd like to see this change stick.

Powered by Google App Engine
This is Rietveld 408576698