OLD | NEW |
---|---|
(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 #include "content/common/media/cdm_host_file.h" | |
6 | |
7 #include <memory> | |
8 | |
9 #include "base/logging.h" | |
10 #include "base/memory/ptr_util.h" | |
11 #include "media/cdm/content_decryption_module_ext.h" | |
12 | |
13 namespace content { | |
14 | |
15 // const char kSigFileExtension[] = ".sig"; | |
16 | |
17 std::unique_ptr<CdmHostFile> CdmHostFile::Create( | |
18 const base::FilePath& file_path) { | |
19 // Open file at |file_path|. | |
20 base::File file(file_path, base::File::FLAG_OPEN | base::File::FLAG_READ); | |
21 if (!file.IsValid()) { | |
22 DVLOG(1) << "Failed to open file at " << file_path.MaybeAsASCII(); | |
23 return nullptr; | |
24 } | |
25 | |
26 // Also open the sig file. | |
27 | |
28 // HACK(xhwang): This is a HACK since we don't have a sig file now. | |
29 base::FilePath sig_file_path = file_path; | |
30 | |
31 // base::FilePath sig_file_path = file_path.AppendASCII(kSigFileExtension); | |
32 base::File sig_file(sig_file_path, | |
Greg K
2017/01/09 21:45:14
On OS X we'll need to locate the signature file in
tinskip1
2017/01/09 23:49:30
Specifically in the Chrome Framework.
xhwang
2017/01/12 20:15:02
Good point. Will do.
xhwang
2017/01/18 06:03:58
On Mac we are more interested in "Google Chrome Fr
| |
33 base::File::FLAG_OPEN | base::File::FLAG_READ); | |
34 if (!sig_file.IsValid()) { | |
35 DVLOG(1) << "Failed to open sig file at " << sig_file_path.MaybeAsASCII(); | |
36 return nullptr; | |
37 } | |
38 | |
39 return std::unique_ptr<CdmHostFile>( | |
40 new CdmHostFile(file_path, std::move(file), std::move(sig_file))); | |
jrummell
2016/12/16 20:21:30
I think Chromium is moving to base::MakeUnique<Cdm
xhwang
2017/01/12 20:15:02
Good point. Will do.
xhwang
2017/01/18 06:03:58
Actually, now I remember why I didn't use MakeUniq
| |
41 } | |
42 | |
43 cdm::CdmHostFile CdmHostFile::TakePlatformFile() { | |
44 return cdm::CdmHostFile(file_path_.value().c_str(), file_.TakePlatformFile(), | |
45 sig_file_.TakePlatformFile()); | |
46 } | |
47 | |
48 CdmHostFile::CdmHostFile(const base::FilePath& file_path, | |
49 base::File file, | |
50 base::File sig_file) | |
51 : file_path_(file_path), | |
52 file_(std::move(file)), | |
53 sig_file_(std::move(sig_file)) { | |
54 DVLOG(1) << __func__ << ": " << file_path_.value(); | |
55 DCHECK(!file_path_.empty()) << "File path is empty."; | |
56 DCHECK(file_.IsValid()) << "Invalid file."; | |
57 DCHECK(sig_file_.IsValid()) << "Invalid signature file."; | |
58 } | |
59 | |
60 } // namespace content | |
OLD | NEW |