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

Side by Side Diff: content/browser/media/media_web_contents_observer.cc

Issue 1821753002: media: Allow WMPI to send playing started notification while playing (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2661
Patch Set: Created 4 years, 9 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
« no previous file with comments | « content/browser/media/media_web_contents_observer.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include "content/browser/media/media_web_contents_observer.h" 5 #include "content/browser/media/media_web_contents_observer.h"
6 6
7 #include "base/lazy_instance.h" 7 #include "base/lazy_instance.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "build/build_config.h" 9 #include "build/build_config.h"
10 #include "content/browser/media/audible_metrics.h" 10 #include "content/browser/media/audible_metrics.h"
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 } 192 }
193 193
194 // If there are no more video players, clear the video power save blocker. 194 // If there are no more video players, clear the video power save blocker.
195 if (active_video_players_.empty()) 195 if (active_video_players_.empty())
196 video_power_save_blocker_.reset(); 196 video_power_save_blocker_.reset();
197 } 197 }
198 198
199 void MediaWebContentsObserver::AddMediaPlayerEntry( 199 void MediaWebContentsObserver::AddMediaPlayerEntry(
200 const MediaPlayerId& id, 200 const MediaPlayerId& id,
201 ActiveMediaPlayerMap* player_map) { 201 ActiveMediaPlayerMap* player_map) {
202 DCHECK(std::find((*player_map)[id.first].begin(), 202 (*player_map)[id.first].insert(id.second);
203 (*player_map)[id.first].end(),
204 id.second) == (*player_map)[id.first].end());
205 (*player_map)[id.first].push_back(id.second);
206 } 203 }
207 204
208 bool MediaWebContentsObserver::RemoveMediaPlayerEntry( 205 bool MediaWebContentsObserver::RemoveMediaPlayerEntry(
209 const MediaPlayerId& id, 206 const MediaPlayerId& id,
210 ActiveMediaPlayerMap* player_map) { 207 ActiveMediaPlayerMap* player_map) {
211 auto it = player_map->find(id.first); 208 auto it = player_map->find(id.first);
212 if (it == player_map->end()) 209 if (it == player_map->end())
213 return false; 210 return false;
214 211
215 // Remove the player. 212 // Remove the player.
216 auto player_for_removal = 213 bool did_remove = it->second.erase(id.second) == 1;
217 std::remove(it->second.begin(), it->second.end(), id.second); 214 if (!did_remove)
218 if (player_for_removal == it->second.end())
219 return false; 215 return false;
220 it->second.erase(player_for_removal);
221 216
222 // If there are no players left, remove the map entry. 217 // If there are no players left, remove the map entry.
223 if (it->second.empty()) 218 if (it->second.empty())
224 player_map->erase(it); 219 player_map->erase(it);
225 220
226 return true; 221 return true;
227 } 222 }
228 223
229 void MediaWebContentsObserver::RemoveAllMediaPlayerEntries( 224 void MediaWebContentsObserver::RemoveAllMediaPlayerEntries(
230 RenderFrameHost* render_frame_host, 225 RenderFrameHost* render_frame_host,
231 ActiveMediaPlayerMap* player_map, 226 ActiveMediaPlayerMap* player_map,
232 std::set<MediaPlayerId>* removed_players) { 227 std::set<MediaPlayerId>* removed_players) {
233 auto it = player_map->find(render_frame_host); 228 auto it = player_map->find(render_frame_host);
234 if (it == player_map->end()) 229 if (it == player_map->end())
235 return; 230 return;
236 231
237 for (int delegate_id : it->second) 232 for (int delegate_id : it->second)
238 removed_players->insert(MediaPlayerId(render_frame_host, delegate_id)); 233 removed_players->insert(MediaPlayerId(render_frame_host, delegate_id));
239 234
240 player_map->erase(it); 235 player_map->erase(it);
241 } 236 }
242 237
243 } // namespace content 238 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/media/media_web_contents_observer.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698