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

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

Issue 2585963002: Clarifying the parameters ownership of BrowserChildProcessHost::Launch() (Closed)
Patch Set: Fixed crasher on Windows. Created 3 years, 12 months 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
OLDNEW
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/ppapi_plugin_process_host.h" 5 #include "content/browser/ppapi_plugin_process_host.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <string> 9 #include <string>
10 #include <utility> 10 #include <utility>
(...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after
366 ChildProcessHost::CHILD_NORMAL; 366 ChildProcessHost::CHILD_NORMAL;
367 #else 367 #else
368 int flags = ChildProcessHost::CHILD_NORMAL; 368 int flags = ChildProcessHost::CHILD_NORMAL;
369 #endif 369 #endif
370 base::FilePath exe_path = ChildProcessHost::GetChildPath(flags); 370 base::FilePath exe_path = ChildProcessHost::GetChildPath(flags);
371 if (exe_path.empty()) { 371 if (exe_path.empty()) {
372 VLOG(1) << "Pepper plugin exe path is empty."; 372 VLOG(1) << "Pepper plugin exe path is empty.";
373 return false; 373 return false;
374 } 374 }
375 375
376 base::CommandLine* cmd_line = new base::CommandLine(exe_path); 376 std::unique_ptr<base::CommandLine> cmd_line =
377 base::MakeUnique<base::CommandLine>(exe_path);
377 cmd_line->AppendSwitchASCII(switches::kProcessType, 378 cmd_line->AppendSwitchASCII(switches::kProcessType,
378 is_broker_ ? switches::kPpapiBrokerProcess 379 is_broker_ ? switches::kPpapiBrokerProcess
379 : switches::kPpapiPluginProcess); 380 : switches::kPpapiPluginProcess);
380 BrowserChildProcessHostImpl::CopyFeatureAndFieldTrialFlags(cmd_line); 381 BrowserChildProcessHostImpl::CopyFeatureAndFieldTrialFlags(cmd_line.get());
381 382
382 #if defined(OS_WIN) 383 #if defined(OS_WIN)
383 cmd_line->AppendArg(is_broker_ ? switches::kPrefetchArgumentPpapiBroker 384 cmd_line->AppendArg(is_broker_ ? switches::kPrefetchArgumentPpapiBroker
384 : switches::kPrefetchArgumentPpapi); 385 : switches::kPrefetchArgumentPpapi);
385 #endif // defined(OS_WIN) 386 #endif // defined(OS_WIN)
386 387
387 // These switches are forwarded to both plugin and broker pocesses. 388 // These switches are forwarded to both plugin and broker pocesses.
388 static const char* const kCommonForwardSwitches[] = { 389 static const char* const kCommonForwardSwitches[] = {
389 switches::kVModule 390 switches::kVModule
390 }; 391 };
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
429 switches::kPpapiSubpixelRenderingSetting, 430 switches::kPpapiSubpixelRenderingSetting,
430 base::IntToString(font_params.subpixel_rendering)); 431 base::IntToString(font_params.subpixel_rendering));
431 #endif 432 #endif
432 433
433 if (!plugin_launcher.empty()) 434 if (!plugin_launcher.empty())
434 cmd_line->PrependWrapper(plugin_launcher); 435 cmd_line->PrependWrapper(plugin_launcher);
435 436
436 // On posix, never use the zygote for the broker. Also, only use the zygote if 437 // On posix, never use the zygote for the broker. Also, only use the zygote if
437 // we are not using a plugin launcher - having a plugin launcher means we need 438 // we are not using a plugin launcher - having a plugin launcher means we need
438 // to use another process instead of just forking the zygote. 439 // to use another process instead of just forking the zygote.
439 process_->Launch(new PpapiPluginSandboxedProcessLauncherDelegate(is_broker_), 440 process_->Launch(
440 cmd_line, true); 441 base::MakeUnique<PpapiPluginSandboxedProcessLauncherDelegate>(is_broker_),
442 std::move(cmd_line), true);
441 return true; 443 return true;
442 } 444 }
443 445
444 void PpapiPluginProcessHost::RequestPluginChannel(Client* client) { 446 void PpapiPluginProcessHost::RequestPluginChannel(Client* client) {
445 base::ProcessHandle process_handle; 447 base::ProcessHandle process_handle;
446 int renderer_child_id; 448 int renderer_child_id;
447 client->GetPpapiChannelInfo(&process_handle, &renderer_child_id); 449 client->GetPpapiChannelInfo(&process_handle, &renderer_child_id);
448 450
449 base::ProcessId process_id = base::kNullProcessId; 451 base::ProcessId process_id = base::kNullProcessId;
450 if (process_handle != base::kNullProcessHandle) { 452 if (process_handle != base::kNullProcessHandle) {
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
547 // sent_requests_ queue should be the one that the plugin just created. 549 // sent_requests_ queue should be the one that the plugin just created.
548 Client* client = sent_requests_.front(); 550 Client* client = sent_requests_.front();
549 sent_requests_.pop(); 551 sent_requests_.pop();
550 552
551 const ChildProcessData& data = process_->GetData(); 553 const ChildProcessData& data = process_->GetData();
552 client->OnPpapiChannelOpened(channel_handle, base::GetProcId(data.handle), 554 client->OnPpapiChannelOpened(channel_handle, base::GetProcId(data.handle),
553 data.id); 555 data.id);
554 } 556 }
555 557
556 } // namespace content 558 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/gpu/gpu_process_host.cc ('k') | content/browser/renderer_host/render_process_host_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698