OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "chrome/browser/gpu_process_host.h" | 5 #include "chrome/browser/gpu_process_host.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/singleton.h" | 8 #include "base/singleton.h" |
9 #include "base/thread.h" | 9 #include "base/thread.h" |
10 #include "chrome/browser/browser_process.h" | 10 #include "chrome/browser/browser_process.h" |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 | 119 |
120 void GpuProcessHost::AddRoute(int32 routing_id, | 120 void GpuProcessHost::AddRoute(int32 routing_id, |
121 IPC::Channel::Listener* listener) { | 121 IPC::Channel::Listener* listener) { |
122 router_.AddRoute(routing_id, listener); | 122 router_.AddRoute(routing_id, listener); |
123 } | 123 } |
124 | 124 |
125 void GpuProcessHost::RemoveRoute(int32 routing_id) { | 125 void GpuProcessHost::RemoveRoute(int32 routing_id) { |
126 router_.RemoveRoute(routing_id); | 126 router_.RemoveRoute(routing_id); |
127 } | 127 } |
128 | 128 |
129 void GpuProcessHost::EstablishGpuChannel( | 129 void GpuProcessHost::EstablishGpuChannel(int renderer_id) { |
130 int renderer_id, | |
131 int routing_id) { | |
132 if (Send(new GpuMsg_EstablishChannel(renderer_id))) | 130 if (Send(new GpuMsg_EstablishChannel(renderer_id))) |
133 sent_requests_.push(ChannelRequest(renderer_id, routing_id)); | 131 sent_requests_.push(ChannelRequest(renderer_id)); |
134 else | 132 else |
135 ReplyToRenderer(renderer_id, routing_id, IPC::ChannelHandle()); | 133 ReplyToRenderer(renderer_id, IPC::ChannelHandle()); |
136 } | 134 } |
137 | 135 |
138 void GpuProcessHost::OnControlMessageReceived(const IPC::Message& message) { | 136 void GpuProcessHost::OnControlMessageReceived(const IPC::Message& message) { |
139 IPC_BEGIN_MESSAGE_MAP(GpuProcessHost, message) | 137 IPC_BEGIN_MESSAGE_MAP(GpuProcessHost, message) |
140 IPC_MESSAGE_HANDLER(GpuHostMsg_ChannelEstablished, OnChannelEstablished) | 138 IPC_MESSAGE_HANDLER(GpuHostMsg_ChannelEstablished, OnChannelEstablished) |
141 IPC_MESSAGE_UNHANDLED_ERROR() | 139 IPC_MESSAGE_UNHANDLED_ERROR() |
142 IPC_END_MESSAGE_MAP() | 140 IPC_END_MESSAGE_MAP() |
143 } | 141 } |
144 | 142 |
145 void GpuProcessHost::OnChannelEstablished( | 143 void GpuProcessHost::OnChannelEstablished( |
146 const IPC::ChannelHandle& channel_handle) { | 144 const IPC::ChannelHandle& channel_handle) { |
147 const ChannelRequest& request = sent_requests_.front(); | 145 const ChannelRequest& request = sent_requests_.front(); |
148 | 146 |
149 ReplyToRenderer(request.renderer_id, request.routing_id, channel_handle); | 147 ReplyToRenderer(request.renderer_id, channel_handle); |
150 sent_requests_.pop(); | 148 sent_requests_.pop(); |
151 } | 149 } |
152 | 150 |
153 void GpuProcessHost::ReplyToRenderer( | 151 void GpuProcessHost::ReplyToRenderer( |
154 int renderer_id, | 152 int renderer_id, |
155 int routing_id, | |
156 const IPC::ChannelHandle& channel) { | 153 const IPC::ChannelHandle& channel) { |
157 // Check whether the renderer process is still around. | 154 // Check whether the renderer process is still around. |
158 RenderProcessHost* process_host = RenderProcessHost::FromID(renderer_id); | 155 RenderProcessHost* process_host = RenderProcessHost::FromID(renderer_id); |
159 if (!process_host) | 156 if (!process_host) |
160 return; | 157 return; |
161 | 158 |
162 CHECK(process_host->Send(new ViewMsg_GpuChannelEstablished(routing_id, | 159 CHECK(process_host->Send(new ViewMsg_GpuChannelEstablished(channel))); |
163 channel))); | |
164 } | 160 } |
165 | 161 |
166 void GpuProcessHost::PropagateBrowserCommandLineToGpu( | 162 void GpuProcessHost::PropagateBrowserCommandLineToGpu( |
167 const CommandLine& browser_cmd, | 163 const CommandLine& browser_cmd, |
168 CommandLine* gpu_cmd) const { | 164 CommandLine* gpu_cmd) const { |
169 // Propagate the following switches to the GPU process command line (along | 165 // Propagate the following switches to the GPU process command line (along |
170 // with any associated values) if present in the browser command line. | 166 // with any associated values) if present in the browser command line. |
171 static const char* const switch_names[] = { | 167 static const char* const switch_names[] = { |
172 switches::kDisableLogging, | 168 switches::kDisableLogging, |
173 switches::kEnableLogging, | 169 switches::kEnableLogging, |
174 switches::kGpuStartupDialog, | 170 switches::kGpuStartupDialog, |
175 switches::kLoggingLevel, | 171 switches::kLoggingLevel, |
176 }; | 172 }; |
177 | 173 |
178 for (size_t i = 0; i < arraysize(switch_names); ++i) { | 174 for (size_t i = 0; i < arraysize(switch_names); ++i) { |
179 if (browser_cmd.HasSwitch(switch_names[i])) { | 175 if (browser_cmd.HasSwitch(switch_names[i])) { |
180 gpu_cmd->AppendSwitchWithValue(switch_names[i], | 176 gpu_cmd->AppendSwitchWithValue(switch_names[i], |
181 browser_cmd.GetSwitchValueASCII(switch_names[i])); | 177 browser_cmd.GetSwitchValueASCII(switch_names[i])); |
182 } | 178 } |
183 } | 179 } |
184 } | 180 } |
OLD | NEW |