| 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/callback_helpers.h" |
| 10 #include "base/debug/trace_event.h" | 11 #include "base/debug/trace_event.h" |
| 11 #include "base/id_map.h" | 12 #include "base/id_map.h" |
| 12 #include "base/lazy_instance.h" | 13 #include "base/lazy_instance.h" |
| 13 #include "base/strings/string_number_conversions.h" | 14 #include "base/strings/string_number_conversions.h" |
| 14 #include "content/browser/gpu/compositor_util.h" | 15 #include "content/browser/gpu/compositor_util.h" |
| 15 #include "content/browser/gpu/gpu_data_manager_impl.h" | 16 #include "content/browser/gpu/gpu_data_manager_impl.h" |
| 16 #include "content/browser/gpu/gpu_process_host.h" | 17 #include "content/browser/gpu/gpu_process_host.h" |
| 17 #include "content/browser/gpu/gpu_surface_tracker.h" | 18 #include "content/browser/gpu/gpu_surface_tracker.h" |
| 18 #include "content/browser/renderer_host/render_process_host_impl.h" | 19 #include "content/browser/renderer_host/render_process_host_impl.h" |
| 19 #include "content/browser/renderer_host/render_view_host_impl.h" | 20 #include "content/browser/renderer_host/render_view_host_impl.h" |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 ->OnMessageReceived(message)) | 174 ->OnMessageReceived(message)) |
| 174 return true; | 175 return true; |
| 175 #endif | 176 #endif |
| 176 | 177 |
| 177 if (message.routing_id() != MSG_ROUTING_CONTROL) | 178 if (message.routing_id() != MSG_ROUTING_CONTROL) |
| 178 return false; | 179 return false; |
| 179 | 180 |
| 180 return OnControlMessageReceived(message); | 181 return OnControlMessageReceived(message); |
| 181 } | 182 } |
| 182 | 183 |
| 184 void GpuProcessHostUIShim::RelinquishGpuResources( |
| 185 const base::Closure& callback) { |
| 186 DCHECK(relinquish_callback_.is_null()); |
| 187 relinquish_callback_ = callback; |
| 188 Send(new GpuMsg_RelinquishResources()); |
| 189 } |
| 190 |
| 183 void GpuProcessHostUIShim::SimulateRemoveAllContext() { | 191 void GpuProcessHostUIShim::SimulateRemoveAllContext() { |
| 184 Send(new GpuMsg_Clean()); | 192 Send(new GpuMsg_Clean()); |
| 185 } | 193 } |
| 186 | 194 |
| 187 void GpuProcessHostUIShim::SimulateCrash() { | 195 void GpuProcessHostUIShim::SimulateCrash() { |
| 188 Send(new GpuMsg_Crash()); | 196 Send(new GpuMsg_Crash()); |
| 189 } | 197 } |
| 190 | 198 |
| 191 void GpuProcessHostUIShim::SimulateHang() { | 199 void GpuProcessHostUIShim::SimulateHang() { |
| 192 Send(new GpuMsg_Hang()); | 200 Send(new GpuMsg_Hang()); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 205 IPC_MESSAGE_HANDLER(GpuHostMsg_OnLogMessage, | 213 IPC_MESSAGE_HANDLER(GpuHostMsg_OnLogMessage, |
| 206 OnLogMessage) | 214 OnLogMessage) |
| 207 IPC_MESSAGE_HANDLER(GpuHostMsg_AcceleratedSurfaceInitialized, | 215 IPC_MESSAGE_HANDLER(GpuHostMsg_AcceleratedSurfaceInitialized, |
| 208 OnAcceleratedSurfaceInitialized) | 216 OnAcceleratedSurfaceInitialized) |
| 209 IPC_MESSAGE_HANDLER(GpuHostMsg_AcceleratedSurfaceBuffersSwapped, | 217 IPC_MESSAGE_HANDLER(GpuHostMsg_AcceleratedSurfaceBuffersSwapped, |
| 210 OnAcceleratedSurfaceBuffersSwapped) | 218 OnAcceleratedSurfaceBuffersSwapped) |
| 211 IPC_MESSAGE_HANDLER(GpuHostMsg_GraphicsInfoCollected, | 219 IPC_MESSAGE_HANDLER(GpuHostMsg_GraphicsInfoCollected, |
| 212 OnGraphicsInfoCollected) | 220 OnGraphicsInfoCollected) |
| 213 IPC_MESSAGE_HANDLER(GpuHostMsg_VideoMemoryUsageStats, | 221 IPC_MESSAGE_HANDLER(GpuHostMsg_VideoMemoryUsageStats, |
| 214 OnVideoMemoryUsageStatsReceived); | 222 OnVideoMemoryUsageStatsReceived); |
| 223 IPC_MESSAGE_HANDLER(GpuHostMsg_ResourcesRelinquished, |
| 224 OnResourcesRelinquished) |
| 215 | 225 |
| 216 IPC_MESSAGE_UNHANDLED_ERROR() | 226 IPC_MESSAGE_UNHANDLED_ERROR() |
| 217 IPC_END_MESSAGE_MAP() | 227 IPC_END_MESSAGE_MAP() |
| 218 | 228 |
| 219 return true; | 229 return true; |
| 220 } | 230 } |
| 221 | 231 |
| 222 void GpuProcessHostUIShim::OnLogMessage( | 232 void GpuProcessHostUIShim::OnLogMessage( |
| 223 int level, | 233 int level, |
| 224 const std::string& header, | 234 const std::string& header, |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 275 NOTREACHED(); | 285 NOTREACHED(); |
| 276 #endif | 286 #endif |
| 277 } | 287 } |
| 278 | 288 |
| 279 void GpuProcessHostUIShim::OnVideoMemoryUsageStatsReceived( | 289 void GpuProcessHostUIShim::OnVideoMemoryUsageStatsReceived( |
| 280 const GPUVideoMemoryUsageStats& video_memory_usage_stats) { | 290 const GPUVideoMemoryUsageStats& video_memory_usage_stats) { |
| 281 GpuDataManagerImpl::GetInstance()->UpdateVideoMemoryUsageStats( | 291 GpuDataManagerImpl::GetInstance()->UpdateVideoMemoryUsageStats( |
| 282 video_memory_usage_stats); | 292 video_memory_usage_stats); |
| 283 } | 293 } |
| 284 | 294 |
| 295 void GpuProcessHostUIShim::OnResourcesRelinquished() { |
| 296 if (!relinquish_callback_.is_null()) { |
| 297 base::ResetAndReturn(&relinquish_callback_).Run(); |
| 298 } |
| 299 } |
| 300 |
| 285 } // namespace content | 301 } // namespace content |
| OLD | NEW |