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

Unified Diff: services/media/common/media_pipe_base.cc

Issue 1823833003: Take advantage of MojoGetBufferInformation (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 4 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 | « services/media/common/media_pipe_base.h ('k') | services/media/framework_mojo/mojo_consumer.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: services/media/common/media_pipe_base.cc
diff --git a/services/media/common/media_pipe_base.cc b/services/media/common/media_pipe_base.cc
index 069283c6c21227304e01e1c3096380f02b8cd7e5..4ead2e45b3828b5d764013e98ff4ee1ad22abec8 100644
--- a/services/media/common/media_pipe_base.cc
+++ b/services/media/common/media_pipe_base.cc
@@ -40,27 +40,37 @@ void MediaPipeBase::Reset() {
}
void MediaPipeBase::SetBuffer(ScopedSharedBufferHandle handle,
- uint64_t size,
const SetBufferCallback& cbk) {
+ DCHECK(handle.is_valid());
+
// Double init? Close the connection.
if (buffer_) {
- LOG(ERROR) << "Attempting to set a new buffer (size = "
- << size
- << ") on a MediaConsumer which already has a buffer (size = "
+ LOG(ERROR) << "Attempting to set a new buffer on a MediaConsumer which "
+ "already has a buffer assigned. (size = "
<< buffer_->size()
<< ")";
Reset();
return;
}
+ // Query the buffer for its size. If we fail to query the info, close the
+ // connection.
+ MojoResult res;
+ struct MojoBufferInformation info;
viettrungluu 2016/03/22 17:58:58 Up to you, but in most of our C++ code, we omit th
johngro 2016/03/22 18:16:40 Done.
+ res = MojoGetBufferInformation(handle.get().value(), &info, sizeof(info));
+ if (res != MOJO_RESULT_OK) {
+ LOG(ERROR) << "Failed to query shared buffer info (res = " << res << ")";
+ Reset();
+ }
viettrungluu 2016/03/22 17:58:58 |return;|?
johngro 2016/03/22 18:16:40 good catch!
+
// Invalid size? Close the connection.
+ uint64_t size = info.num_bytes;
if (!size || (size > MediaConsumer::kMaxBufferLen)) {
LOG(ERROR) << "Invalid shared buffer size (size = " << size << ")";
Reset();
return;
}
-
// Failed to map the buffer? Close the connection.
buffer_ = MappedSharedBuffer::Create(handle.Pass(), size);
if (!buffer_) {
« no previous file with comments | « services/media/common/media_pipe_base.h ('k') | services/media/framework_mojo/mojo_consumer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698