OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 #ifndef MEDIA_MOJO_SERVICES_MOJO_CDM_SERVICE_CONTEXT_H_ | 5 #ifndef MEDIA_MOJO_SERVICES_MOJO_CDM_SERVICE_CONTEXT_H_ |
6 #define MEDIA_MOJO_SERVICES_MOJO_CDM_SERVICE_CONTEXT_H_ | 6 #define MEDIA_MOJO_SERVICES_MOJO_CDM_SERVICE_CONTEXT_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <map> | 10 #include <map> |
11 | 11 |
12 #include "base/macros.h" | 12 #include "base/macros.h" |
13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
14 #include "base/memory/weak_ptr.h" | 14 #include "base/memory/weak_ptr.h" |
15 #include "media/mojo/services/media_mojo_export.h" | 15 #include "media/mojo/services/media_mojo_export.h" |
16 | 16 |
17 namespace media { | 17 namespace media { |
18 | 18 |
19 class MediaKeys; | 19 class ContentDecryptionModule; |
20 class MojoCdmService; | 20 class MojoCdmService; |
21 | 21 |
22 // A class that creates, owns and manages all MojoCdmService instances. | 22 // A class that creates, owns and manages all MojoCdmService instances. |
23 class MEDIA_MOJO_EXPORT MojoCdmServiceContext { | 23 class MEDIA_MOJO_EXPORT MojoCdmServiceContext { |
24 public: | 24 public: |
25 MojoCdmServiceContext(); | 25 MojoCdmServiceContext(); |
26 ~MojoCdmServiceContext(); | 26 ~MojoCdmServiceContext(); |
27 | 27 |
28 base::WeakPtr<MojoCdmServiceContext> GetWeakPtr(); | 28 base::WeakPtr<MojoCdmServiceContext> GetWeakPtr(); |
29 | 29 |
30 // Registers The |cdm_service| with |cdm_id|. | 30 // Registers The |cdm_service| with |cdm_id|. |
31 void RegisterCdm(int cdm_id, MojoCdmService* cdm_service); | 31 void RegisterCdm(int cdm_id, MojoCdmService* cdm_service); |
32 | 32 |
33 // Unregisters the CDM. Must be called before the CDM is destroyed. | 33 // Unregisters the CDM. Must be called before the CDM is destroyed. |
34 void UnregisterCdm(int cdm_id); | 34 void UnregisterCdm(int cdm_id); |
35 | 35 |
36 // Returns the CDM associated with |cdm_id|. | 36 // Returns the CDM associated with |cdm_id|. |
37 scoped_refptr<MediaKeys> GetCdm(int cdm_id); | 37 scoped_refptr<ContentDecryptionModule> GetCdm(int cdm_id); |
38 | 38 |
39 private: | 39 private: |
40 // A map between CDM ID and MojoCdmService. | 40 // A map between CDM ID and MojoCdmService. |
41 std::map<int, MojoCdmService*> cdm_services_; | 41 std::map<int, MojoCdmService*> cdm_services_; |
42 | 42 |
43 // NOTE: Weak pointers must be invalidated before all other member variables. | 43 // NOTE: Weak pointers must be invalidated before all other member variables. |
44 base::WeakPtrFactory<MojoCdmServiceContext> weak_ptr_factory_; | 44 base::WeakPtrFactory<MojoCdmServiceContext> weak_ptr_factory_; |
45 | 45 |
46 DISALLOW_COPY_AND_ASSIGN(MojoCdmServiceContext); | 46 DISALLOW_COPY_AND_ASSIGN(MojoCdmServiceContext); |
47 }; | 47 }; |
48 | 48 |
49 } // namespace media | 49 } // namespace media |
50 | 50 |
51 #endif // MEDIA_MOJO_SERVICES_MOJO_CDM_SERVICE_CONTEXT_H_ | 51 #endif // MEDIA_MOJO_SERVICES_MOJO_CDM_SERVICE_CONTEXT_H_ |
OLD | NEW |