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..9e042bfbd2a30ebb261d6a1e420c8e247b8bc8d0 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,28 @@ 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. |
- // We might not have any common CDM host file (e.g. chrome) since we are |
- // running in browser_tests. |
- if (num_files < 2) { |
+ // 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. |
+ if (num_files < 3) { |
Haoming Chen
2017/03/31 16:46:53
nit: kNumRequiredHostFile or kMinimumNumHostFile?
xhwang
2017/03/31 18:05:37
Done.
|
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 +305,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 the CDM and CDM adapter opened. |
+ if (num_opened_files < 2) { |
Haoming Chen
2017/03/31 16:46:53
nit: kNumCdmFiles?
xhwang
2017/03/31 18:05:37
Done.
|
+ 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; |
} |