diff options
author | apatrick@chromium.org <apatrick@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-02-24 22:27:04 +0000 |
---|---|---|
committer | apatrick@chromium.org <apatrick@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-02-24 22:27:04 +0000 |
commit | 8ceb44c74fc375df749b60acc6fc01b5327c6d18 (patch) | |
tree | 0512ef018e445f45d142e8a79ed4a19b9390b6d3 /chrome/plugin/command_buffer_stub.cc | |
parent | c16b5958cc9a47992e6c24473258582773036af5 (diff) | |
download | chromium_src-8ceb44c74fc375df749b60acc6fc01b5327c6d18.zip chromium_src-8ceb44c74fc375df749b60acc6fc01b5327c6d18.tar.gz chromium_src-8ceb44c74fc375df749b60acc6fc01b5327c6d18.tar.bz2 |
I just put the code that does not compile on ARM. Trybots will fail because I had to remove these from the CL to make gcl upload properly accept it.
A + base\scoped_open_process.h
A + chrome\plugin\command_buffer_stub_win.cc
TEST=try
BUG=none
Review URL: http://codereview.chromium.org/661022
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@39937 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/plugin/command_buffer_stub.cc')
-rw-r--r-- | chrome/plugin/command_buffer_stub.cc | 84 |
1 files changed, 60 insertions, 24 deletions
diff --git a/chrome/plugin/command_buffer_stub.cc b/chrome/plugin/command_buffer_stub.cc index 103bde3..d8cc7d4 100644 --- a/chrome/plugin/command_buffer_stub.cc +++ b/chrome/plugin/command_buffer_stub.cc @@ -3,7 +3,7 @@ // found in the LICENSE file. #include "base/callback.h" -#include "base/process_util.h" +#include "base/scoped_open_process.h" #include "base/shared_memory.h" #include "chrome/common/command_buffer_messages.h" #include "chrome/common/plugin_messages.h" @@ -23,6 +23,7 @@ CommandBufferStub::CommandBufferStub(PluginChannel* channel, } CommandBufferStub::~CommandBufferStub() { + Destroy(); channel_->RemoveRoute(route_id_); } @@ -67,38 +68,57 @@ void CommandBufferStub::OnInitialize(int32 size, // Assume service is responsible for duplicating the handle from the calling // process. - base::ProcessHandle peer_handle; - if (!base::OpenProcessHandle(channel_->peer_pid(), &peer_handle)) + base::ScopedOpenProcess peer_process; + if (!peer_process.Open(channel_->peer_pid())) return; command_buffer_.reset(new gpu::CommandBufferService); - // Initialize the CommandBufferService and GPUProcessor. - if (command_buffer_->Initialize(size)) { - Buffer buffer = command_buffer_->GetRingBuffer(); - if (buffer.shared_memory) { - processor_ = new gpu::GPUProcessor(command_buffer_.get()); - if (processor_->Initialize(window_)) { - command_buffer_->SetPutOffsetChangeCallback( - NewCallback(processor_.get(), - &gpu::GPUProcessor::ProcessCommands)); + // Initialize the CommandBufferService. + if (!command_buffer_->Initialize(size)) { + Destroy(); + return; + } + + // Get the ring buffer. + Buffer buffer = command_buffer_->GetRingBuffer(); + if (!buffer.shared_memory) { + Destroy(); + return; + } + + // Initialize the GPUProcessor. + processor_ = new gpu::GPUProcessor(command_buffer_.get()); + if (!processor_->Initialize(window_)) { + Destroy(); + return; + } + + // Perform platform specific initialization. + if (!InitializePlatformSpecific()) { + Destroy(); + return; + } + + // Share the ring buffer to the client process. + if (!buffer.shared_memory->ShareToProcess(peer_process.handle(), + ring_buffer)) { + Destroy(); + return; + } + + // Setup callbacks for events. + command_buffer_->SetPutOffsetChangeCallback( + NewCallback(processor_.get(), + &gpu::GPUProcessor::ProcessCommands)); #if defined(OS_MACOSX) - processor_->SetSwapBuffersCallback( - NewCallback(this, - &CommandBufferStub::SwapBuffersCallback)); + processor_->SetSwapBuffersCallback( + NewCallback(this, + &CommandBufferStub::SwapBuffersCallback)); processor_->SetTransportDIBAllocAndFree( NewCallback(this, &CommandBufferStub::AllocTransportDIB), NewCallback(this, &CommandBufferStub::FreeTransportDIB)); #endif - buffer.shared_memory->ShareToProcess(peer_handle, ring_buffer); - } else { - processor_ = NULL; - command_buffer_.reset(); - } - } - } - - base::CloseProcessHandle(peer_handle); } void CommandBufferStub::OnGetState(gpu::CommandBuffer::State* state) { @@ -150,6 +170,22 @@ void CommandBufferStub::OnGetTransferBuffer( base::CloseProcessHandle(peer_handle); } +void CommandBufferStub::Destroy() { + processor_ = NULL; + command_buffer_.reset(); + + DestroyPlatformSpecific(); +} + +#if !defined(OS_WIN) +bool CommandBufferStub::InitializePlatformSpecific() { + return true; +} + +void CommandBufferStub::DestroyPlatformSpecific() { +} +#endif // defined(OS_WIN) + #if defined(OS_MACOSX) void CommandBufferStub::OnSetWindowSize(int32 width, int32 height) { // Try using the IOSurface version first. |