| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "content/browser/gpu/gpu_process_host_ui_shim.h" | 5 #include "content/browser/gpu/gpu_process_host_ui_shim.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/debug/trace_event.h" | 10 #include "base/debug/trace_event.h" |
| 11 #include "base/id_map.h" | 11 #include "base/id_map.h" |
| 12 #include "base/lazy_instance.h" | 12 #include "base/lazy_instance.h" |
| 13 #include "base/strings/string_number_conversions.h" | 13 #include "base/strings/string_number_conversions.h" |
| 14 #include "content/browser/gpu/gpu_data_manager_impl.h" | 14 #include "content/browser/gpu/gpu_data_manager_impl.h" |
| 15 #include "content/browser/gpu/gpu_process_host.h" | 15 #include "content/browser/gpu/gpu_process_host.h" |
| 16 #include "content/browser/gpu/gpu_surface_tracker.h" | 16 #include "content/browser/gpu/gpu_surface_tracker.h" |
| 17 #include "content/browser/renderer_host/render_process_host_impl.h" | 17 #include "content/browser/renderer_host/render_process_host_impl.h" |
| 18 #include "content/browser/renderer_host/render_view_host_impl.h" | 18 #include "content/browser/renderer_host/render_view_host_impl.h" |
| 19 #include "content/browser/renderer_host/render_widget_host_view_base.h" | 19 #include "content/browser/renderer_host/render_widget_host_view_base.h" |
| 20 #include "content/common/gpu/gpu_messages.h" | 20 #include "content/common/gpu/gpu_messages.h" |
| 21 #include "content/public/browser/browser_thread.h" | 21 #include "content/public/browser/browser_thread.h" |
| 22 | 22 |
| 23 #if defined(USE_OZONE) |
| 24 #include "ui/ozone/gpu/gpu_platform_support_host.h" |
| 25 #include "ui/ozone/ozone_platform.h" |
| 26 #endif |
| 27 |
| 23 namespace content { | 28 namespace content { |
| 24 | 29 |
| 25 namespace { | 30 namespace { |
| 26 | 31 |
| 27 // One of the linux specific headers defines this as a macro. | 32 // One of the linux specific headers defines this as a macro. |
| 28 #ifdef DestroyAll | 33 #ifdef DestroyAll |
| 29 #undef DestroyAll | 34 #undef DestroyAll |
| 30 #endif | 35 #endif |
| 31 | 36 |
| 32 base::LazyInstance<IDMap<GpuProcessHostUIShim> > g_hosts_by_id = | 37 base::LazyInstance<IDMap<GpuProcessHostUIShim> > g_hosts_by_id = |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 | 88 |
| 84 void RouteToGpuProcessHostUIShimTask(int host_id, const IPC::Message& msg) { | 89 void RouteToGpuProcessHostUIShimTask(int host_id, const IPC::Message& msg) { |
| 85 GpuProcessHostUIShim* ui_shim = GpuProcessHostUIShim::FromID(host_id); | 90 GpuProcessHostUIShim* ui_shim = GpuProcessHostUIShim::FromID(host_id); |
| 86 if (ui_shim) | 91 if (ui_shim) |
| 87 ui_shim->OnMessageReceived(msg); | 92 ui_shim->OnMessageReceived(msg); |
| 88 } | 93 } |
| 89 | 94 |
| 90 GpuProcessHostUIShim::GpuProcessHostUIShim(int host_id) | 95 GpuProcessHostUIShim::GpuProcessHostUIShim(int host_id) |
| 91 : host_id_(host_id) { | 96 : host_id_(host_id) { |
| 92 g_hosts_by_id.Pointer()->AddWithID(this, host_id_); | 97 g_hosts_by_id.Pointer()->AddWithID(this, host_id_); |
| 98 #if defined(USE_OZONE) |
| 99 ui::OzonePlatform::GetInstance() |
| 100 ->GetGpuPlatformSupportHost() |
| 101 ->OnChannelEstablished(host_id, this); |
| 102 #endif |
| 93 } | 103 } |
| 94 | 104 |
| 95 // static | 105 // static |
| 96 GpuProcessHostUIShim* GpuProcessHostUIShim::Create(int host_id) { | 106 GpuProcessHostUIShim* GpuProcessHostUIShim::Create(int host_id) { |
| 97 DCHECK(!FromID(host_id)); | 107 DCHECK(!FromID(host_id)); |
| 98 return new GpuProcessHostUIShim(host_id); | 108 return new GpuProcessHostUIShim(host_id); |
| 99 } | 109 } |
| 100 | 110 |
| 101 // static | 111 // static |
| 102 void GpuProcessHostUIShim::Destroy(int host_id, const std::string& message) { | 112 void GpuProcessHostUIShim::Destroy(int host_id, const std::string& message) { |
| 103 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 113 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 104 | 114 |
| 105 GpuDataManagerImpl::GetInstance()->AddLogMessage( | 115 GpuDataManagerImpl::GetInstance()->AddLogMessage( |
| 106 logging::LOG_ERROR, "GpuProcessHostUIShim", | 116 logging::LOG_ERROR, "GpuProcessHostUIShim", |
| 107 message); | 117 message); |
| 108 | 118 |
| 119 #if defined(USE_OZONE) |
| 120 ui::OzonePlatform::GetInstance() |
| 121 ->GetGpuPlatformSupportHost() |
| 122 ->OnChannelDestroyed(host_id); |
| 123 #endif |
| 124 |
| 109 delete FromID(host_id); | 125 delete FromID(host_id); |
| 110 } | 126 } |
| 111 | 127 |
| 112 // static | 128 // static |
| 113 void GpuProcessHostUIShim::DestroyAll() { | 129 void GpuProcessHostUIShim::DestroyAll() { |
| 114 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 130 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 115 while (!g_hosts_by_id.Pointer()->IsEmpty()) { | 131 while (!g_hosts_by_id.Pointer()->IsEmpty()) { |
| 116 IDMap<GpuProcessHostUIShim>::iterator it(g_hosts_by_id.Pointer()); | 132 IDMap<GpuProcessHostUIShim>::iterator it(g_hosts_by_id.Pointer()); |
| 117 delete it.GetCurrentValue(); | 133 delete it.GetCurrentValue(); |
| 118 } | 134 } |
| (...skipping 19 matching lines...) Expand all Loading... |
| 138 return BrowserThread::PostTask(BrowserThread::IO, | 154 return BrowserThread::PostTask(BrowserThread::IO, |
| 139 FROM_HERE, | 155 FROM_HERE, |
| 140 base::Bind(&SendOnIOThreadTask, | 156 base::Bind(&SendOnIOThreadTask, |
| 141 host_id_, | 157 host_id_, |
| 142 msg)); | 158 msg)); |
| 143 } | 159 } |
| 144 | 160 |
| 145 bool GpuProcessHostUIShim::OnMessageReceived(const IPC::Message& message) { | 161 bool GpuProcessHostUIShim::OnMessageReceived(const IPC::Message& message) { |
| 146 DCHECK(CalledOnValidThread()); | 162 DCHECK(CalledOnValidThread()); |
| 147 | 163 |
| 164 #if defined(USE_OZONE) |
| 165 if (ui::OzonePlatform::GetInstance() |
| 166 ->GetGpuPlatformSupportHost() |
| 167 ->OnMessageReceived(message)) |
| 168 return true; |
| 169 #endif |
| 170 |
| 148 if (message.routing_id() != MSG_ROUTING_CONTROL) | 171 if (message.routing_id() != MSG_ROUTING_CONTROL) |
| 149 return false; | 172 return false; |
| 150 | 173 |
| 151 return OnControlMessageReceived(message); | 174 return OnControlMessageReceived(message); |
| 152 } | 175 } |
| 153 | 176 |
| 154 void GpuProcessHostUIShim::SimulateRemoveAllContext() { | 177 void GpuProcessHostUIShim::SimulateRemoveAllContext() { |
| 155 Send(new GpuMsg_Clean()); | 178 Send(new GpuMsg_Clean()); |
| 156 } | 179 } |
| 157 | 180 |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 340 view->AcceleratedSurfaceRelease(); | 363 view->AcceleratedSurfaceRelease(); |
| 341 } | 364 } |
| 342 | 365 |
| 343 void GpuProcessHostUIShim::OnVideoMemoryUsageStatsReceived( | 366 void GpuProcessHostUIShim::OnVideoMemoryUsageStatsReceived( |
| 344 const GPUVideoMemoryUsageStats& video_memory_usage_stats) { | 367 const GPUVideoMemoryUsageStats& video_memory_usage_stats) { |
| 345 GpuDataManagerImpl::GetInstance()->UpdateVideoMemoryUsageStats( | 368 GpuDataManagerImpl::GetInstance()->UpdateVideoMemoryUsageStats( |
| 346 video_memory_usage_stats); | 369 video_memory_usage_stats); |
| 347 } | 370 } |
| 348 | 371 |
| 349 } // namespace content | 372 } // namespace content |
| OLD | NEW |