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

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: comments addressed 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
« no previous file with comments | « media/cdm/ppapi/cdm_file_io_impl.h ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..3409f16fd581f9258f23f0096aa1c0ea97ec9765 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& first_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),
+ first_file_read_cb_(first_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_) {
+ first_file_read_cb_.Run(local_buffer.size());
+ first_file_read_reported_ = true;
+ }
+
client_->OnReadComplete(
cdm::FileIOClient::kSuccess, data, local_buffer.size());
}
« no previous file with comments | « media/cdm/ppapi/cdm_file_io_impl.h ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698