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