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

Unified Diff: media/cdm/ppapi/cdm_file_io_impl.cc

Issue 568623003: CdmAdapter: Report size of the file read by CDM via FileIO. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Only report the first file read in CdmFileIOImpl (becase the completion cb can only be used once). Created 6 years, 3 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
Index: media/cdm/ppapi/cdm_file_io_impl.cc
diff --git a/media/cdm/ppapi/cdm_file_io_impl.cc b/media/cdm/ppapi/cdm_file_io_impl.cc
index 726388949ec483ef1ad05191e95a212b0677d29f..277c076a8e0efca9e56417147267cd826a3e62c2 100644
--- a/media/cdm/ppapi/cdm_file_io_impl.cc
+++ b/media/cdm/ppapi/cdm_file_io_impl.cc
@@ -55,12 +55,17 @@ CdmFileIOImpl::ResourceTracker::~ResourceTracker() {
delete CdmFileIOImpl::file_lock_map_;
}
-CdmFileIOImpl::CdmFileIOImpl(cdm::FileIOClient* client, PP_Instance pp_instance)
+CdmFileIOImpl::CdmFileIOImpl(
+ cdm::FileIOClient* client,
+ PP_Instance pp_instance,
+ const pp::CompletionCallback& file_read_cb)
: state_(FILE_UNOPENED),
client_(client),
pp_instance_handle_(pp_instance),
callback_factory_(this),
- io_offset_(0) {
+ io_offset_(0),
+ first_file_read_reported_(false),
+ file_read_cb_(file_read_cb) {
PP_DCHECK(IsMainThread());
PP_DCHECK(pp_instance); // 0 indicates a "NULL handle".
}
@@ -336,6 +341,14 @@ void CdmFileIOImpl::OnFileRead(int32_t bytes_read) {
state_ = FILE_OPENED;
const uint8_t* data = local_buffer.empty() ?
NULL : reinterpret_cast<const uint8_t*>(&local_buffer[0]);
+
+ // Call this before OnReadComplete() so that we always have the latest file
+ // size before CDM fires errors.
+ if (!first_file_read_reported_) {
+ file_read_cb_.Run(local_buffer.size());
+ first_file_read_reported_ = true;
+ }
+
client_->OnReadComplete(
cdm::FileIOClient::kSuccess, data, local_buffer.size());
}

Powered by Google App Engine
This is Rietveld 408576698