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

Unified Diff: o3d/gpu_plugin/command_buffer.cc

Issue 234001: GPUProcessor uses O3D command buffer service to render to a window.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 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 | « o3d/gpu_plugin/command_buffer.h ('k') | o3d/gpu_plugin/command_buffer_mock.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: o3d/gpu_plugin/command_buffer.cc
===================================================================
--- o3d/gpu_plugin/command_buffer.cc (revision 26879)
+++ o3d/gpu_plugin/command_buffer.cc (working copy)
@@ -13,7 +13,8 @@
get_offset_(0),
put_offset_(0),
token_(0),
- error_(ERROR_NO_ERROR) {
+ parse_error_(0),
+ error_status_(false) {
// Element zero is always NULL.
registered_objects_.push_back(NPObjectPointer<NPObject>());
}
@@ -22,6 +23,12 @@
}
bool CommandBuffer::Initialize(int32 size) {
+ // Check the size will not overflow when it is converted from count of int32s
+ // to count of bytes.
+ int32 num_bytes = static_cast<int32>(size * sizeof(int32));
+ if (num_bytes / sizeof(int32) != size)
+ return false;
+
if (shared_memory_.Get())
return false;
@@ -41,7 +48,7 @@
}
NPObjectPointer<NPObject> result;
- if (!NPInvoke(npp_, system, "createSharedMemory", size,
+ if (!NPInvoke(npp_, system, "createSharedMemory", num_bytes,
&result)) {
return false;
}
@@ -148,15 +155,18 @@
}
NPObjectPointer<NPObject> CommandBuffer::GetRegisteredObject(int32 handle) {
- DCHECK_GE(handle, 0);
- DCHECK_LT(static_cast<size_t>(handle), registered_objects_.size());
+ if (handle < 0)
+ return NPObjectPointer<NPObject>();
+ if (static_cast<size_t>(handle) >= registered_objects_.size())
+ return NPObjectPointer<NPObject>();
+
return registered_objects_[handle];
}
-int32 CommandBuffer::ResetError() {
- int32 last_error = error_;
- error_ = ERROR_NO_ERROR;
+int32 CommandBuffer::ResetParseError() {
+ int32 last_error = parse_error_;
+ parse_error_ = 0;
return last_error;
}
« no previous file with comments | « o3d/gpu_plugin/command_buffer.h ('k') | o3d/gpu_plugin/command_buffer_mock.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698