OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "content/browser/media/session/media_session_impl.h" | 5 #include "content/browser/media/session/media_session_impl.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include "content/browser/media/session/audio_focus_delegate.h" | 8 #include "content/browser/media/session/audio_focus_delegate.h" |
9 #include "content/browser/media/session/media_session_controller.h" | 9 #include "content/browser/media/session/media_session_controller.h" |
10 #include "content/browser/media/session/media_session_player_observer.h" | 10 #include "content/browser/media/session/media_session_player_observer.h" |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 session->Initialize(); | 86 session->Initialize(); |
87 } | 87 } |
88 return session; | 88 return session; |
89 } | 89 } |
90 | 90 |
91 MediaSessionImpl::~MediaSessionImpl() { | 91 MediaSessionImpl::~MediaSessionImpl() { |
92 DCHECK(normal_players_.empty()); | 92 DCHECK(normal_players_.empty()); |
93 DCHECK(pepper_players_.empty()); | 93 DCHECK(pepper_players_.empty()); |
94 DCHECK(one_shot_players_.empty()); | 94 DCHECK(one_shot_players_.empty()); |
95 DCHECK(audio_focus_state_ == State::INACTIVE); | 95 DCHECK(audio_focus_state_ == State::INACTIVE); |
96 for (auto& observer : observers_) | 96 for (auto& observer : observers_) { |
97 observer.MediaSessionDestroyed(); | 97 observer.MediaSessionDestroyed(); |
| 98 observer.StopObserving(); |
| 99 } |
98 } | 100 } |
99 | 101 |
100 void MediaSessionImpl::WebContentsDestroyed() { | 102 void MediaSessionImpl::WebContentsDestroyed() { |
101 // This should only work for tests. In production, all the players should have | 103 // This should only work for tests. In production, all the players should have |
102 // already been removed before WebContents is destroyed. | 104 // already been removed before WebContents is destroyed. |
103 | 105 |
104 // TODO(zqzhang): refactor MediaSessionImpl, maybe move the interface used to | 106 // TODO(zqzhang): refactor MediaSessionImpl, maybe move the interface used to |
105 // talk with AudioFocusManager out to a seperate class. The AudioFocusManager | 107 // talk with AudioFocusManager out to a seperate class. The AudioFocusManager |
106 // unit tests then could mock the interface and abandon audio focus when | 108 // unit tests then could mock the interface and abandon audio focus when |
107 // WebContents is destroyed. See https://crbug.com/651069 | 109 // WebContents is destroyed. See https://crbug.com/651069 |
(...skipping 614 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
722 if (!IsServiceActiveForRenderFrameHost(frame)) | 724 if (!IsServiceActiveForRenderFrameHost(frame)) |
723 continue; | 725 continue; |
724 best_frame = frame; | 726 best_frame = frame; |
725 min_depth = depth; | 727 min_depth = depth; |
726 } | 728 } |
727 | 729 |
728 return best_frame ? services_[best_frame] : nullptr; | 730 return best_frame ? services_[best_frame] : nullptr; |
729 } | 731 } |
730 | 732 |
731 } // namespace content | 733 } // namespace content |
OLD | NEW |