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