| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #ifndef CONTENT_BROWSER_MEDIA_MEDIA_WEB_CONTENTS_OBSERVER_H_ | 5 #ifndef CONTENT_BROWSER_MEDIA_MEDIA_WEB_CONTENTS_OBSERVER_H_ |
| 6 #define CONTENT_BROWSER_MEDIA_MEDIA_WEB_CONTENTS_OBSERVER_H_ | 6 #define CONTENT_BROWSER_MEDIA_MEDIA_WEB_CONTENTS_OBSERVER_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <map> | 10 #include <map> |
| 11 #include <set> | 11 #include <set> |
| 12 #include <vector> | |
| 13 | 12 |
| 14 #include "base/macros.h" | 13 #include "base/macros.h" |
| 15 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
| 16 #include "content/common/content_export.h" | 15 #include "content/common/content_export.h" |
| 17 #include "content/public/browser/web_contents_observer.h" | 16 #include "content/public/browser/web_contents_observer.h" |
| 18 | 17 |
| 19 namespace content { | 18 namespace content { |
| 20 class PowerSaveBlocker; | 19 class PowerSaveBlocker; |
| 21 | 20 |
| 22 // This class manages all RenderFrame based media related managers at the | 21 // This class manages all RenderFrame based media related managers at the |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 // Creates an audio or video power save blocker respectively. | 64 // Creates an audio or video power save blocker respectively. |
| 66 void CreateAudioPowerSaveBlocker(); | 65 void CreateAudioPowerSaveBlocker(); |
| 67 void CreateVideoPowerSaveBlocker(); | 66 void CreateVideoPowerSaveBlocker(); |
| 68 | 67 |
| 69 // Releases the audio power save blockers if |active_audio_players_| is empty. | 68 // Releases the audio power save blockers if |active_audio_players_| is empty. |
| 70 // Likewise, releases the video power save blockers if |active_video_players_| | 69 // Likewise, releases the video power save blockers if |active_video_players_| |
| 71 // is empty. | 70 // is empty. |
| 72 void MaybeReleasePowerSaveBlockers(); | 71 void MaybeReleasePowerSaveBlockers(); |
| 73 | 72 |
| 74 // Helper methods for adding or removing player entries in |player_map|. | 73 // Helper methods for adding or removing player entries in |player_map|. |
| 75 using PlayerList = std::vector<int>; | 74 using PlayerSet = std::set<int>; |
| 76 using ActiveMediaPlayerMap = std::map<RenderFrameHost*, PlayerList>; | 75 using ActiveMediaPlayerMap = std::map<RenderFrameHost*, PlayerSet>; |
| 77 void AddMediaPlayerEntry(const MediaPlayerId& id, | 76 void AddMediaPlayerEntry(const MediaPlayerId& id, |
| 78 ActiveMediaPlayerMap* player_map); | 77 ActiveMediaPlayerMap* player_map); |
| 79 // Returns true if an entry is actually removed. | 78 // Returns true if an entry is actually removed. |
| 80 bool RemoveMediaPlayerEntry(const MediaPlayerId& id, | 79 bool RemoveMediaPlayerEntry(const MediaPlayerId& id, |
| 81 ActiveMediaPlayerMap* player_map); | 80 ActiveMediaPlayerMap* player_map); |
| 82 // Removes all entries from |player_map| for |render_frame_host|. Removed | 81 // Removes all entries from |player_map| for |render_frame_host|. Removed |
| 83 // entries are added to |removed_players|. | 82 // entries are added to |removed_players|. |
| 84 void RemoveAllMediaPlayerEntries(RenderFrameHost* render_frame_host, | 83 void RemoveAllMediaPlayerEntries(RenderFrameHost* render_frame_host, |
| 85 ActiveMediaPlayerMap* player_map, | 84 ActiveMediaPlayerMap* player_map, |
| 86 std::set<MediaPlayerId>* removed_players); | 85 std::set<MediaPlayerId>* removed_players); |
| 87 | 86 |
| 88 // Tracking variables and associated power save blockers for media playback. | 87 // Tracking variables and associated power save blockers for media playback. |
| 89 ActiveMediaPlayerMap active_audio_players_; | 88 ActiveMediaPlayerMap active_audio_players_; |
| 90 ActiveMediaPlayerMap active_video_players_; | 89 ActiveMediaPlayerMap active_video_players_; |
| 91 scoped_ptr<PowerSaveBlocker> audio_power_save_blocker_; | 90 scoped_ptr<PowerSaveBlocker> audio_power_save_blocker_; |
| 92 scoped_ptr<PowerSaveBlocker> video_power_save_blocker_; | 91 scoped_ptr<PowerSaveBlocker> video_power_save_blocker_; |
| 93 | 92 |
| 94 DISALLOW_COPY_AND_ASSIGN(MediaWebContentsObserver); | 93 DISALLOW_COPY_AND_ASSIGN(MediaWebContentsObserver); |
| 95 }; | 94 }; |
| 96 | 95 |
| 97 } // namespace content | 96 } // namespace content |
| 98 | 97 |
| 99 #endif // CONTENT_BROWSER_MEDIA_MEDIA_WEB_CONTENTS_OBSERVER_H_ | 98 #endif // CONTENT_BROWSER_MEDIA_MEDIA_WEB_CONTENTS_OBSERVER_H_ |
| OLD | NEW |