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

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

Issue 741823004: Chromecast: extensions to the BrowserCdm interface. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 1 month 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 | « chromecast/media/cdm/browser_cdm_cast.h ('k') | chromecast/media/media.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "chromecast/media/cdm/browser_cdm_cast.h"
6
7 #include "base/callback.h"
8 #include "base/location.h"
9 #include "base/message_loop/message_loop_proxy.h"
10 #include "base/stl_util.h"
11
12 namespace chromecast {
13 namespace media {
14
15 BrowserCdmCast::BrowserCdmCast()
16 : next_registration_id_(1) {
17 }
18
19 BrowserCdmCast::~BrowserCdmCast() {
20 // Call unset callbacks synchronously.
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 }
29
30 int BrowserCdmCast::RegisterPlayer(const base::Closure& new_key_cb,
31 const base::Closure& cdm_unset_cb) {
32 int registration_id = next_registration_id_++;
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 }
41
42 void BrowserCdmCast::UnregisterPlayer(int registration_id) {
43 DCHECK(ContainsKey(new_key_callbacks_, 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 }
48
49 void BrowserCdmCast::NotifyKeyAdded() const {
50 for (std::map<uint32_t, base::Closure>::const_iterator it =
51 new_key_callbacks_.begin(); it != new_key_callbacks_.end(); ++it) {
52 base::MessageLoopProxy::current()->PostTask(FROM_HERE, it->second);
53 }
54 }
55
56 } // namespace media
57 } // namespace chromecast
OLDNEW
« no previous file with comments | « chromecast/media/cdm/browser_cdm_cast.h ('k') | chromecast/media/media.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698