OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "media/gpu/ipc/client/gpu_jpeg_decode_accelerator_host.h" | 5 #include "media/gpu/ipc/client/gpu_jpeg_decode_accelerator_host.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 DCHECK(CalledOnValidThread()); | 111 DCHECK(CalledOnValidThread()); |
112 Send(new AcceleratedJpegDecoderMsg_Destroy(decoder_route_id_)); | 112 Send(new AcceleratedJpegDecoderMsg_Destroy(decoder_route_id_)); |
113 | 113 |
114 if (receiver_) { | 114 if (receiver_) { |
115 channel_->RemoveRoute(decoder_route_id_); | 115 channel_->RemoveRoute(decoder_route_id_); |
116 | 116 |
117 // Invalidate weak ptr of |receiver_|. After that, no more messages will be | 117 // Invalidate weak ptr of |receiver_|. After that, no more messages will be |
118 // routed to |receiver_| on IO thread. | 118 // routed to |receiver_| on IO thread. |
119 base::WaitableEvent event(base::WaitableEvent::ResetPolicy::AUTOMATIC, | 119 base::WaitableEvent event(base::WaitableEvent::ResetPolicy::AUTOMATIC, |
120 base::WaitableEvent::InitialState::NOT_SIGNALED); | 120 base::WaitableEvent::InitialState::NOT_SIGNALED); |
121 io_task_runner_->PostTask(FROM_HERE, | 121 bool task_expected_to_run = io_task_runner_->PostTask( |
122 base::Bind(&Receiver::InvalidateWeakPtr, | 122 FROM_HERE, base::Bind(&Receiver::InvalidateWeakPtr, |
123 base::Unretained(receiver_.get()), | 123 base::Unretained(receiver_.get()), |
124 base::Unretained(&event))); | 124 base::Unretained(&event))); |
125 event.Wait(); | 125 // If the current call is happening during the browser shutdown, the |
| 126 // |io_task_runner_| may no longer be accepting tasks. |
| 127 if (task_expected_to_run) |
| 128 event.Wait(); |
126 } | 129 } |
127 } | 130 } |
128 | 131 |
129 bool GpuJpegDecodeAcceleratorHost::Initialize( | 132 bool GpuJpegDecodeAcceleratorHost::Initialize( |
130 JpegDecodeAccelerator::Client* client) { | 133 JpegDecodeAccelerator::Client* client) { |
131 DCHECK(CalledOnValidThread()); | 134 DCHECK(CalledOnValidThread()); |
132 | 135 |
133 bool succeeded = false; | 136 bool succeeded = false; |
134 // This cannot be on IO thread because the msg is synchronous. | 137 // This cannot be on IO thread because the msg is synchronous. |
135 Send(new GpuChannelMsg_CreateJpegDecoder(decoder_route_id_, &succeeded)); | 138 Send(new GpuChannelMsg_CreateJpegDecoder(decoder_route_id_, &succeeded)); |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
196 if (!channel_->Send(message)) { | 199 if (!channel_->Send(message)) { |
197 DLOG(ERROR) << "Send(" << message->type() << ") failed"; | 200 DLOG(ERROR) << "Send(" << message->type() << ") failed"; |
198 } | 201 } |
199 } | 202 } |
200 | 203 |
201 base::WeakPtr<IPC::Listener> GpuJpegDecodeAcceleratorHost::GetReceiver() { | 204 base::WeakPtr<IPC::Listener> GpuJpegDecodeAcceleratorHost::GetReceiver() { |
202 return receiver_->AsWeakPtrForIO(); | 205 return receiver_->AsWeakPtrForIO(); |
203 } | 206 } |
204 | 207 |
205 } // namespace media | 208 } // namespace media |
OLD | NEW |