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

Side by Side Diff: chrome/browser/media/android/remote/remote_media_player_manager.cc

Issue 1889233002: [Android,VideoFling] Never add null players to alternative ones (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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 | « no previous file | 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "chrome/browser/media/android/remote/remote_media_player_manager.h" 5 #include "chrome/browser/media/android/remote/remote_media_player_manager.h"
6 6
7 #include "chrome/browser/android/tab_android.h" 7 #include "chrome/browser/android/tab_android.h"
8 #include "chrome/common/chrome_content_client.h" 8 #include "chrome/common/chrome_content_client.h"
9 #include "content/common/media/media_player_messages_android.h" 9 #include "content/common/media/media_player_messages_android.h"
10 #include "third_party/skia/include/core/SkBitmap.h" 10 #include "third_party/skia/include/core/SkBitmap.h"
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 } 143 }
144 144
145 void RemoteMediaPlayerManager::SwapCurrentPlayer(int player_id) { 145 void RemoteMediaPlayerManager::SwapCurrentPlayer(int player_id) {
146 // Find the remote player 146 // Find the remote player
147 auto it = GetAlternativePlayer(player_id); 147 auto it = GetAlternativePlayer(player_id);
148 if (it == alternative_players_.end()) 148 if (it == alternative_players_.end())
149 return; 149 return;
150 MediaPlayerAndroid* new_player = *it; 150 MediaPlayerAndroid* new_player = *it;
151 std::unique_ptr<MediaPlayerAndroid> old_player = 151 std::unique_ptr<MediaPlayerAndroid> old_player =
152 SwapPlayer(player_id, new_player); 152 SwapPlayer(player_id, new_player);
153 if (!old_player)
dgn 2016/04/18 13:18:49 In which case can this be null? Is it safe to run
whywhat 2016/04/18 13:21:51 SwapPlayer doesn't do anything if it can't find th
aberent 2016/04/18 13:44:57 Is all this one line too high? It seems that this
whywhat 2016/04/18 14:54:45 Good point, remove and delete the alternative play
154 return;
155
153 alternative_players_.weak_erase(it); 156 alternative_players_.weak_erase(it);
154 alternative_players_.push_back(old_player.release()); 157 alternative_players_.push_back(old_player.release());
155 } 158 }
156 159
157 void RemoteMediaPlayerManager::SwitchToRemotePlayer( 160 void RemoteMediaPlayerManager::SwitchToRemotePlayer(
158 int player_id, 161 int player_id,
159 const std::string& casting_message) { 162 const std::string& casting_message) {
160 DCHECK(!IsPlayingRemotely(player_id)); 163 DCHECK(!IsPlayingRemotely(player_id));
161 SwapCurrentPlayer(player_id); 164 SwapCurrentPlayer(player_id);
162 players_playing_remotely_.insert(player_id); 165 players_playing_remotely_.insert(player_id);
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
268 MediaPlayerAndroid* local_player = GetLocalPlayer(player_id); 271 MediaPlayerAndroid* local_player = GetLocalPlayer(player_id);
269 Send(new MediaPlayerMsg_MediaMetadataChanged( 272 Send(new MediaPlayerMsg_MediaMetadataChanged(
270 RoutingID(), player_id, duration, local_player->GetVideoWidth(), 273 RoutingID(), player_id, duration, local_player->GetVideoWidth(),
271 local_player->GetVideoHeight(), success)); 274 local_player->GetVideoHeight(), success));
272 } else { 275 } else {
273 BrowserMediaPlayerManager::OnMediaMetadataChanged(player_id, duration, 276 BrowserMediaPlayerManager::OnMediaMetadataChanged(player_id, duration,
274 width, height, success); 277 width, height, success);
275 } 278 }
276 } 279 }
277 } // namespace remote_media 280 } // namespace remote_media
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698