Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(145)

Side by Side Diff: content/browser/gpu/gpu_process_host_ui_shim.cc

Issue 1249313004: Remove GPU relinquish resources infrastructure and stop GPU process. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Only skip recording crash in ~GpuProcessHost() Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/callback_helpers.h"
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 LAZY_INSTANCE_INITIALIZER; 53 LAZY_INSTANCE_INITIALIZER;
54 54
55 void SendOnIOThreadTask(int host_id, IPC::Message* msg) { 55 void SendOnIOThreadTask(int host_id, IPC::Message* msg) {
56 GpuProcessHost* host = GpuProcessHost::FromID(host_id); 56 GpuProcessHost* host = GpuProcessHost::FromID(host_id);
57 if (host) 57 if (host)
58 host->Send(msg); 58 host->Send(msg);
59 else 59 else
60 delete msg; 60 delete msg;
61 } 61 }
62 62
63 void StopGpuProcessOnIO(int host_id) {
64 GpuProcessHost* host = GpuProcessHost::FromID(host_id);
65 if (host)
66 host->StopGpuProcess();
67 }
68
63 class ScopedSendOnIOThread { 69 class ScopedSendOnIOThread {
64 public: 70 public:
65 ScopedSendOnIOThread(int host_id, IPC::Message* msg) 71 ScopedSendOnIOThread(int host_id, IPC::Message* msg)
66 : host_id_(host_id), 72 : host_id_(host_id),
67 msg_(msg), 73 msg_(msg),
68 cancelled_(false) { 74 cancelled_(false) {
69 } 75 }
70 76
71 ~ScopedSendOnIOThread() { 77 ~ScopedSendOnIOThread() {
72 if (!cancelled_) { 78 if (!cancelled_) {
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 ->OnMessageReceived(message)) 191 ->OnMessageReceived(message))
186 return true; 192 return true;
187 #endif 193 #endif
188 194
189 if (message.routing_id() != MSG_ROUTING_CONTROL) 195 if (message.routing_id() != MSG_ROUTING_CONTROL)
190 return false; 196 return false;
191 197
192 return OnControlMessageReceived(message); 198 return OnControlMessageReceived(message);
193 } 199 }
194 200
195 void GpuProcessHostUIShim::RelinquishGpuResources( 201 void GpuProcessHostUIShim::StopGpuProcess(const base::Closure& callback) {
196 const base::Closure& callback) { 202 close_callback_ = callback;
197 DCHECK(relinquish_callback_.is_null()); 203
198 relinquish_callback_ = callback; 204 BrowserThread::PostTask(
199 Send(new GpuMsg_RelinquishResources()); 205 BrowserThread::IO, FROM_HERE, base::Bind(&StopGpuProcessOnIO, host_id_));
200 } 206 }
201 207
202 void GpuProcessHostUIShim::SimulateRemoveAllContext() { 208 void GpuProcessHostUIShim::SimulateRemoveAllContext() {
203 Send(new GpuMsg_Clean()); 209 Send(new GpuMsg_Clean());
204 } 210 }
205 211
206 void GpuProcessHostUIShim::SimulateCrash() { 212 void GpuProcessHostUIShim::SimulateCrash() {
207 Send(new GpuMsg_Crash()); 213 Send(new GpuMsg_Crash());
208 } 214 }
209 215
210 void GpuProcessHostUIShim::SimulateHang() { 216 void GpuProcessHostUIShim::SimulateHang() {
211 Send(new GpuMsg_Hang()); 217 Send(new GpuMsg_Hang());
212 } 218 }
213 219
214 GpuProcessHostUIShim::~GpuProcessHostUIShim() { 220 GpuProcessHostUIShim::~GpuProcessHostUIShim() {
215 DCHECK(CalledOnValidThread()); 221 DCHECK(CalledOnValidThread());
222 if (!close_callback_.is_null())
223 base::ResetAndReturn(&close_callback_).Run();
216 g_hosts_by_id.Pointer()->Remove(host_id_); 224 g_hosts_by_id.Pointer()->Remove(host_id_);
217 } 225 }
218 226
219 bool GpuProcessHostUIShim::OnControlMessageReceived( 227 bool GpuProcessHostUIShim::OnControlMessageReceived(
220 const IPC::Message& message) { 228 const IPC::Message& message) {
221 DCHECK(CalledOnValidThread()); 229 DCHECK(CalledOnValidThread());
222 230
223 IPC_BEGIN_MESSAGE_MAP(GpuProcessHostUIShim, message) 231 IPC_BEGIN_MESSAGE_MAP(GpuProcessHostUIShim, message)
224 IPC_MESSAGE_HANDLER(GpuHostMsg_OnLogMessage, 232 IPC_MESSAGE_HANDLER(GpuHostMsg_OnLogMessage,
225 OnLogMessage) 233 OnLogMessage)
226 IPC_MESSAGE_HANDLER(GpuHostMsg_AcceleratedSurfaceInitialized, 234 IPC_MESSAGE_HANDLER(GpuHostMsg_AcceleratedSurfaceInitialized,
227 OnAcceleratedSurfaceInitialized) 235 OnAcceleratedSurfaceInitialized)
228 #if defined(OS_MACOSX) 236 #if defined(OS_MACOSX)
229 IPC_MESSAGE_HANDLER(GpuHostMsg_AcceleratedSurfaceBuffersSwapped, 237 IPC_MESSAGE_HANDLER(GpuHostMsg_AcceleratedSurfaceBuffersSwapped,
230 OnAcceleratedSurfaceBuffersSwapped) 238 OnAcceleratedSurfaceBuffersSwapped)
231 #endif 239 #endif
232 IPC_MESSAGE_HANDLER(GpuHostMsg_GraphicsInfoCollected, 240 IPC_MESSAGE_HANDLER(GpuHostMsg_GraphicsInfoCollected,
233 OnGraphicsInfoCollected) 241 OnGraphicsInfoCollected)
234 IPC_MESSAGE_HANDLER(GpuHostMsg_VideoMemoryUsageStats, 242 IPC_MESSAGE_HANDLER(GpuHostMsg_VideoMemoryUsageStats,
235 OnVideoMemoryUsageStatsReceived); 243 OnVideoMemoryUsageStatsReceived);
236 IPC_MESSAGE_HANDLER(GpuHostMsg_ResourcesRelinquished,
237 OnResourcesRelinquished)
238 IPC_MESSAGE_HANDLER(GpuHostMsg_AddSubscription, OnAddSubscription); 244 IPC_MESSAGE_HANDLER(GpuHostMsg_AddSubscription, OnAddSubscription);
239 IPC_MESSAGE_HANDLER(GpuHostMsg_RemoveSubscription, OnRemoveSubscription); 245 IPC_MESSAGE_HANDLER(GpuHostMsg_RemoveSubscription, OnRemoveSubscription);
240 246
241 IPC_MESSAGE_UNHANDLED_ERROR() 247 IPC_MESSAGE_UNHANDLED_ERROR()
242 IPC_END_MESSAGE_MAP() 248 IPC_END_MESSAGE_MAP()
243 249
244 return true; 250 return true;
245 } 251 }
246 252
247 void GpuProcessHostUIShim::OnLogMessage( 253 void GpuProcessHostUIShim::OnLogMessage(
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
307 Send(new AcceleratedSurfaceMsg_BufferPresented(params.route_id, ack_params)); 313 Send(new AcceleratedSurfaceMsg_BufferPresented(params.route_id, ack_params));
308 } 314 }
309 #endif 315 #endif
310 316
311 void GpuProcessHostUIShim::OnVideoMemoryUsageStatsReceived( 317 void GpuProcessHostUIShim::OnVideoMemoryUsageStatsReceived(
312 const GPUVideoMemoryUsageStats& video_memory_usage_stats) { 318 const GPUVideoMemoryUsageStats& video_memory_usage_stats) {
313 GpuDataManagerImpl::GetInstance()->UpdateVideoMemoryUsageStats( 319 GpuDataManagerImpl::GetInstance()->UpdateVideoMemoryUsageStats(
314 video_memory_usage_stats); 320 video_memory_usage_stats);
315 } 321 }
316 322
317 void GpuProcessHostUIShim::OnResourcesRelinquished() {
318 if (!relinquish_callback_.is_null()) {
319 base::ResetAndReturn(&relinquish_callback_).Run();
320 }
321 }
322
323 void GpuProcessHostUIShim::OnAddSubscription( 323 void GpuProcessHostUIShim::OnAddSubscription(
324 int32 process_id, unsigned int target) { 324 int32 process_id, unsigned int target) {
325 RenderProcessHost* rph = RenderProcessHost::FromID(process_id); 325 RenderProcessHost* rph = RenderProcessHost::FromID(process_id);
326 if (rph) { 326 if (rph) {
327 rph->OnAddSubscription(target); 327 rph->OnAddSubscription(target);
328 } 328 }
329 } 329 }
330 330
331 void GpuProcessHostUIShim::OnRemoveSubscription( 331 void GpuProcessHostUIShim::OnRemoveSubscription(
332 int32 process_id, unsigned int target) { 332 int32 process_id, unsigned int target) {
333 RenderProcessHost* rph = RenderProcessHost::FromID(process_id); 333 RenderProcessHost* rph = RenderProcessHost::FromID(process_id);
334 if (rph) { 334 if (rph) {
335 rph->OnRemoveSubscription(target); 335 rph->OnRemoveSubscription(target);
336 } 336 }
337 } 337 }
338 338
339 } // namespace content 339 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698