OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 CONTENT_COMMON_MEDIA_CDM_HOST_FILES_H_ | 5 #ifndef CONTENT_COMMON_MEDIA_CDM_HOST_FILES_H_ |
6 #define CONTENT_COMMON_MEDIA_CDM_HOST_FILES_H_ | 6 #define CONTENT_COMMON_MEDIA_CDM_HOST_FILES_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <memory> | 9 #include <memory> |
10 #include <vector> | 10 #include <vector> |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 // files later. | 65 // files later. |
66 // Only returns false if the CDM returns false (when there's an immediate | 66 // Only returns false if the CDM returns false (when there's an immediate |
67 // failure). Otherwise always returns true for backward compatibility, e.g. | 67 // failure). Otherwise always returns true for backward compatibility, e.g. |
68 // when using an old CDM which doesn't implement the verification API. | 68 // when using an old CDM which doesn't implement the verification API. |
69 bool VerifyFiles(base::NativeLibrary cdm_adapter_library, | 69 bool VerifyFiles(base::NativeLibrary cdm_adapter_library, |
70 const base::FilePath& cdm_adapter_path); | 70 const base::FilePath& cdm_adapter_path); |
71 | 71 |
72 private: | 72 private: |
73 #if defined(POSIX_WITH_ZYGOTE) | 73 #if defined(POSIX_WITH_ZYGOTE) |
74 // Opens all common files and CDM specific files for all registered CDMs. | 74 // Opens all common files and CDM specific files for all registered CDMs. |
75 void OpenFilesForAllRegisteredCdms(); | 75 bool OpenFilesForAllRegisteredCdms(); |
76 #endif | 76 #endif |
77 | 77 |
78 // Opens all common files and CDM specific files for the CDM adapter | 78 // Opens all common files and CDM specific files for the CDM adapter |
79 // registered at |cdm_adapter_path|. | 79 // registered at |cdm_adapter_path|. |
80 void OpenFiles(const base::FilePath& cdm_adapter_path); | 80 bool OpenFiles(const base::FilePath& cdm_adapter_path); |
81 | 81 |
82 // Opens common CDM host files shared by all CDMs. | 82 // Opens common CDM host files shared by all CDMs. Upon failure, close all |
83 void OpenCommonFiles(); | 83 // files opened. |
| 84 bool OpenCommonFiles(); |
84 | 85 |
85 // Opens CDM specific files for the CDM adapter registered at | 86 // Opens CDM specific files for the CDM adapter registered at |
86 // |cdm_adapter_path|. | 87 // |cdm_adapter_path|. Returns whether all CDM specific files are opened. |
87 void OpenCdmFiles(const base::FilePath& cdm_adapter_path); | 88 // Upon failure, close all files opened. |
| 89 bool OpenCdmFiles(const base::FilePath& cdm_adapter_path); |
88 | 90 |
89 // Fills |cdm_host_files| with common and CDM specific files for | 91 // Fills |cdm_host_files| with common and CDM specific files for |
90 // |cdm_adapter_path|. The ownership of those files are also transferred. | 92 // |cdm_adapter_path|. The ownership of those files are also transferred. |
91 void TakePlatformFiles(const base::FilePath& cdm_adapter_path, | 93 // Returns true upon success where the remaining files will be closed. |
| 94 // Returns false upon any failure and all files will be closed. |
| 95 bool TakePlatformFiles(const base::FilePath& cdm_adapter_path, |
92 std::vector<cdm::HostFile>* cdm_host_files); | 96 std::vector<cdm::HostFile>* cdm_host_files); |
93 | 97 |
94 void CloseAllFiles(); | 98 void CloseAllFiles(); |
95 | 99 |
96 using ScopedFileVector = std::vector<std::unique_ptr<CdmHostFile>>; | 100 using ScopedFileVector = std::vector<std::unique_ptr<CdmHostFile>>; |
97 ScopedFileVector common_files_; | 101 ScopedFileVector common_files_; |
98 std::map<base::FilePath, ScopedFileVector> cdm_specific_files_map_; | 102 std::map<base::FilePath, ScopedFileVector> cdm_specific_files_map_; |
99 }; | 103 }; |
100 | 104 |
101 // Returns whether the |cdm_adapter_path| corresponds to a known CDM. | 105 // Returns whether the |cdm_adapter_path| corresponds to a known CDM. |
102 bool IsCdm(const base::FilePath& cdm_adapter_path); | 106 bool IsCdm(const base::FilePath& cdm_adapter_path); |
103 | 107 |
104 } // namespace content | 108 } // namespace content |
105 | 109 |
106 #endif // CONTENT_COMMON_MEDIA_CDM_HOST_FILES_H_ | 110 #endif // CONTENT_COMMON_MEDIA_CDM_HOST_FILES_H_ |
OLD | NEW |