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

Side by Side Diff: content/browser/media/session/pepper_playback_observer.cc

Issue 2060933002: Let Flash join and be controlled by media session (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@pepper_to_contents
Patch Set: addressed Jochen's comments Created 4 years, 5 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "content/browser/media/session/pepper_playback_observer.h"
6
7 #include "base/feature_list.h"
8 #include "content/browser/media/session/media_session.h"
9 #include "content/browser/media/session/pepper_player_delegate.h"
10 #include "content/common/frame_messages.h"
11 #include "ipc/ipc_message_macros.h"
12 #include "media/base/media_switches.h"
13
14 namespace content {
15
16 PepperPlaybackObserver::PepperPlaybackObserver(WebContents *contents)
17 : contents_(contents) {}
18
19 PepperPlaybackObserver::~PepperPlaybackObserver() {
20 // At this point WebContents is being destructed, so it's safe to
21 // call this. MediaSession may decide to send further IPC messages
22 // through PepperPlayerDelegates, which might be declined if the
23 // RenderViewHost has been destroyed.
24 for (PlayersMap::iterator iter(&players_map_);
25 !iter.IsAtEnd(); iter.Advance())
26 PepperStopsPlayback(iter.GetCurrentKey());
mlamouri (slow - plz ping) 2016/06/30 11:01:18 style: can you wrap this into { }
Zhiqiang Zhang (Slow) 2016/06/30 12:46:54 Done.
27 contents_ = nullptr;
28 }
29
30 void PepperPlaybackObserver::PepperInstanceCreated(int32_t pp_instance) {
31 }
32
33 void PepperPlaybackObserver::PepperInstanceDeleted(int32_t pp_instance) {
34 PepperStopsPlayback(pp_instance);
35 }
36
37 void PepperPlaybackObserver::PepperStartsPlayback(int32_t pp_instance) {
38 if (!base::FeatureList::IsEnabled(media::kFlashJoinsMediaSession))
39 return;
40
41 if (players_map_.Lookup(pp_instance))
42 return;
43
44 players_map_.AddWithID(new PepperPlayerDelegate(
dcheng 2016/06/30 07:02:39 Would an ordinary std::map work here? It doesn't s
Zhiqiang Zhang (Slow) 2016/06/30 12:46:54 Actually it was suggested by jochen. IDMap allows
dcheng 2016/07/01 05:57:59 I just don't see much of a point to using IDMap he
Zhiqiang Zhang (Slow) 2016/07/01 11:01:06 OK, I agree with you. changed to std::map. But one
45 static_cast<WebContentsImpl*>(contents_), pp_instance), pp_instance);
46 MediaSession::Get(contents_)->AddPlayer(
47 players_map_.Lookup(pp_instance), 0, MediaSession::Type::Content);
dcheng 2016/06/30 07:02:39 Perhaps make 0 a constant so it's clear this is th
Zhiqiang Zhang (Slow) 2016/06/30 12:46:54 Done.
48 }
49
50 void PepperPlaybackObserver::PepperStopsPlayback(int32_t pp_instance) {
51 if (!players_map_.Lookup(pp_instance))
52 return;
53
54 MediaSession::Get(contents_)->RemovePlayer(
55 players_map_.Lookup(pp_instance), 0);
56
57 players_map_.Remove(pp_instance);
58 }
59
60 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698