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 25 matching lines...) Expand all Loading... |
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*>>::DestructorAtExit | 43 base::LazyInstance<IDMap<GpuProcessHostUIShim*>>::DestructorAtExit |
44 g_hosts_by_id = LAZY_INSTANCE_INITIALIZER; | 44 g_hosts_by_id = LAZY_INSTANCE_INITIALIZER; |
45 | 45 |
46 void StopGpuProcessOnIO(int host_id) { | |
47 GpuProcessHost* host = GpuProcessHost::FromID(host_id); | |
48 if (host) | |
49 host->StopGpuProcess(); | |
50 } | |
51 | |
52 } // namespace | 46 } // namespace |
53 | 47 |
54 void RouteToGpuProcessHostUIShimTask(int host_id, const IPC::Message& msg) { | 48 void RouteToGpuProcessHostUIShimTask(int host_id, const IPC::Message& msg) { |
55 GpuProcessHostUIShim* ui_shim = GpuProcessHostUIShim::FromID(host_id); | 49 GpuProcessHostUIShim* ui_shim = GpuProcessHostUIShim::FromID(host_id); |
56 if (ui_shim) | 50 if (ui_shim) |
57 ui_shim->OnMessageReceived(msg); | 51 ui_shim->OnMessageReceived(msg); |
58 } | 52 } |
59 | 53 |
60 GpuProcessHostUIShim::GpuProcessHostUIShim(int host_id) | 54 GpuProcessHostUIShim::GpuProcessHostUIShim(int host_id) |
61 : host_id_(host_id) { | 55 : host_id_(host_id) { |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 ->OnMessageReceived(message)) | 108 ->OnMessageReceived(message)) |
115 return true; | 109 return true; |
116 #endif | 110 #endif |
117 | 111 |
118 if (message.routing_id() != MSG_ROUTING_CONTROL) | 112 if (message.routing_id() != MSG_ROUTING_CONTROL) |
119 return false; | 113 return false; |
120 | 114 |
121 return OnControlMessageReceived(message); | 115 return OnControlMessageReceived(message); |
122 } | 116 } |
123 | 117 |
124 void GpuProcessHostUIShim::StopGpuProcess(const base::Closure& callback) { | |
125 close_callback_ = callback; | |
126 | |
127 BrowserThread::PostTask( | |
128 BrowserThread::IO, FROM_HERE, base::Bind(&StopGpuProcessOnIO, host_id_)); | |
129 } | |
130 | |
131 GpuProcessHostUIShim::~GpuProcessHostUIShim() { | 118 GpuProcessHostUIShim::~GpuProcessHostUIShim() { |
132 DCHECK(CalledOnValidThread()); | 119 DCHECK(CalledOnValidThread()); |
133 if (!close_callback_.is_null()) | |
134 base::ResetAndReturn(&close_callback_).Run(); | |
135 g_hosts_by_id.Pointer()->Remove(host_id_); | 120 g_hosts_by_id.Pointer()->Remove(host_id_); |
136 } | 121 } |
137 | 122 |
138 bool GpuProcessHostUIShim::OnControlMessageReceived( | 123 bool GpuProcessHostUIShim::OnControlMessageReceived( |
139 const IPC::Message& message) { | 124 const IPC::Message& message) { |
140 DCHECK(CalledOnValidThread()); | 125 DCHECK(CalledOnValidThread()); |
141 | 126 |
142 IPC_BEGIN_MESSAGE_MAP(GpuProcessHostUIShim, message) | 127 IPC_BEGIN_MESSAGE_MAP(GpuProcessHostUIShim, message) |
143 IPC_MESSAGE_HANDLER(GpuHostMsg_OnLogMessage, OnLogMessage) | 128 IPC_MESSAGE_HANDLER(GpuHostMsg_OnLogMessage, OnLogMessage) |
144 IPC_MESSAGE_HANDLER(GpuHostMsg_GraphicsInfoCollected, | 129 IPC_MESSAGE_HANDLER(GpuHostMsg_GraphicsInfoCollected, |
(...skipping 16 matching lines...) Expand all Loading... |
161 void GpuProcessHostUIShim::OnGraphicsInfoCollected( | 146 void GpuProcessHostUIShim::OnGraphicsInfoCollected( |
162 const gpu::GPUInfo& gpu_info) { | 147 const gpu::GPUInfo& gpu_info) { |
163 // OnGraphicsInfoCollected is sent back after the GPU process successfully | 148 // OnGraphicsInfoCollected is sent back after the GPU process successfully |
164 // initializes GL. | 149 // initializes GL. |
165 TRACE_EVENT0("test_gpu", "OnGraphicsInfoCollected"); | 150 TRACE_EVENT0("test_gpu", "OnGraphicsInfoCollected"); |
166 | 151 |
167 GpuDataManagerImpl::GetInstance()->UpdateGpuInfo(gpu_info); | 152 GpuDataManagerImpl::GetInstance()->UpdateGpuInfo(gpu_info); |
168 } | 153 } |
169 | 154 |
170 } // namespace content | 155 } // namespace content |
OLD | NEW |