| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/android/media_player_manager_android.h" | 5 #include "content/browser/android/media_player_manager_android.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "content/browser/android/cookie_getter_impl.h" | 8 #include "content/browser/android/media_resource_getter_impl.h" |
| 9 #include "content/common/media/media_player_messages.h" | 9 #include "content/common/media/media_player_messages.h" |
| 10 #include "content/public/browser/browser_context.h" | 10 #include "content/public/browser/browser_context.h" |
| 11 #include "content/public/browser/render_process_host.h" | 11 #include "content/public/browser/render_process_host.h" |
| 12 #include "content/public/browser/render_view_host.h" | 12 #include "content/public/browser/render_view_host.h" |
| 13 #include "content/public/browser/storage_partition.h" |
| 13 | 14 |
| 14 using media::MediaPlayerBridge; | 15 using media::MediaPlayerBridge; |
| 15 | 16 |
| 16 // Threshold on the number of media players per renderer before we start | 17 // Threshold on the number of media players per renderer before we start |
| 17 // attempting to release inactive media players. | 18 // attempting to release inactive media players. |
| 18 static const int kMediaPlayerThreshold = 1; | 19 static const int kMediaPlayerThreshold = 1; |
| 19 | 20 |
| 20 namespace content { | 21 namespace content { |
| 21 | 22 |
| 22 MediaPlayerManagerAndroid::MediaPlayerManagerAndroid( | 23 MediaPlayerManagerAndroid::MediaPlayerManagerAndroid( |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 for (ScopedVector<MediaPlayerBridge>::iterator it = players_.begin(); | 100 for (ScopedVector<MediaPlayerBridge>::iterator it = players_.begin(); |
| 100 it != players_.end(); ++it) { | 101 it != players_.end(); ++it) { |
| 101 if ((*it)->player_id() == player_id) { | 102 if ((*it)->player_id() == player_id) { |
| 102 players_.erase(it); | 103 players_.erase(it); |
| 103 break; | 104 break; |
| 104 } | 105 } |
| 105 } | 106 } |
| 106 | 107 |
| 107 RenderProcessHost* host = render_view_host()->GetProcess(); | 108 RenderProcessHost* host = render_view_host()->GetProcess(); |
| 108 BrowserContext* context = host->GetBrowserContext(); | 109 BrowserContext* context = host->GetBrowserContext(); |
| 110 StoragePartition* partition = host->GetStoragePartition(); |
| 111 fileapi::FileSystemContext* file_system_context = |
| 112 partition ? partition->GetFileSystemContext() : NULL; |
| 109 players_.push_back(new MediaPlayerBridge( | 113 players_.push_back(new MediaPlayerBridge( |
| 110 player_id, url, first_party_for_cookies, | 114 player_id, url, first_party_for_cookies, |
| 111 new CookieGetterImpl(context, host->GetID(), routing_id()), | 115 new MediaResourceGetterImpl(context, file_system_context, host->GetID(), |
| 116 routing_id()), |
| 112 context->IsOffTheRecord(), this, | 117 context->IsOffTheRecord(), this, |
| 113 base::Bind(&MediaPlayerManagerAndroid::OnError, base::Unretained(this)), | 118 base::Bind(&MediaPlayerManagerAndroid::OnError, base::Unretained(this)), |
| 114 base::Bind(&MediaPlayerManagerAndroid::OnVideoSizeChanged, | 119 base::Bind(&MediaPlayerManagerAndroid::OnVideoSizeChanged, |
| 115 base::Unretained(this)), | 120 base::Unretained(this)), |
| 116 base::Bind(&MediaPlayerManagerAndroid::OnBufferingUpdate, | 121 base::Bind(&MediaPlayerManagerAndroid::OnBufferingUpdate, |
| 117 base::Unretained(this)), | 122 base::Unretained(this)), |
| 118 base::Bind(&MediaPlayerManagerAndroid::OnPrepared, | 123 base::Bind(&MediaPlayerManagerAndroid::OnPrepared, |
| 119 base::Unretained(this)), | 124 base::Unretained(this)), |
| 120 base::Bind(&MediaPlayerManagerAndroid::OnPlaybackComplete, | 125 base::Bind(&MediaPlayerManagerAndroid::OnPlaybackComplete, |
| 121 base::Unretained(this)), | 126 base::Unretained(this)), |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 292 } | 297 } |
| 293 } | 298 } |
| 294 } | 299 } |
| 295 | 300 |
| 296 void MediaPlayerManagerAndroid::ReleaseMediaResources( | 301 void MediaPlayerManagerAndroid::ReleaseMediaResources( |
| 297 MediaPlayerBridge* player) { | 302 MediaPlayerBridge* player) { |
| 298 // Nothing needs to be done. | 303 // Nothing needs to be done. |
| 299 } | 304 } |
| 300 | 305 |
| 301 } // namespace content | 306 } // namespace content |
| OLD | NEW |