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

Unified Diff: media/cdm/ppapi/external_clear_key/clear_key_cdm.cc

Issue 2773283002: media: Simplify CdmHostFile(s) (Closed)
Patch Set: comments addressed Created 3 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « media/base/media_switches.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/cdm/ppapi/external_clear_key/clear_key_cdm.cc
diff --git a/media/cdm/ppapi/external_clear_key/clear_key_cdm.cc b/media/cdm/ppapi/external_clear_key/clear_key_cdm.cc
index 655fd6a8a5e7ee06222a762ec1fe5feecbd842ba..18e4f87ea8c06a4f1bbcaf57b54729f9f4a15ec4 100644
--- a/media/cdm/ppapi/external_clear_key/clear_key_cdm.cc
+++ b/media/cdm/ppapi/external_clear_key/clear_key_cdm.cc
@@ -272,22 +272,33 @@ static bool g_verify_host_files_result = false;
// Makes sure files and corresponding signature files are readable but not
// writable.
bool VerifyCdmHost_0(const cdm::HostFile* host_files, uint32_t num_files) {
- DVLOG(1) << __func__;
+ DVLOG(1) << __func__ << ": " << num_files;
+
+ // We should always have the CDM and CDM adapter and at lease one common file.
+ // The common CDM host file (e.g. chrome) might not exist since we are running
+ // in browser_tests.
+ const uint32_t kMinNumHostFiles = 3;
// We should always have the CDM and CDM adapter.
- // We might not have any common CDM host file (e.g. chrome) since we are
- // running in browser_tests.
- if (num_files < 2) {
+ const int kNumCdmFiles = 2;
+
+ if (num_files < kMinNumHostFiles) {
LOG(ERROR) << "Too few host files: " << num_files;
g_verify_host_files_result = false;
return true;
}
+ int num_opened_files = 0;
for (uint32_t i = 0; i < num_files; ++i) {
const int kBytesToRead = 10;
std::vector<char> buffer(kBytesToRead);
base::File file(static_cast<base::PlatformFile>(host_files[i].file));
+ if (!file.IsValid())
+ continue;
+
+ num_opened_files++;
+
int bytes_read = file.Read(0, buffer.data(), buffer.size());
if (bytes_read != kBytesToRead) {
LOG(ERROR) << "File bytes read: " << bytes_read;
@@ -299,6 +310,13 @@ bool VerifyCdmHost_0(const cdm::HostFile* host_files, uint32_t num_files) {
// TODO(xhwang): Also verify the signature file when it's available.
}
+ // We should always have CDM files opened.
+ if (num_opened_files < kNumCdmFiles) {
+ LOG(ERROR) << "Too few opened files: " << num_opened_files;
+ g_verify_host_files_result = false;
+ return true;
+ }
+
g_verify_host_files_result = true;
return true;
}
« no previous file with comments | « media/base/media_switches.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698