Chromium Code Reviews| Index: content/common/media/cdm_host_file.cc |
| diff --git a/content/common/media/cdm_host_file.cc b/content/common/media/cdm_host_file.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..ea5df9c3bba822567248b77f9af8704562b27101 |
| --- /dev/null |
| +++ b/content/common/media/cdm_host_file.cc |
| @@ -0,0 +1,60 @@ |
| +// 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. |
| + |
| +#include "content/common/media/cdm_host_file.h" |
| + |
| +#include <memory> |
| + |
| +#include "base/logging.h" |
| +#include "base/memory/ptr_util.h" |
| +#include "media/cdm/content_decryption_module_ext.h" |
| + |
| +namespace content { |
| + |
| +// const char kSigFileExtension[] = ".sig"; |
| + |
| +std::unique_ptr<CdmHostFile> CdmHostFile::Create( |
| + const base::FilePath& file_path) { |
| + // Open file at |file_path|. |
| + base::File file(file_path, base::File::FLAG_OPEN | base::File::FLAG_READ); |
| + if (!file.IsValid()) { |
| + DVLOG(1) << "Failed to open file at " << file_path.MaybeAsASCII(); |
| + return nullptr; |
| + } |
| + |
| + // Also open the sig file. |
| + |
| + // HACK(xhwang): This is a HACK since we don't have a sig file now. |
| + base::FilePath sig_file_path = file_path; |
| + |
| + // base::FilePath sig_file_path = file_path.AppendASCII(kSigFileExtension); |
| + 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
|
| + base::File::FLAG_OPEN | base::File::FLAG_READ); |
| + if (!sig_file.IsValid()) { |
| + DVLOG(1) << "Failed to open sig file at " << sig_file_path.MaybeAsASCII(); |
| + return nullptr; |
| + } |
| + |
| + return std::unique_ptr<CdmHostFile>( |
| + 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
|
| +} |
| + |
| +cdm::CdmHostFile CdmHostFile::TakePlatformFile() { |
| + return cdm::CdmHostFile(file_path_.value().c_str(), file_.TakePlatformFile(), |
| + sig_file_.TakePlatformFile()); |
| +} |
| + |
| +CdmHostFile::CdmHostFile(const base::FilePath& file_path, |
| + base::File file, |
| + base::File sig_file) |
| + : file_path_(file_path), |
| + file_(std::move(file)), |
| + sig_file_(std::move(sig_file)) { |
| + DVLOG(1) << __func__ << ": " << file_path_.value(); |
| + DCHECK(!file_path_.empty()) << "File path is empty."; |
| + DCHECK(file_.IsValid()) << "Invalid file."; |
| + DCHECK(sig_file_.IsValid()) << "Invalid signature file."; |
| +} |
| + |
| +} // namespace content |