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 | 16 |
16 namespace media { | 17 namespace media { |
17 | 18 |
18 class MediaKeys; | 19 class MediaKeys; |
19 class MojoCdmService; | 20 class MojoCdmService; |
20 | 21 |
21 // A class that creates, owns and manages all MojoCdmService instances. | 22 // A class that creates, owns and manages all MojoCdmService instances. |
22 class MojoCdmServiceContext { | 23 class MEDIA_MOJO_EXPORT MojoCdmServiceContext { |
23 public: | 24 public: |
24 MojoCdmServiceContext(); | 25 MojoCdmServiceContext(); |
25 ~MojoCdmServiceContext(); | 26 ~MojoCdmServiceContext(); |
26 | 27 |
27 base::WeakPtr<MojoCdmServiceContext> GetWeakPtr(); | 28 base::WeakPtr<MojoCdmServiceContext> GetWeakPtr(); |
28 | 29 |
29 // Registers The |cdm_service| with |cdm_id|. | 30 // Registers The |cdm_service| with |cdm_id|. |
30 void RegisterCdm(int cdm_id, MojoCdmService* cdm_service); | 31 void RegisterCdm(int cdm_id, MojoCdmService* cdm_service); |
31 | 32 |
32 // Unregisters the CDM. Must be called before the CDM is destroyed. | 33 // Unregisters the CDM. Must be called before the CDM is destroyed. |
33 void UnregisterCdm(int cdm_id); | 34 void UnregisterCdm(int cdm_id); |
34 | 35 |
35 // Returns the CDM associated with |cdm_id|. | 36 // Returns the CDM associated with |cdm_id|. |
36 scoped_refptr<MediaKeys> GetCdm(int cdm_id); | 37 scoped_refptr<MediaKeys> GetCdm(int cdm_id); |
37 | 38 |
38 private: | 39 private: |
39 // A map between CDM ID and MojoCdmService. | 40 // A map between CDM ID and MojoCdmService. |
40 std::map<int, MojoCdmService*> cdm_services_; | 41 std::map<int, MojoCdmService*> cdm_services_; |
41 | 42 |
42 // NOTE: Weak pointers must be invalidated before all other member variables. | 43 // NOTE: Weak pointers must be invalidated before all other member variables. |
43 base::WeakPtrFactory<MojoCdmServiceContext> weak_ptr_factory_; | 44 base::WeakPtrFactory<MojoCdmServiceContext> weak_ptr_factory_; |
44 | 45 |
45 DISALLOW_COPY_AND_ASSIGN(MojoCdmServiceContext); | 46 DISALLOW_COPY_AND_ASSIGN(MojoCdmServiceContext); |
46 }; | 47 }; |
47 | 48 |
48 } // namespace media | 49 } // namespace media |
49 | 50 |
50 #endif // MEDIA_MOJO_SERVICES_MOJO_CDM_SERVICE_CONTEXT_H_ | 51 #endif // MEDIA_MOJO_SERVICES_MOJO_CDM_SERVICE_CONTEXT_H_ |
OLD | NEW |