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

Unified Diff: services/gles2/command_buffer_impl.cc

Issue 1161533005: Fix crash when backgrounding MojoShell on Android. Fixes issue #186. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 7 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/gles2/command_buffer_impl.h ('k') | services/native_viewport/onscreen_context_provider.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: services/gles2/command_buffer_impl.cc
diff --git a/services/gles2/command_buffer_impl.cc b/services/gles2/command_buffer_impl.cc
index 29a772c010d3f327ebedc2b20e5d6e69bf660acf..8e7300137f5831ddab8530ede2dadf75bf23607d 100644
--- a/services/gles2/command_buffer_impl.cc
+++ b/services/gles2/command_buffer_impl.cc
@@ -53,6 +53,7 @@ CommandBufferImpl::CommandBufferImpl(
gpu::SyncPointManager* sync_point_manager,
scoped_ptr<CommandBufferDriver> driver)
: sync_point_manager_(sync_point_manager),
+ control_task_runner_(control_task_runner),
driver_task_runner_(base::MessageLoop::current()->task_runner()),
driver_(driver.Pass()),
viewport_parameter_listener_(listener.Pass()),
@@ -62,15 +63,12 @@ CommandBufferImpl::CommandBufferImpl(
driver_->set_client(make_scoped_ptr(new CommandBufferDriverClientImpl(
weak_factory_.GetWeakPtr(), control_task_runner)));
- control_task_runner->PostTask(
+ control_task_runner_->PostTask(
FROM_HERE, base::Bind(&CommandBufferImpl::BindToRequest,
base::Unretained(this), base::Passed(&request)));
}
CommandBufferImpl::~CommandBufferImpl() {
- if (observer_) {
- observer_->OnCommandBufferImplDestroyed();
- }
driver_task_runner_->PostTask(
FROM_HERE, base::Bind(&DestroyDriver, base::Passed(&driver_)));
}
@@ -147,10 +145,35 @@ void CommandBufferImpl::Echo(const mojo::Callback<void()>& callback) {
void CommandBufferImpl::BindToRequest(
mojo::InterfaceRequest<mojo::CommandBuffer> request) {
binding_.Bind(request.Pass());
+ binding_.set_error_handler(this);
}
void CommandBufferImpl::DidLoseContext() {
- binding_.OnConnectionError();
+ NotifyAndDestroy();
blundell 2015/06/03 14:48:59 This method is called on |control_task_runner_| at
etiennej 2015/06/03 15:00:40 Right. Fixed.
+}
+
+void CommandBufferImpl::OnConnectionError() {
+ // Called from the control_task_runner thread as we bound to the message pipe
+ // handle on that thread. However, the observer have to be notified on the
+ // thread that created this object, so we post on driver_task_runner.
+ driver_task_runner_->PostTask(
+ FROM_HERE,
+ base::Bind(&CommandBufferImpl::NotifyAndDestroy, base::Unretained(this)));
+}
+
+void CommandBufferImpl::NotifyAndDestroy() {
+ if (observer_) {
+ observer_->OnCommandBufferImplDestroyed();
+ }
+ // We have notified the observer on the right thread. However, destruction of
+ // this object must happen on control_task_runner_
+ control_task_runner_->PostTask(
+ FROM_HERE,
+ base::Bind(&CommandBufferImpl::Destroy, base::Unretained(this)));
+}
+
+void CommandBufferImpl::Destroy() {
+ delete this;
}
void CommandBufferImpl::UpdateVSyncParameters(base::TimeTicks timebase,
« no previous file with comments | « services/gles2/command_buffer_impl.h ('k') | services/native_viewport/onscreen_context_provider.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698