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

Side by Side Diff: content/common/media/cdm_host_files.h

Issue 2582463003: media: Verify CDM Host files (Closed)
Patch Set: Created 4 years 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 unified diff | Download patch
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef CONTENT_COMMON_MEDIA_CDM_HOST_FILES_H_
6 #define CONTENT_COMMON_MEDIA_CDM_HOST_FILES_H_
7
8 #include <map>
9 #include <memory>
10 #include <vector>
11
12 #include "base/files/file.h"
13 #include "base/files/file_path.h"
14 #include "base/lazy_instance.h"
15 #include "base/logging.h"
16 #include "base/memory/ptr_util.h"
17 #include "base/native_library.h"
18 #include "base/path_service.h"
19 #include "build/build_config.h"
20 #include "content/common/media/cdm_host_file.h"
21 #include "content/common/pepper_plugin_list.h"
22 #include "content/public/common/pepper_plugin_info.h"
23 #include "media/cdm/cdm_paths.h"
24 #include "media/cdm/content_decryption_module_ext.h"
25
26 // On systems that use the zygote process to spawn child processes, we must
27 // open files in the zygote process.
28 #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.
29 !defined(OS_ANDROID)
30 #define POSIX_WITH_ZYGOTE 1
31 #endif
32
33 namespace base {
34 class FilePath;
35 }
36
37 namespace content {
38
39 // Manages all CDM host files.
40 class CdmHostFiles {
41 public:
42 CdmHostFiles();
43 ~CdmHostFiles();
44
45 #if defined(POSIX_WITH_ZYGOTE)
46 static void CreateGlobalInstance();
47 static std::unique_ptr<CdmHostFiles> TakeGlobalInstance();
48 #endif
49
50 static std::unique_ptr<CdmHostFiles> Create(
51 const base::FilePath& cdm_adapter_path);
52
53 // Verifies |cdm_adapter_path| CDM files by calling VerifyCdmFiles() on the
54 // 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.
55 // Otherwise, the PlatformFiles are passed to the CDM which will close the
56 // files later.
57 void VerifyFiles(base::NativeLibrary library,
58 const base::FilePath& cdm_adapter_path);
59
60 private:
61 #if defined(POSIX_WITH_ZYGOTE)
62 // Opens all common files and CDM specific files for all registered CDMs.
63 bool OpenFilesForAllRegisteredCdms();
64 #endif
65
66 // Opens all common files and CDM specific files for the CDM adapter
67 // registered at |cdm_adapter_path|.
68 bool OpenFiles(const base::FilePath& cdm_adapter_path);
69
70 // Open common CDM host files shared by all CDMs. Upon failure, close all
71 // files opened.
72 bool OpenCommonFiles();
73 // 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.
74 // |cdm_adapter_path|. Returns whether all CDM specific files are opened.
75 // Upon failure, close all files opened.
76 bool OpenCdmFiles(const base::FilePath& cdm_adapter_path);
77
78 // Fills |cdm_host_files| with common and CDM specific files for
79 // |cdm_adapter_path|. The ownership of those files are also transferred.
80 // Returns true upon success where the remaining files will be closed.
81 // Returns false upon any failure and all files will be closed.
82 bool TakePlatformFiles(const base::FilePath& cdm_adapter_path,
83 std::vector<cdm::CdmHostFile>* cdm_host_files);
84
85 void CloseAllFiles();
86
87 using ScopedFileVector = std::vector<std::unique_ptr<CdmHostFile>>;
88 ScopedFileVector common_files_;
89 std::map<base::FilePath, ScopedFileVector> cdm_specific_files_map_;
90 };
91
92 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.
93
94 } // namespace content
95
96 #endif // CONTENT_COMMON_MEDIA_CDM_HOST_FILES_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698