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/callback_helpers.h" |
(...skipping 22 matching lines...) Expand all Loading... |
33 | 33 |
34 namespace content { | 34 namespace content { |
35 | 35 |
36 namespace { | 36 namespace { |
37 | 37 |
38 // One of the linux specific headers defines this as a macro. | 38 // One of the linux specific headers defines this as a macro. |
39 #ifdef DestroyAll | 39 #ifdef DestroyAll |
40 #undef DestroyAll | 40 #undef DestroyAll |
41 #endif | 41 #endif |
42 | 42 |
43 base::LazyInstance<IDMap<GpuProcessHostUIShim> > g_hosts_by_id = | 43 base::LazyInstance<IDMap<GpuProcessHostUIShim*>> g_hosts_by_id = |
44 LAZY_INSTANCE_INITIALIZER; | 44 LAZY_INSTANCE_INITIALIZER; |
45 | 45 |
46 void SendOnIOThreadTask(int host_id, IPC::Message* msg) { | 46 void SendOnIOThreadTask(int host_id, IPC::Message* msg) { |
47 GpuProcessHost* host = GpuProcessHost::FromID(host_id); | 47 GpuProcessHost* host = GpuProcessHost::FromID(host_id); |
48 if (host) | 48 if (host) |
49 host->Send(msg); | 49 host->Send(msg); |
50 else | 50 else |
51 delete msg; | 51 delete msg; |
52 } | 52 } |
53 | 53 |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 ->OnChannelDestroyed(host_id); | 95 ->OnChannelDestroyed(host_id); |
96 #endif | 96 #endif |
97 | 97 |
98 delete FromID(host_id); | 98 delete FromID(host_id); |
99 } | 99 } |
100 | 100 |
101 // static | 101 // static |
102 void GpuProcessHostUIShim::DestroyAll() { | 102 void GpuProcessHostUIShim::DestroyAll() { |
103 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 103 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
104 while (!g_hosts_by_id.Pointer()->IsEmpty()) { | 104 while (!g_hosts_by_id.Pointer()->IsEmpty()) { |
105 IDMap<GpuProcessHostUIShim>::iterator it(g_hosts_by_id.Pointer()); | 105 IDMap<GpuProcessHostUIShim*>::iterator it(g_hosts_by_id.Pointer()); |
106 delete it.GetCurrentValue(); | 106 delete it.GetCurrentValue(); |
107 } | 107 } |
108 } | 108 } |
109 | 109 |
110 // static | 110 // static |
111 GpuProcessHostUIShim* GpuProcessHostUIShim::FromID(int host_id) { | 111 GpuProcessHostUIShim* GpuProcessHostUIShim::FromID(int host_id) { |
112 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 112 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
113 return g_hosts_by_id.Pointer()->Lookup(host_id); | 113 return g_hosts_by_id.Pointer()->Lookup(host_id); |
114 } | 114 } |
115 | 115 |
116 // static | 116 // static |
117 GpuProcessHostUIShim* GpuProcessHostUIShim::GetOneInstance() { | 117 GpuProcessHostUIShim* GpuProcessHostUIShim::GetOneInstance() { |
118 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 118 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
119 if (g_hosts_by_id.Pointer()->IsEmpty()) | 119 if (g_hosts_by_id.Pointer()->IsEmpty()) |
120 return NULL; | 120 return NULL; |
121 IDMap<GpuProcessHostUIShim>::iterator it(g_hosts_by_id.Pointer()); | 121 IDMap<GpuProcessHostUIShim*>::iterator it(g_hosts_by_id.Pointer()); |
122 return it.GetCurrentValue(); | 122 return it.GetCurrentValue(); |
123 } | 123 } |
124 | 124 |
125 bool GpuProcessHostUIShim::Send(IPC::Message* msg) { | 125 bool GpuProcessHostUIShim::Send(IPC::Message* msg) { |
126 DCHECK(CalledOnValidThread()); | 126 DCHECK(CalledOnValidThread()); |
127 return BrowserThread::PostTask(BrowserThread::IO, | 127 return BrowserThread::PostTask(BrowserThread::IO, |
128 FROM_HERE, | 128 FROM_HERE, |
129 base::Bind(&SendOnIOThreadTask, | 129 base::Bind(&SendOnIOThreadTask, |
130 host_id_, | 130 host_id_, |
131 msg)); | 131 msg)); |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
207 GpuDataManagerImpl::GetInstance()->UpdateGpuInfo(gpu_info); | 207 GpuDataManagerImpl::GetInstance()->UpdateGpuInfo(gpu_info); |
208 } | 208 } |
209 | 209 |
210 void GpuProcessHostUIShim::OnVideoMemoryUsageStatsReceived( | 210 void GpuProcessHostUIShim::OnVideoMemoryUsageStatsReceived( |
211 const gpu::VideoMemoryUsageStats& video_memory_usage_stats) { | 211 const gpu::VideoMemoryUsageStats& video_memory_usage_stats) { |
212 GpuDataManagerImpl::GetInstance()->UpdateVideoMemoryUsageStats( | 212 GpuDataManagerImpl::GetInstance()->UpdateVideoMemoryUsageStats( |
213 video_memory_usage_stats); | 213 video_memory_usage_stats); |
214 } | 214 } |
215 | 215 |
216 } // namespace content | 216 } // namespace content |
OLD | NEW |