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

Side by Side Diff: content/common/media/cdm_host_file.cc

Issue 2802853002: Revert of media: Simplify CdmHostFile(s) (Closed)
Patch Set: Created 3 years, 8 months 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
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 #include "content/common/media/cdm_host_file.h" 5 #include "content/common/media/cdm_host_file.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/feature_list.h" 10 #include "base/feature_list.h"
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/memory/ptr_util.h" 12 #include "base/memory/ptr_util.h"
13 #include "media/base/media_switches.h"
13 #include "media/cdm/api/content_decryption_module_ext.h" 14 #include "media/cdm/api/content_decryption_module_ext.h"
14 15
15 namespace content { 16 namespace content {
16 17
18 namespace {
19
20 bool IgnoreMissingCdmHostFile() {
21 return base::CommandLine::ForCurrentProcess()->HasSwitch(
22 switches::kIgnoreMissingCdmHostFile);
23 }
24
25 } // namespace
26
17 // static 27 // static
18 std::unique_ptr<CdmHostFile> CdmHostFile::Create( 28 std::unique_ptr<CdmHostFile> CdmHostFile::Create(
19 const base::FilePath& file_path, 29 const base::FilePath& file_path,
20 const base::FilePath& sig_file_path) { 30 const base::FilePath& sig_file_path) {
21 DVLOG(1) << __func__;
22
23 // Open file at |file_path|. 31 // Open file at |file_path|.
24 base::File file(file_path, base::File::FLAG_OPEN | base::File::FLAG_READ); 32 base::File file(file_path, base::File::FLAG_OPEN | base::File::FLAG_READ);
25 DVLOG(1) << " " << file.IsValid() << ": " << file_path.MaybeAsASCII(); 33 if (!file.IsValid()) {
34 DVLOG(1) << "Failed to open file at " << file_path.MaybeAsASCII();
35 return nullptr;
36 }
26 37
27 // Also open the sig file at |sig_file_path|. 38 // Also open the sig file at |sig_file_path|.
28 base::File sig_file(sig_file_path, 39 base::File sig_file(sig_file_path,
29 base::File::FLAG_OPEN | base::File::FLAG_READ); 40 base::File::FLAG_OPEN | base::File::FLAG_READ);
30 DVLOG(1) << " " << sig_file.IsValid() << ": " 41 if (!sig_file.IsValid()) {
31 << sig_file_path.MaybeAsASCII(); 42 DVLOG(1) << "Failed to open sig file at " << sig_file_path.MaybeAsASCII();
43 if (!IgnoreMissingCdmHostFile())
44 return nullptr;
45
46 DVLOG(1) << "Ignoring sig file failure at " << sig_file_path.MaybeAsASCII();
47 }
32 48
33 return std::unique_ptr<CdmHostFile>( 49 return std::unique_ptr<CdmHostFile>(
34 new CdmHostFile(file_path, std::move(file), std::move(sig_file))); 50 new CdmHostFile(file_path, std::move(file), std::move(sig_file)));
35 } 51 }
36 52
37 cdm::HostFile CdmHostFile::TakePlatformFile() { 53 cdm::HostFile CdmHostFile::TakePlatformFile() {
38 return cdm::HostFile(file_path_.value().c_str(), file_.TakePlatformFile(), 54 return cdm::HostFile(file_path_.value().c_str(), file_.TakePlatformFile(),
39 sig_file_.TakePlatformFile()); 55 sig_file_.TakePlatformFile());
40 } 56 }
41 57
42 CdmHostFile::CdmHostFile(const base::FilePath& file_path, 58 CdmHostFile::CdmHostFile(const base::FilePath& file_path,
43 base::File file, 59 base::File file,
44 base::File sig_file) 60 base::File sig_file)
45 : file_path_(file_path), 61 : file_path_(file_path),
46 file_(std::move(file)), 62 file_(std::move(file)),
47 sig_file_(std::move(sig_file)) { 63 sig_file_(std::move(sig_file)) {
48 DCHECK(!file_path_.empty()); 64 DVLOG(1) << __func__ << ": " << file_path_.value();
65 DCHECK(!file_path_.empty()) << "File path is empty.";
66 DCHECK(file_.IsValid()) << "Invalid file.";
67
68 if (!IgnoreMissingCdmHostFile())
69 DCHECK(sig_file_.IsValid()) << "Invalid signature file.";
49 } 70 }
50 71
51 } // namespace content 72 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/zygote_host/zygote_communication_linux.cc ('k') | content/common/media/cdm_host_files.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698