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

Side by Side Diff: content/browser/plugin_process_host.cc

Issue 8774040: Don't make classes derive from ChildProcessHost, and instead have them use it through composition... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: fix linker errors on posix Created 9 years 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 | Annotate | Revision Log
« no previous file with comments | « content/browser/plugin_process_host.h ('k') | content/browser/ppapi_plugin_process_host.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/plugin_process_host.h" 5 #include "content/browser/plugin_process_host.h"
6 6
7 #if defined(OS_WIN) && !defined(USE_AURA) 7 #if defined(OS_WIN) && !defined(USE_AURA)
8 #include <windows.h> 8 #include <windows.h>
9 #elif defined(OS_POSIX) 9 #elif defined(OS_POSIX)
10 #include <utility> // for pair<> 10 #include <utility> // for pair<>
11 #endif 11 #endif
12 12
13 #include <vector> 13 #include <vector>
14 14
15 #include "base/base_switches.h" 15 #include "base/base_switches.h"
16 #include "base/bind.h" 16 #include "base/bind.h"
17 #include "base/command_line.h" 17 #include "base/command_line.h"
18 #include "base/file_path.h" 18 #include "base/file_path.h"
19 #include "base/file_util.h" 19 #include "base/file_util.h"
20 #include "base/logging.h" 20 #include "base/logging.h"
21 #include "base/path_service.h" 21 #include "base/path_service.h"
22 #include "base/string_util.h" 22 #include "base/string_util.h"
23 #include "base/utf_string_conversions.h" 23 #include "base/utf_string_conversions.h"
24 #include "content/browser/plugin_service.h" 24 #include "content/browser/plugin_service.h"
25 #include "content/common/child_process_host.h"
25 #include "content/common/plugin_messages.h" 26 #include "content/common/plugin_messages.h"
26 #include "content/common/resource_messages.h" 27 #include "content/common/resource_messages.h"
27 #include "content/public/browser/browser_thread.h" 28 #include "content/public/browser/browser_thread.h"
28 #include "content/public/browser/content_browser_client.h" 29 #include "content/public/browser/content_browser_client.h"
29 #include "content/public/browser/notification_types.h" 30 #include "content/public/browser/notification_types.h"
30 #include "content/public/common/content_switches.h" 31 #include "content/public/common/content_switches.h"
31 #include "content/public/common/process_type.h" 32 #include "content/public/common/process_type.h"
32 #include "ipc/ipc_switches.h" 33 #include "ipc/ipc_switches.h"
33 #include "ui/base/ui_base_switches.h" 34 #include "ui/base/ui_base_switches.h"
34 #include "ui/gfx/gl/gl_switches.h" 35 #include "ui/gfx/gl/gl_switches.h"
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 #endif 161 #endif
161 // Cancel all pending and sent requests. 162 // Cancel all pending and sent requests.
162 CancelRequests(); 163 CancelRequests();
163 } 164 }
164 165
165 bool PluginProcessHost::Init(const webkit::WebPluginInfo& info, 166 bool PluginProcessHost::Init(const webkit::WebPluginInfo& info,
166 const std::string& locale) { 167 const std::string& locale) {
167 info_ = info; 168 info_ = info;
168 set_name(info_.name); 169 set_name(info_.name);
169 170
170 if (!CreateChannel()) 171 if (!child_process_host()->CreateChannel())
171 return false; 172 return false;
172 173
173 // Build command line for plugin. When we have a plugin launcher, we can't 174 // Build command line for plugin. When we have a plugin launcher, we can't
174 // allow "self" on linux and we need the real file path. 175 // allow "self" on linux and we need the real file path.
175 const CommandLine& browser_command_line = *CommandLine::ForCurrentProcess(); 176 const CommandLine& browser_command_line = *CommandLine::ForCurrentProcess();
176 CommandLine::StringType plugin_launcher = 177 CommandLine::StringType plugin_launcher =
177 browser_command_line.GetSwitchValueNative(switches::kPluginLauncher); 178 browser_command_line.GetSwitchValueNative(switches::kPluginLauncher);
178 179
179 #if defined(OS_MACOSX) 180 #if defined(OS_MACOSX)
180 // Run the plug-in process in a mode tolerant of heap execution without 181 // Run the plug-in process in a mode tolerant of heap execution without
181 // explicit mprotect calls. Some plug-ins still rely on this quaint and 182 // explicit mprotect calls. Some plug-ins still rely on this quaint and
182 // archaic "feature." See http://crbug.com/93551. 183 // archaic "feature." See http://crbug.com/93551.
183 int flags = CHILD_ALLOW_HEAP_EXECUTION; 184 int flags = ChildProcessHost::CHILD_ALLOW_HEAP_EXECUTION;
184 #elif defined(OS_LINUX) 185 #elif defined(OS_LINUX)
185 int flags = plugin_launcher.empty() ? CHILD_ALLOW_SELF : CHILD_NORMAL; 186 int flags = plugin_launcher.empty() ? ChildProcessHost::CHILD_ALLOW_SELF :
187 ChildProcessHost::CHILD_NORMAL;
186 #else 188 #else
187 int flags = CHILD_NORMAL; 189 int flags = ChildProcessHost::CHILD_NORMAL;
188 #endif 190 #endif
189 191
190 FilePath exe_path = GetChildPath(flags); 192 FilePath exe_path = ChildProcessHost::GetChildPath(flags);
191 if (exe_path.empty()) 193 if (exe_path.empty())
192 return false; 194 return false;
193 195
194 CommandLine* cmd_line = new CommandLine(exe_path); 196 CommandLine* cmd_line = new CommandLine(exe_path);
195 // Put the process type and plugin path first so they're easier to see 197 // Put the process type and plugin path first so they're easier to see
196 // in process listings using native process management tools. 198 // in process listings using native process management tools.
197 cmd_line->AppendSwitchASCII(switches::kProcessType, switches::kPluginProcess); 199 cmd_line->AppendSwitchASCII(switches::kProcessType, switches::kPluginProcess);
198 cmd_line->AppendSwitchPath(switches::kPluginPath, info.path); 200 cmd_line->AppendSwitchPath(switches::kPluginPath, info.path);
199 201
200 // Propagate the following switches to the plugin command line (along with 202 // Propagate the following switches to the plugin command line (along with
(...skipping 25 matching lines...) Expand all
226 // If specified, prepend a launcher program to the command line. 228 // If specified, prepend a launcher program to the command line.
227 if (!plugin_launcher.empty()) 229 if (!plugin_launcher.empty())
228 cmd_line->PrependWrapper(plugin_launcher); 230 cmd_line->PrependWrapper(plugin_launcher);
229 231
230 if (!locale.empty()) { 232 if (!locale.empty()) {
231 // Pass on the locale so the null plugin will use the right language in the 233 // Pass on the locale so the null plugin will use the right language in the
232 // prompt to install the desired plugin. 234 // prompt to install the desired plugin.
233 cmd_line->AppendSwitchASCII(switches::kLang, locale); 235 cmd_line->AppendSwitchASCII(switches::kLang, locale);
234 } 236 }
235 237
236 cmd_line->AppendSwitchASCII(switches::kProcessChannelID, channel_id()); 238 cmd_line->AppendSwitchASCII(switches::kProcessChannelID,
239 child_process_host()->channel_id());
237 240
238 #if defined(OS_POSIX) 241 #if defined(OS_POSIX)
239 base::environment_vector env; 242 base::environment_vector env;
240 #if defined(OS_MACOSX) && !defined(__LP64__) 243 #if defined(OS_MACOSX) && !defined(__LP64__)
241 // Add our interposing library for Carbon. This is stripped back out in 244 // Add our interposing library for Carbon. This is stripped back out in
242 // plugin_main.cc, so changes here should be reflected there. 245 // plugin_main.cc, so changes here should be reflected there.
243 std::string interpose_list(plugin_interpose_strings::kInterposeLibraryPath); 246 std::string interpose_list(plugin_interpose_strings::kInterposeLibraryPath);
244 const char* existing_list = 247 const char* existing_list =
245 getenv(plugin_interpose_strings::kDYLDInsertLibrariesKey); 248 getenv(plugin_interpose_strings::kDYLDInsertLibrariesKey);
246 if (existing_list) { 249 if (existing_list) {
(...skipping 25 matching lines...) Expand all
272 275
273 return true; 276 return true;
274 } 277 }
275 278
276 void PluginProcessHost::ForceShutdown() { 279 void PluginProcessHost::ForceShutdown() {
277 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 280 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
278 Send(new PluginProcessMsg_NotifyRenderersOfPendingShutdown()); 281 Send(new PluginProcessMsg_NotifyRenderersOfPendingShutdown());
279 BrowserChildProcessHost::ForceShutdown(); 282 BrowserChildProcessHost::ForceShutdown();
280 } 283 }
281 284
285 void PluginProcessHost::AddFilter(IPC::ChannelProxy::MessageFilter* filter) {
286 child_process_host()->AddFilter(filter);
287 }
288
282 bool PluginProcessHost::OnMessageReceived(const IPC::Message& msg) { 289 bool PluginProcessHost::OnMessageReceived(const IPC::Message& msg) {
283 bool handled = true; 290 bool handled = true;
284 IPC_BEGIN_MESSAGE_MAP(PluginProcessHost, msg) 291 IPC_BEGIN_MESSAGE_MAP(PluginProcessHost, msg)
285 IPC_MESSAGE_HANDLER(PluginProcessHostMsg_ChannelCreated, OnChannelCreated) 292 IPC_MESSAGE_HANDLER(PluginProcessHostMsg_ChannelCreated, OnChannelCreated)
286 #if defined(OS_WIN) && !defined(USE_AURA) 293 #if defined(OS_WIN) && !defined(USE_AURA)
287 IPC_MESSAGE_HANDLER(PluginProcessHostMsg_PluginWindowDestroyed, 294 IPC_MESSAGE_HANDLER(PluginProcessHostMsg_PluginWindowDestroyed,
288 OnPluginWindowDestroyed) 295 OnPluginWindowDestroyed)
289 IPC_MESSAGE_HANDLER(PluginProcessHostMsg_ReparentPluginWindow, 296 IPC_MESSAGE_HANDLER(PluginProcessHostMsg_ReparentPluginWindow,
290 OnReparentPluginWindow) 297 OnReparentPluginWindow)
291 #endif 298 #endif
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
352 host->pending_requests_.erase(host->pending_requests_.begin() + i); 359 host->pending_requests_.erase(host->pending_requests_.begin() + i);
353 --i; 360 --i;
354 } 361 }
355 } 362 }
356 } 363 }
357 } 364 }
358 365
359 void PluginProcessHost::OpenChannelToPlugin(Client* client) { 366 void PluginProcessHost::OpenChannelToPlugin(Client* client) {
360 Notify(content::NOTIFICATION_CHILD_INSTANCE_CREATED); 367 Notify(content::NOTIFICATION_CHILD_INSTANCE_CREATED);
361 client->SetPluginInfo(info_); 368 client->SetPluginInfo(info_);
362 if (opening_channel()) { 369 if (child_process_host()->opening_channel()) {
363 // The channel is already in the process of being opened. Put 370 // The channel is already in the process of being opened. Put
364 // this "open channel" request into a queue of requests that will 371 // this "open channel" request into a queue of requests that will
365 // be run once the channel is open. 372 // be run once the channel is open.
366 pending_requests_.push_back(client); 373 pending_requests_.push_back(client);
367 return; 374 return;
368 } 375 }
369 376
370 // We already have an open channel, send a request right away to plugin. 377 // We already have an open channel, send a request right away to plugin.
371 RequestPluginChannel(client); 378 RequestPluginChannel(client);
372 } 379 }
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
415 } 422 }
416 423
417 void PluginProcessHost::OnChannelCreated( 424 void PluginProcessHost::OnChannelCreated(
418 const IPC::ChannelHandle& channel_handle) { 425 const IPC::ChannelHandle& channel_handle) {
419 Client* client = sent_requests_.front(); 426 Client* client = sent_requests_.front();
420 427
421 if (client) 428 if (client)
422 client->OnChannelOpened(channel_handle); 429 client->OnChannelOpened(channel_handle);
423 sent_requests_.pop_front(); 430 sent_requests_.pop_front();
424 } 431 }
OLDNEW
« no previous file with comments | « content/browser/plugin_process_host.h ('k') | content/browser/ppapi_plugin_process_host.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698