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

Issue 2718483003: Use base::Optional for selected video track. (Closed)

Created:
3 years, 10 months ago by servolk
Modified:
3 years, 9 months ago
CC:
apacible+watch_chromium.org, chromium-reviews, erickung+watch_chromium.org, feature-media-reviews_chromium.org, miu+watch_chromium.org, posciak+watch_chromium.org, xjz+watch_chromium.org
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

Use base::Optional for selected video track. Previously we used a one-element std::vector for passing around the selected video track, but we can use base::Optional instead, since there is never more than one selected video track. Review-Url: https://codereview.chromium.org/2718483003 Cr-Commit-Position: refs/heads/master@{#452705} Committed: https://chromium.googlesource.com/chromium/src/+/9bed660668c954ffd18eee419fba8c5cfaac8789

Patch Set 1 #

Total comments: 10

Patch Set 2 : CR feedback #

Patch Set 3 : Updated also enabledTrackIds -> enabled_track_ids #

Patch Set 4 : rebase #

Unified diffs Side-by-side diffs Delta from patch set Stats (+90 lines, -100 lines) Patch
M media/base/demuxer.h View 1 2 chunks +6 lines, -4 lines 0 comments Download
M media/base/media_url_demuxer.h View 1 1 chunk +4 lines, -3 lines 0 comments Download
M media/base/media_url_demuxer.cc View 1 1 chunk +3 lines, -3 lines 0 comments Download
M media/base/mock_filters.h View 2 chunks +2 lines, -2 lines 0 comments Download
M media/base/pipeline.h View 1 2 1 chunk +5 lines, -5 lines 0 comments Download
M media/base/pipeline_impl.h View 1 2 1 chunk +5 lines, -5 lines 0 comments Download
M media/base/pipeline_impl.cc View 1 2 4 chunks +19 lines, -19 lines 0 comments Download
M media/blink/webmediaplayer_impl.cc View 1 2 3 1 chunk +6 lines, -9 lines 0 comments Download
M media/filters/chunk_demuxer.h View 1 1 chunk +5 lines, -4 lines 0 comments Download
M media/filters/chunk_demuxer.cc View 1 2 3 3 chunks +9 lines, -11 lines 0 comments Download
M media/filters/ffmpeg_demuxer.h View 1 1 chunk +5 lines, -4 lines 0 comments Download
M media/filters/ffmpeg_demuxer.cc View 1 2 3 3 chunks +9 lines, -10 lines 0 comments Download
M media/test/pipeline_integration_test.cc View 1 7 chunks +12 lines, -21 lines 0 comments Download

Messages

Total messages: 36 (19 generated)
servolk
3 years, 10 months ago (2017-02-23 18:44:05 UTC) #4
watk
lgtm with nits. I'm confused why this code uses camelCase though. Maybe it's a convention ...
3 years, 10 months ago (2017-02-23 20:57:54 UTC) #8
servolk
On 2017/02/23 20:57:54, watk wrote: > lgtm with nits. I'm confused why this code uses ...
3 years, 10 months ago (2017-02-23 21:15:39 UTC) #11
servolk
https://codereview.chromium.org/2718483003/diff/1/media/base/pipeline.h File media/base/pipeline.h (right): https://codereview.chromium.org/2718483003/diff/1/media/base/pipeline.h#newcode85 media/base/pipeline.h:85: // |trackId| is either empty, which means no video ...
3 years, 10 months ago (2017-02-23 21:15:49 UTC) #12
watk
Thanks for fixing naming! lgtm
3 years, 10 months ago (2017-02-23 21:18:34 UTC) #13
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/2718483003/40001
3 years, 10 months ago (2017-02-23 21:19:46 UTC) #19
commit-bot: I haz the power
Failed to apply patch for media/filters/chunk_demuxer.cc: While running git apply --index -p1; error: patch failed: ...
3 years, 10 months ago (2017-02-23 23:24:51 UTC) #21
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/2718483003/60001
3 years, 10 months ago (2017-02-23 23:33:21 UTC) #24
commit-bot: I haz the power
Committed patchset #4 (id:60001) as https://chromium.googlesource.com/chromium/src/+/9bed660668c954ffd18eee419fba8c5cfaac8789
3 years, 10 months ago (2017-02-24 01:21:09 UTC) #27
mlamouri (slow - plz ping)
base::Optional isn't recommended for parameters, see https://chromium.googlesource.com/chromium/src/+/master/docs/optional.md#When-not-to-use Would a pointer have done the job here?
3 years, 10 months ago (2017-02-24 11:32:22 UTC) #29
servolk
On 2017/02/24 11:32:22, mlamouri wrote: > base::Optional isn't recommended for parameters, see > https://chromium.googlesource.com/chromium/src/+/master/docs/optional.md#When-not-to-use > ...
3 years, 10 months ago (2017-02-24 17:52:00 UTC) #30
watk
On 2017/02/24 17:52:00, servolk wrote: > On 2017/02/24 11:32:22, mlamouri wrote: > > base::Optional isn't ...
3 years, 10 months ago (2017-02-24 20:40:02 UTC) #31
mlamouri (slow - plz ping)
On 2017/02/24 at 20:40:02, watk wrote: > On 2017/02/24 17:52:00, servolk wrote: > > On ...
3 years, 9 months ago (2017-02-27 11:06:38 UTC) #32
watk
On 2017/02/27 11:06:38, mlamouri wrote: > On 2017/02/24 at 20:40:02, watk wrote: > > On ...
3 years, 9 months ago (2017-03-01 22:08:48 UTC) #33
servolk
On 2017/03/01 22:08:48, watk wrote: > On 2017/02/27 11:06:38, mlamouri wrote: > > On 2017/02/24 ...
3 years, 9 months ago (2017-03-03 22:22:01 UTC) #34
watk
On 2017/03/03 22:22:01, servolk wrote: > On 2017/03/01 22:08:48, watk wrote: > > On 2017/02/27 ...
3 years, 9 months ago (2017-03-03 22:27:23 UTC) #35
servolk
3 years, 9 months ago (2017-03-03 22:29:06 UTC) #36
Message was sent while issue was closed.
On 2017/03/03 22:27:23, watk wrote:
> On 2017/03/03 22:22:01, servolk wrote:
> > On 2017/03/01 22:08:48, watk wrote:
> > > On 2017/02/27 11:06:38, mlamouri wrote:
> > > > On 2017/02/24 at 20:40:02, watk wrote:
> > > > > On 2017/02/24 17:52:00, servolk wrote:
> > > > > > On 2017/02/24 11:32:22, mlamouri wrote:
> > > > > > > base::Optional isn't recommended for parameters, see
> > > > > > >
> > > > > >
> > > >
> > >
> >
>
https://chromium.googlesource.com/chromium/src/+/master/docs/optional.md#When...
> > > > > > > 
> > > > > > > Would a pointer have done the job here?
> > > > > > 
> > > > > > Ah, thanks, I wasn't aware of those limitations. I've considered
using
> a
> > > > > > pointer, but a raw pointer isn't good here since we need to pass
this
> > > value
> > > > > > between the UI and media thread (see PostTask in pipeline_impl.cc),
> and
> > I
> > > > didn't
> > > > > > want to deal with lifetime management issues. But I guess we could
use
> > > > > > scoped_ptr<MediaTrack::Id> instead, that should work. WDYT about
using
> > > > > > scoped_ptr instead of base::Optional?
> > > > > 
> > > > > mlamouri@, could you help me understand why this is the guidance? I
> > > understand
> > > > why you might not want to have optionals in the public interface of a
> > library,
> > > > but why does it matter between internal pieces? I guess the goal is to
> avoid
> > > > having any layer that has to translate between a pointer and an
optional?
> So
> > > > make it a pointer through every layer? Optionals are nice because you
> don't
> > > have
> > > > to care about lifetimes.
> > > > > 
> > > > > servolk@, seems like unique_ptr works so I would use that.
> > > > 
> > > > To be clear, I have no strong opinion about this, this is what the
//base
> > > OWNERS
> > > > asked for when I wrote the implementation of base::Optional. They had
> > specific
> > > > concerns about Windows (as said in the doc). I wouldn't be surprised
that
> > > > base::Optional<> has been used as argument's type in other places so
it's
> > > > probably not the end of the world :)
> > > 
> > > Ah ok. danakj@ said that T* should be preferred when possible. But since
T*
> > > doesn't work in this case because we're binding into a callback, optional
> > seems
> > > fine.
> > 
> > Sorry for the delay on this. perf ate my time :)
> > But it sounds like all is good and we can actually keep using the
> > base::Optional?
> 
> Yep. The conclusion is: prefer T*, if it's not possible carefully consider the
> implications of using optional because it may be contagious and make
surrounding
> code unclear or difficult to work with.
> 
> In this case since the alternative is unique_ptr, which IMO is equivalent in
> terms of how it affects surrounding code, optional is fine.

Got it, makes sense, thanks!

Powered by Google App Engine
This is Rietveld 408576698