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_) { |