| Index: ui/ozone/platform/dri/dri_gpu_platform_support_host.cc
|
| diff --git a/ui/ozone/platform/dri/dri_gpu_platform_support_host.cc b/ui/ozone/platform/dri/dri_gpu_platform_support_host.cc
|
| index 890ee325c5aff3b3bcd63a0cf5bc555256f373a7..eb1d6b91aa1d8b9b04d82a55059851171d40e4a9 100644
|
| --- a/ui/ozone/platform/dri/dri_gpu_platform_support_host.cc
|
| +++ b/ui/ozone/platform/dri/dri_gpu_platform_support_host.cc
|
| @@ -11,8 +11,7 @@
|
|
|
| namespace ui {
|
|
|
| -DriGpuPlatformSupportHost::DriGpuPlatformSupportHost()
|
| - : host_id_(-1), sender_(NULL) {
|
| +DriGpuPlatformSupportHost::DriGpuPlatformSupportHost() : host_id_(-1) {
|
| }
|
|
|
| DriGpuPlatformSupportHost::~DriGpuPlatformSupportHost() {
|
| @@ -22,8 +21,8 @@ void DriGpuPlatformSupportHost::RegisterHandler(
|
| GpuPlatformSupportHost* handler) {
|
| handlers_.push_back(handler);
|
|
|
| - if (sender_)
|
| - handler->OnChannelEstablished(host_id_, sender_);
|
| + if (IsConnected())
|
| + handler->OnChannelEstablished(host_id_, send_runner_, send_callback_);
|
| }
|
|
|
| void DriGpuPlatformSupportHost::UnregisterHandler(
|
| @@ -37,7 +36,7 @@ void DriGpuPlatformSupportHost::UnregisterHandler(
|
| void DriGpuPlatformSupportHost::AddChannelObserver(ChannelObserver* observer) {
|
| channel_observers_.AddObserver(observer);
|
|
|
| - if (sender_)
|
| + if (IsConnected())
|
| observer->OnChannelEstablished();
|
| }
|
|
|
| @@ -46,15 +45,22 @@ void DriGpuPlatformSupportHost::RemoveChannelObserver(
|
| channel_observers_.RemoveObserver(observer);
|
| }
|
|
|
| -void DriGpuPlatformSupportHost::OnChannelEstablished(int host_id,
|
| - IPC::Sender* sender) {
|
| +bool DriGpuPlatformSupportHost::IsConnected() {
|
| + return host_id_ >= 0;
|
| +}
|
| +
|
| +void DriGpuPlatformSupportHost::OnChannelEstablished(
|
| + int host_id,
|
| + scoped_refptr<base::SingleThreadTaskRunner> send_runner,
|
| + const base::Callback<void(IPC::Message*)>& send_callback) {
|
| TRACE_EVENT1("dri", "DriGpuPlatformSupportHost::OnChannelEstablished",
|
| "host_id", host_id);
|
| host_id_ = host_id;
|
| - sender_ = sender;
|
| + send_runner_ = send_runner;
|
| + send_callback_ = send_callback;
|
|
|
| for (size_t i = 0; i < handlers_.size(); ++i)
|
| - handlers_[i]->OnChannelEstablished(host_id, sender);
|
| + handlers_[i]->OnChannelEstablished(host_id, send_runner_, send_callback_);
|
|
|
| FOR_EACH_OBSERVER(ChannelObserver, channel_observers_,
|
| OnChannelEstablished());
|
| @@ -65,8 +71,8 @@ void DriGpuPlatformSupportHost::OnChannelDestroyed(int host_id) {
|
| "host_id", host_id);
|
| if (host_id_ == host_id) {
|
| host_id_ = -1;
|
| - sender_ = NULL;
|
| -
|
| + send_runner_ = nullptr;
|
| + send_callback_.Reset();
|
| FOR_EACH_OBSERVER(ChannelObserver, channel_observers_,
|
| OnChannelDestroyed());
|
| }
|
| @@ -84,9 +90,11 @@ bool DriGpuPlatformSupportHost::OnMessageReceived(const IPC::Message& message) {
|
| }
|
|
|
| bool DriGpuPlatformSupportHost::Send(IPC::Message* message) {
|
| - if (sender_)
|
| - return sender_->Send(message);
|
| + if (IsConnected() &&
|
| + send_runner_->PostTask(FROM_HERE, base::Bind(send_callback_, message)))
|
| + return true;
|
|
|
| + delete message;
|
| return false;
|
| }
|
|
|
|
|