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

Issue 2441423002: Add MediaSessionObserver to allow clients observe MediaSession directly (Closed)

Created:
4 years, 1 month ago by Zhiqiang Zhang (Slow)
Modified:
4 years, 1 month ago
CC:
chromium-reviews, creis+watch_chromium.org, darin-cc_chromium.org, feature-media-reviews_chromium.org, nasko+codewatch_chromium.org
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

Add MediaSessionObserver to allow clients observe MediaSession directly This CL is part of a larger effort to decouple MediaSession with WebContents, which helps to avoid WebContents plumbing for MediaSession messages. The MediaSession is extracted as an interface in content/public/browser to allow non-content code to access MediaSession. A follow up of this CL is: https://codereview.chromium.org/2450433002/ The greater effort is described in doc: https://docs.google.com/a/chromium.org/document/d/1PfiCtOidmNrwsXcnpN7tCa_IkeHb5SJ73d5nwzxZYV8/edit?usp=sharing BUG=658678

Patch Set 1 #

Patch Set 2 : fixed Android build #

Total comments: 12

Patch Set 3 : really fixed Android build #

Patch Set 4 : nits #

Patch Set 5 : clean up observers when session is destroyed #

Patch Set 6 : addressed nits from jam@ #

Total comments: 3

Patch Set 7 : don't store session pointer in observer, remove StopObserving() #

Unified diffs Side-by-side diffs Delta from patch set Stats (+660 lines, -2962 lines) Patch
M content/browser/BUILD.gn View 1 2 3 4 5 6 1 chunk +2 lines, -2 lines 0 comments Download
M content/browser/media/session/audio_focus_delegate.h View 1 chunk +3 lines, -2 lines 0 comments Download
M content/browser/media/session/audio_focus_delegate_android.h View 2 chunks +2 lines, -2 lines 0 comments Download
M content/browser/media/session/audio_focus_delegate_android.cc View 1 3 chunks +3 lines, -2 lines 0 comments Download
M content/browser/media/session/audio_focus_delegate_android_browsertest.cc View 1 2 2 chunks +5 lines, -3 lines 0 comments Download
M content/browser/media/session/audio_focus_delegate_default.cc View 3 chunks +4 lines, -4 lines 0 comments Download
M content/browser/media/session/audio_focus_delegate_default_browsertest.cc View 1 2 3 4 5 3 chunks +6 lines, -5 lines 0 comments Download
M content/browser/media/session/audio_focus_manager.h View 3 chunks +5 lines, -5 lines 0 comments Download
M content/browser/media/session/audio_focus_manager.cc View 7 chunks +13 lines, -10 lines 0 comments Download
M content/browser/media/session/audio_focus_manager_unittest.cc View 22 chunks +60 lines, -37 lines 0 comments Download
D content/browser/media/session/media_session.h View 1 chunk +0 lines, -245 lines 0 comments Download
D content/browser/media/session/media_session.cc View 1 chunk +0 lines, -447 lines 0 comments Download
D content/browser/media/session/media_session_browsertest.cc View 1 chunk +0 lines, -1356 lines 0 comments Download
M content/browser/media/session/media_session_controller.h View 2 chunks +2 lines, -2 lines 0 comments Download
M content/browser/media/session/media_session_controller.cc View 2 chunks +3 lines, -2 lines 0 comments Download
M content/browser/media/session/media_session_controller_unittest.cc View 2 chunks +4 lines, -2 lines 0 comments Download
M content/browser/media/session/media_session_controllers_manager.cc View 1 chunk +0 lines, -1 line 0 comments Download
A + content/browser/media/session/media_session_impl.h View 1 2 3 9 chunks +47 lines, -49 lines 0 comments Download
A + content/browser/media/session/media_session_impl.cc View 5 6 15 chunks +75 lines, -54 lines 0 comments Download
A + content/browser/media/session/media_session_impl_browsertest.cc View 63 chunks +237 lines, -349 lines 0 comments Download
A + content/browser/media/session/media_session_impl_visibility_browsertest.cc View 8 chunks +55 lines, -58 lines 0 comments Download
M content/browser/media/session/media_session_service_impl.cc View 2 chunks +2 lines, -2 lines 0 comments Download
D content/browser/media/session/media_session_visibility_browsertest.cc View 1 chunk +0 lines, -310 lines 0 comments Download
M content/browser/media/session/pepper_playback_observer.cc View 3 chunks +5 lines, -5 lines 0 comments Download
M content/browser/web_contents/web_contents_impl.cc View 1 2 3 4 5 6 3 chunks +6 lines, -6 lines 0 comments Download
M content/public/browser/BUILD.gn View 1 2 3 1 chunk +3 lines, -0 lines 0 comments Download
A content/public/browser/media_session.h View 1 2 3 1 chunk +55 lines, -0 lines 0 comments Download
A content/public/browser/media_session_observer.h View 1 2 3 4 5 6 1 chunk +44 lines, -0 lines 0 comments Download
A content/public/browser/media_session_observer.cc View 1 2 3 4 5 6 1 chunk +17 lines, -0 lines 0 comments Download
M content/test/BUILD.gn View 1 2 3 4 5 6 1 chunk +2 lines, -2 lines 0 comments Download

Messages

Total messages: 27 (16 generated)
Zhiqiang Zhang (Slow)
4 years, 1 month ago (2016-10-24 15:06:29 UTC) #8
whywhat
I think you should upgrade the description to mention MediaSession interface extraction as this is ...
4 years, 1 month ago (2016-10-24 20:29:39 UTC) #11
jam
I'm having a hard time following how this simplifies thing. per https://www.chromium.org/developers/content-module/content-api, we don't add ...
4 years, 1 month ago (2016-10-25 00:30:30 UTC) #13
Zhiqiang Zhang (Slow)
On 2016/10/25 00:30:30, jam wrote: > I'm having a hard time following how this simplifies ...
4 years, 1 month ago (2016-10-25 10:18:37 UTC) #14
Zhiqiang Zhang (Slow)
On 2016/10/25 10:18:37, Zhiqiang Zhang wrote: > On 2016/10/25 00:30:30, jam wrote: > > I'm ...
4 years, 1 month ago (2016-10-25 10:22:24 UTC) #15
whywhat
lgtm % nits + the important comment about MSO handling MediaSessionDestroyed.
4 years, 1 month ago (2016-10-25 19:22:43 UTC) #18
Zhiqiang Zhang (Slow)
PTAL for jam@ (please note my previous replies for explaining this CL) Addressed nits from ...
4 years, 1 month ago (2016-10-25 19:51:43 UTC) #19
jam
On 2016/10/25 10:22:24, Zhiqiang Zhang wrote: > On 2016/10/25 10:18:37, Zhiqiang Zhang wrote: > > ...
4 years, 1 month ago (2016-10-25 21:34:28 UTC) #20
Zhiqiang Zhang (Slow)
On 2016/10/25 21:34:28, jam wrote: > For me to understand this change, I'm going to ...
4 years, 1 month ago (2016-10-26 12:42:13 UTC) #21
whywhat
https://codereview.chromium.org/2441423002/diff/100001/content/browser/media/session/media_session_impl.cc File content/browser/media/session/media_session_impl.cc (right): https://codereview.chromium.org/2441423002/diff/100001/content/browser/media/session/media_session_impl.cc#newcode66 content/browser/media/session/media_session_impl.cc:66: observer.MediaSessionDestroyed(); Would MediaSessionDestroyed and StopObserving not called one after ...
4 years, 1 month ago (2016-10-28 19:19:10 UTC) #22
Zhiqiang Zhang (Slow)
4 years, 1 month ago (2016-10-28 21:15:24 UTC) #23
On 2016/10/28 19:19:10, whywhat wrote:
>
https://codereview.chromium.org/2441423002/diff/100001/content/browser/media/...
> File content/browser/media/session/media_session_impl.cc (right):
> 
>
https://codereview.chromium.org/2441423002/diff/100001/content/browser/media/...
> content/browser/media/session/media_session_impl.cc:66:
> observer.MediaSessionDestroyed();
> Would MediaSessionDestroyed and StopObserving not called one after another all
> the time?
> What I suggested was:
> 
> class MediaSessionObserver {
>  public:
>   void MediaSessionDestroyed() {
>     OnMediaSessionDestroyed();
>     session_->RemoveObserver(this);
>     session_ = nullptr;
>   }
> 
>   virtual void OnMediaSessionDestroyed() = 0; 
> }
> 
> class Foo : public MediaSessionObserver {
>   void OnMediaSessionDestroyed() override {
>     ...
>   }
> }
> 
> You can make OnMediaSessionDestroyed() private in MSO to prevent it to be
called
> by anything but MSO.
> 
>
https://codereview.chromium.org/2441423002/diff/100001/content/public/browser...
> File content/public/browser/media_session_observer.cc (right):
> 
>
https://codereview.chromium.org/2441423002/diff/100001/content/public/browser...
> content/public/browser/media_session_observer.cc:27: if (session_)
> This should never be null.
> 
>
https://codereview.chromium.org/2441423002/diff/100001/content/public/browser...
> File content/public/browser/media_session_observer.h (right):
> 
>
https://codereview.chromium.org/2441423002/diff/100001/content/public/browser...
> content/public/browser/media_session_observer.h:46: friend class
> MediaSessionImpl;
> This class is not part of content/public so should not be mentioned here. See
my
> comment above for how to solve this.

Seems like both content/ and content/public/android reviewers don't like storing
MediaSession* in the observer.
Now I totally removed that and we'll let the users take the responsibility to
store MediaSession* and do clean up themselves.

Powered by Google App Engine
This is Rietveld 408576698