Chromium Code Reviews| Index: content/common/media/cdm_host_files.h |
| diff --git a/content/common/media/cdm_host_files.h b/content/common/media/cdm_host_files.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..25ce670025f9f6d8f9ff30263c01c71e63596a79 |
| --- /dev/null |
| +++ b/content/common/media/cdm_host_files.h |
| @@ -0,0 +1,96 @@ |
| +// Copyright 2016 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 CONTENT_COMMON_MEDIA_CDM_HOST_FILES_H_ |
| +#define CONTENT_COMMON_MEDIA_CDM_HOST_FILES_H_ |
| + |
| +#include <map> |
| +#include <memory> |
| +#include <vector> |
| + |
| +#include "base/files/file.h" |
| +#include "base/files/file_path.h" |
| +#include "base/lazy_instance.h" |
| +#include "base/logging.h" |
| +#include "base/memory/ptr_util.h" |
| +#include "base/native_library.h" |
| +#include "base/path_service.h" |
| +#include "build/build_config.h" |
| +#include "content/common/media/cdm_host_file.h" |
| +#include "content/common/pepper_plugin_list.h" |
| +#include "content/public/common/pepper_plugin_info.h" |
| +#include "media/cdm/cdm_paths.h" |
| +#include "media/cdm/content_decryption_module_ext.h" |
| + |
| +// On systems that use the zygote process to spawn child processes, we must |
| +// open files in the zygote process. |
| +#if defined(OS_POSIX) && !defined(OS_NACL) && !defined(OS_MACOSX) && \ |
|
Greg K
2016/12/16 22:10:41
Is it simpler to just say defined(OS_LINUX)? Do an
xhwang
2016/12/16 22:30:15
Good question. This was what I originally did. But
Greg K
2016/12/16 22:34:41
You're right. I looked at the definition of OS_POS
xhwang
2016/12/16 22:37:06
Does it make sense to have an official USE_ZYGOTE
Greg K
2017/01/09 21:45:15
We may want to define that flag but you probably d
xhwang
2017/01/12 20:15:02
okay, then I'll keep this as is.
|
| + !defined(OS_ANDROID) |
| +#define POSIX_WITH_ZYGOTE 1 |
| +#endif |
| + |
| +namespace base { |
| +class FilePath; |
| +} |
| + |
| +namespace content { |
| + |
| +// Manages all CDM host files. |
| +class CdmHostFiles { |
| + public: |
| + CdmHostFiles(); |
| + ~CdmHostFiles(); |
| + |
| +#if defined(POSIX_WITH_ZYGOTE) |
| + static void CreateGlobalInstance(); |
| + static std::unique_ptr<CdmHostFiles> TakeGlobalInstance(); |
| +#endif |
| + |
| + static std::unique_ptr<CdmHostFiles> Create( |
| + const base::FilePath& cdm_adapter_path); |
| + |
| + // Verifies |cdm_adapter_path| CDM files by calling VerifyCdmFiles() on the |
| + // CDM |library|. If unexpected error happens, all files will be closed. |
|
Greg K
2017/01/09 21:45:15
What do you mean by "calling VerifyCdmFiles() on t
xhwang
2017/01/12 20:15:02
oops, it should be "calling VerifyHostFiles() expo
xhwang
2017/01/18 06:03:59
Done.
|
| + // Otherwise, the PlatformFiles are passed to the CDM which will close the |
| + // files later. |
| + void VerifyFiles(base::NativeLibrary library, |
| + const base::FilePath& cdm_adapter_path); |
| + |
| + private: |
| +#if defined(POSIX_WITH_ZYGOTE) |
| + // Opens all common files and CDM specific files for all registered CDMs. |
| + bool OpenFilesForAllRegisteredCdms(); |
| +#endif |
| + |
| + // Opens all common files and CDM specific files for the CDM adapter |
| + // registered at |cdm_adapter_path|. |
| + bool OpenFiles(const base::FilePath& cdm_adapter_path); |
| + |
| + // Open common CDM host files shared by all CDMs. Upon failure, close all |
| + // files opened. |
| + bool OpenCommonFiles(); |
| + // Opens CDM specific files for the CDM adapter registered at |
|
Haoming Chen
2017/01/04 22:23:39
newline
xhwang
2017/01/12 20:15:02
Will do.
xhwang
2017/01/18 06:03:59
Done.
|
| + // |cdm_adapter_path|. Returns whether all CDM specific files are opened. |
| + // Upon failure, close all files opened. |
| + bool OpenCdmFiles(const base::FilePath& cdm_adapter_path); |
| + |
| + // Fills |cdm_host_files| with common and CDM specific files for |
| + // |cdm_adapter_path|. The ownership of those files are also transferred. |
| + // Returns true upon success where the remaining files will be closed. |
| + // Returns false upon any failure and all files will be closed. |
| + bool TakePlatformFiles(const base::FilePath& cdm_adapter_path, |
| + std::vector<cdm::CdmHostFile>* cdm_host_files); |
| + |
| + void CloseAllFiles(); |
| + |
| + using ScopedFileVector = std::vector<std::unique_ptr<CdmHostFile>>; |
| + ScopedFileVector common_files_; |
| + std::map<base::FilePath, ScopedFileVector> cdm_specific_files_map_; |
| +}; |
| + |
| +bool IsCdm(const base::FilePath& cdm_adapter_path); |
|
Haoming Chen
2017/01/04 22:23:38
Add some comments on this function.
xhwang
2017/01/12 20:15:02
Will do.
xhwang
2017/01/18 06:03:59
Done.
|
| + |
| +} // namespace content |
| + |
| +#endif // CONTENT_COMMON_MEDIA_CDM_HOST_FILES_H_ |