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

Side by Side Diff: media/cdm/player_tracker_impl.cc

Issue 308073004: Add PlayerTracker and BrowserCdm interfaces. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: comments addressed Created 6 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « media/cdm/player_tracker_impl.h ('k') | 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 "media/cdm/player_tracker_impl.h"
6
7 #include <utility>
8
9 #include "base/stl_util.h"
10
11 namespace media {
12
13 PlayerTrackerImpl::PlayerCallbacks::PlayerCallbacks(
14 base::Closure new_key_cb,
15 base::Closure cdm_unset_cb)
16 : new_key_cb(new_key_cb), cdm_unset_cb(cdm_unset_cb) {
17 }
18
19 PlayerTrackerImpl::PlayerCallbacks::~PlayerCallbacks() {
20 }
21
22 PlayerTrackerImpl::PlayerTrackerImpl() : next_registration_id_(1) {}
23
24 PlayerTrackerImpl::~PlayerTrackerImpl() {}
25
26 int PlayerTrackerImpl::RegisterPlayer(const base::Closure& new_key_cb,
27 const base::Closure& cdm_unset_cb) {
28 DCHECK(thread_checker_.CalledOnValidThread());
29 int registration_id = next_registration_id_++;
30 DCHECK(!ContainsKey(player_callbacks_map_, registration_id));
31 player_callbacks_map_.insert(std::make_pair(
32 registration_id, PlayerCallbacks(new_key_cb, cdm_unset_cb)));
33 return registration_id;
34 }
35
36 void PlayerTrackerImpl::UnregisterPlayer(int registration_id) {
37 DCHECK(thread_checker_.CalledOnValidThread());
38 DCHECK(ContainsKey(player_callbacks_map_, registration_id))
39 << registration_id;
40 player_callbacks_map_.erase(registration_id);
41 }
42
43 void PlayerTrackerImpl::NotifyNewKey() {
44 DCHECK(thread_checker_.CalledOnValidThread());
45 std::map<int, PlayerCallbacks>::iterator iter = player_callbacks_map_.begin();
46 for (; iter != player_callbacks_map_.end(); ++iter)
47 iter->second.new_key_cb.Run();
48 }
49
50 void PlayerTrackerImpl::NotifyCdmUnset() {
51 DCHECK(thread_checker_.CalledOnValidThread());
52 std::map<int, PlayerCallbacks>::iterator iter = player_callbacks_map_.begin();
53 for (; iter != player_callbacks_map_.end(); ++iter)
54 iter->second.cdm_unset_cb.Run();
55 }
56
57 } // namespace media
OLDNEW
« no previous file with comments | « media/cdm/player_tracker_impl.h ('k') | media/media.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698