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 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 } | 121 } |
122 | 122 |
123 // static | 123 // static |
124 GpuProcessHostUIShim* GpuProcessHostUIShim::Create(int host_id) { | 124 GpuProcessHostUIShim* GpuProcessHostUIShim::Create(int host_id) { |
125 DCHECK(!FromID(host_id)); | 125 DCHECK(!FromID(host_id)); |
126 return new GpuProcessHostUIShim(host_id); | 126 return new GpuProcessHostUIShim(host_id); |
127 } | 127 } |
128 | 128 |
129 // static | 129 // static |
130 void GpuProcessHostUIShim::Destroy(int host_id, const std::string& message) { | 130 void GpuProcessHostUIShim::Destroy(int host_id, const std::string& message) { |
131 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 131 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
132 | 132 |
133 GpuDataManagerImpl::GetInstance()->AddLogMessage( | 133 GpuDataManagerImpl::GetInstance()->AddLogMessage( |
134 logging::LOG_ERROR, "GpuProcessHostUIShim", | 134 logging::LOG_ERROR, "GpuProcessHostUIShim", |
135 message); | 135 message); |
136 | 136 |
137 #if defined(USE_OZONE) | 137 #if defined(USE_OZONE) |
138 ui::OzonePlatform::GetInstance() | 138 ui::OzonePlatform::GetInstance() |
139 ->GetGpuPlatformSupportHost() | 139 ->GetGpuPlatformSupportHost() |
140 ->OnChannelDestroyed(host_id); | 140 ->OnChannelDestroyed(host_id); |
141 #endif | 141 #endif |
142 | 142 |
143 delete FromID(host_id); | 143 delete FromID(host_id); |
144 } | 144 } |
145 | 145 |
146 // static | 146 // static |
147 void GpuProcessHostUIShim::DestroyAll() { | 147 void GpuProcessHostUIShim::DestroyAll() { |
148 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 148 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
149 while (!g_hosts_by_id.Pointer()->IsEmpty()) { | 149 while (!g_hosts_by_id.Pointer()->IsEmpty()) { |
150 IDMap<GpuProcessHostUIShim>::iterator it(g_hosts_by_id.Pointer()); | 150 IDMap<GpuProcessHostUIShim>::iterator it(g_hosts_by_id.Pointer()); |
151 delete it.GetCurrentValue(); | 151 delete it.GetCurrentValue(); |
152 } | 152 } |
153 } | 153 } |
154 | 154 |
155 // static | 155 // static |
156 GpuProcessHostUIShim* GpuProcessHostUIShim::FromID(int host_id) { | 156 GpuProcessHostUIShim* GpuProcessHostUIShim::FromID(int host_id) { |
157 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 157 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
158 return g_hosts_by_id.Pointer()->Lookup(host_id); | 158 return g_hosts_by_id.Pointer()->Lookup(host_id); |
159 } | 159 } |
160 | 160 |
161 // static | 161 // static |
162 GpuProcessHostUIShim* GpuProcessHostUIShim::GetOneInstance() { | 162 GpuProcessHostUIShim* GpuProcessHostUIShim::GetOneInstance() { |
163 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 163 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
164 if (g_hosts_by_id.Pointer()->IsEmpty()) | 164 if (g_hosts_by_id.Pointer()->IsEmpty()) |
165 return NULL; | 165 return NULL; |
166 IDMap<GpuProcessHostUIShim>::iterator it(g_hosts_by_id.Pointer()); | 166 IDMap<GpuProcessHostUIShim>::iterator it(g_hosts_by_id.Pointer()); |
167 return it.GetCurrentValue(); | 167 return it.GetCurrentValue(); |
168 } | 168 } |
169 | 169 |
170 bool GpuProcessHostUIShim::Send(IPC::Message* msg) { | 170 bool GpuProcessHostUIShim::Send(IPC::Message* msg) { |
171 DCHECK(CalledOnValidThread()); | 171 DCHECK(CalledOnValidThread()); |
172 return BrowserThread::PostTask(BrowserThread::IO, | 172 return BrowserThread::PostTask(BrowserThread::IO, |
173 FROM_HERE, | 173 FROM_HERE, |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
329 | 329 |
330 void GpuProcessHostUIShim::OnRemoveSubscription( | 330 void GpuProcessHostUIShim::OnRemoveSubscription( |
331 int32 process_id, unsigned int target) { | 331 int32 process_id, unsigned int target) { |
332 RenderProcessHost* rph = RenderProcessHost::FromID(process_id); | 332 RenderProcessHost* rph = RenderProcessHost::FromID(process_id); |
333 if (rph) { | 333 if (rph) { |
334 rph->OnRemoveSubscription(target); | 334 rph->OnRemoveSubscription(target); |
335 } | 335 } |
336 } | 336 } |
337 | 337 |
338 } // namespace content | 338 } // namespace content |
OLD | NEW |