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

Unified Diff: media/cdm/player_tracker_impl.h

Issue 308073004: Add PlayerTracker and BrowserCdm interfaces. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: comments addressed Created 6 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « media/base/player_tracker.cc ('k') | media/cdm/player_tracker_impl.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/cdm/player_tracker_impl.h
diff --git a/media/cdm/player_tracker_impl.h b/media/cdm/player_tracker_impl.h
new file mode 100644
index 0000000000000000000000000000000000000000..bcbeaf8c3c2ac6b5a76a5c1ff4824b08a8b42b43
--- /dev/null
+++ b/media/cdm/player_tracker_impl.h
@@ -0,0 +1,54 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef MEDIA_CDM_PLAYER_TRACKER_IMPL_H_
+#define MEDIA_CDM_PLAYER_TRACKER_IMPL_H_
+
+#include <map>
+
+#include "base/basictypes.h"
+#include "base/callback.h"
+#include "base/threading/thread_checker.h"
+#include "media/base/media_export.h"
+#include "media/base/player_tracker.h"
+
+namespace media {
+
+// A common implementation that can be shared by different PlayerTracker
+// implementations. This class is not thread safe and should only be called
+// on one thread.
+class MEDIA_EXPORT PlayerTrackerImpl : public PlayerTracker {
+ public:
+ PlayerTrackerImpl();
+ virtual ~PlayerTrackerImpl();
+
+ // PlayerTracker implementation.
+ virtual int RegisterPlayer(const base::Closure& new_key_cb,
+ const base::Closure& cdm_unset_cb) OVERRIDE;
+ virtual void UnregisterPlayer(int registration_id) OVERRIDE;
+
+ // Helpers methods to fire registered callbacks.
+ void NotifyNewKey();
+ void NotifyCdmUnset();
+
+ private:
+ struct PlayerCallbacks {
+ PlayerCallbacks(base::Closure new_key_cb, base::Closure cdm_unset_cb);
+ ~PlayerCallbacks();
+
+ base::Closure new_key_cb;
+ base::Closure cdm_unset_cb;
+ };
+
+ int next_registration_id_;
+ std::map<int, PlayerCallbacks> player_callbacks_map_;
+
+ base::ThreadChecker thread_checker_;
+
+ DISALLOW_COPY_AND_ASSIGN(PlayerTrackerImpl);
+};
+
+} // namespace media
+
+#endif // MEDIA_CDM_PLAYER_TRACKER_IMPL_H_
« no previous file with comments | « media/base/player_tracker.cc ('k') | media/cdm/player_tracker_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698