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

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: comment addressed and updated historgrams.xml 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 170799bdb9593cdc00666c04aaf5776ba8484741..c06531b6564835d94a2553dae6e9d68d0e8cd26b 100644
--- a/media/cdm/ppapi/cdm_file_io_impl.cc
+++ b/media/cdm/ppapi/cdm_file_io_impl.cc
@@ -56,12 +56,16 @@ 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),
+ file_read_cb_(file_read_cb) {
PP_DCHECK(IsMainThread());
PP_DCHECK(pp_instance); // 0 indicates a "NULL handle".
}
@@ -338,6 +342,11 @@ 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.
+ file_read_cb_.Run(local_buffer.size());
+
client_->OnReadComplete(
cdm::FileIOClient::kSuccess, data, local_buffer.size());
}

Powered by Google App Engine
This is Rietveld 408576698