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

Side by Side Diff: chromecast/media/cdm/browser_cdm_cast.cc

Issue 835963005: Chromecast: use PlayerTrackerImpl in BrowserCdmCast. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 11 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
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 "chromecast/media/cdm/browser_cdm_cast.h" 5 #include "chromecast/media/cdm/browser_cdm_cast.h"
6 6
7 #include "base/bind.h"
7 #include "base/callback.h" 8 #include "base/callback.h"
8 #include "base/location.h" 9 #include "base/location.h"
9 #include "base/message_loop/message_loop_proxy.h" 10 #include "base/message_loop/message_loop_proxy.h"
lcwu1 2015/01/08 18:25:17 No longer needed.
gunsch 2015/01/08 18:34:46 Done.
10 #include "base/stl_util.h" 11 #include "base/stl_util.h"
11 12
12 namespace chromecast { 13 namespace chromecast {
13 namespace media { 14 namespace media {
14 15
15 BrowserCdmCast::BrowserCdmCast() 16 BrowserCdmCast::BrowserCdmCast() {
16 : next_registration_id_(1) {
17 } 17 }
18 18
19 BrowserCdmCast::~BrowserCdmCast() { 19 BrowserCdmCast::~BrowserCdmCast() {
20 // Call unset callbacks synchronously. 20 player_tracker_.NotifyCdmUnset();
21 for (std::map<uint32_t, base::Closure>::const_iterator it =
22 cdm_unset_callbacks_.begin(); it != cdm_unset_callbacks_.end(); ++it) {
23 it->second.Run();
24 }
25
26 new_key_callbacks_.clear();
27 cdm_unset_callbacks_.clear();
28 } 21 }
29 22
30 int BrowserCdmCast::RegisterPlayer(const base::Closure& new_key_cb, 23 int BrowserCdmCast::RegisterPlayer(const base::Closure& new_key_cb,
31 const base::Closure& cdm_unset_cb) { 24 const base::Closure& cdm_unset_cb) {
32 int registration_id = next_registration_id_++; 25 return player_tracker_.RegisterPlayer(new_key_cb, cdm_unset_cb);
33 DCHECK(!new_key_cb.is_null());
34 DCHECK(!cdm_unset_cb.is_null());
35 DCHECK(!ContainsKey(new_key_callbacks_, registration_id));
36 DCHECK(!ContainsKey(cdm_unset_callbacks_, registration_id));
37 new_key_callbacks_[registration_id] = new_key_cb;
38 cdm_unset_callbacks_[registration_id] = cdm_unset_cb;
39 return registration_id;
40 } 26 }
41 27
42 void BrowserCdmCast::UnregisterPlayer(int registration_id) { 28 void BrowserCdmCast::UnregisterPlayer(int registration_id) {
43 DCHECK(ContainsKey(new_key_callbacks_, registration_id)); 29 player_tracker_.UnregisterPlayer(registration_id);
44 DCHECK(ContainsKey(cdm_unset_callbacks_, registration_id));
45 new_key_callbacks_.erase(registration_id);
46 cdm_unset_callbacks_.erase(registration_id);
47 } 30 }
48 31
49 void BrowserCdmCast::NotifyKeyAdded() const { 32 void BrowserCdmCast::NotifyKeyAdded() {
50 for (std::map<uint32_t, base::Closure>::const_iterator it = 33 player_tracker_.NotifyNewKey();
51 new_key_callbacks_.begin(); it != new_key_callbacks_.end(); ++it) {
52 base::MessageLoopProxy::current()->PostTask(FROM_HERE, it->second);
53 }
54 } 34 }
55 35
56 } // namespace media 36 } // namespace media
57 } // namespace chromecast 37 } // namespace chromecast
OLDNEW
« chromecast/media/cdm/browser_cdm_cast.h ('K') | « chromecast/media/cdm/browser_cdm_cast.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698