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

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 dcheng'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(WebContentsImpl *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_.begin();
25 iter != players_map_.end();) {
26 MediaSession::Get(contents_)->RemovePlayer(
27 iter->second.get(), PepperPlayerDelegate::kPlayerId);
28 iter = players_map_.erase(iter);
29 }
30 }
31
32 void PepperPlaybackObserver::PepperInstanceCreated(int32_t pp_instance) {
33 }
34
35 void PepperPlaybackObserver::PepperInstanceDeleted(int32_t pp_instance) {
36 PepperStopsPlayback(pp_instance);
37 }
38
39 void PepperPlaybackObserver::PepperStartsPlayback(int32_t pp_instance) {
40 if (!base::FeatureList::IsEnabled(media::kFlashJoinsMediaSession))
41 return;
42
43 if (players_map_.count(pp_instance))
44 return;
45
46 players_map_[pp_instance].reset(new PepperPlayerDelegate(
47 contents_, pp_instance));
48 MediaSession::Get(contents_)->AddPlayer(
49 players_map_[pp_instance].get(),
50 PepperPlayerDelegate::kPlayerId,
51 MediaSession::Type::Content);
52 }
53
54 void PepperPlaybackObserver::PepperStopsPlayback(int32_t pp_instance) {
55 if (!players_map_.count(pp_instance))
56 return;
57
58 MediaSession::Get(contents_)->RemovePlayer(
59 players_map_[pp_instance].get(), PepperPlayerDelegate::kPlayerId);
60
61 players_map_.erase(pp_instance);
62 }
63
64 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/media/session/pepper_playback_observer.h ('k') | content/browser/media/session/pepper_player_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698