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

Side by Side Diff: chrome/browser/nacl_host/nacl_process_host.cc

Issue 16154005: Remove dependency from NaCl code on chrome_constants. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years, 6 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 "chrome/browser/nacl_host/nacl_process_host.h" 5 #include "chrome/browser/nacl_host/nacl_process_host.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/base_switches.h" 10 #include "base/base_switches.h"
11 #include "base/bind.h" 11 #include "base/bind.h"
12 #include "base/command_line.h" 12 #include "base/command_line.h"
13 #include "base/file_util.h" 13 #include "base/file_util.h"
14 #include "base/message_loop.h" 14 #include "base/message_loop.h"
15 #include "base/metrics/histogram.h" 15 #include "base/metrics/histogram.h"
16 #include "base/path_service.h" 16 #include "base/path_service.h"
17 #include "base/process_util.h" 17 #include "base/process_util.h"
18 #include "base/string_util.h" 18 #include "base/string_util.h"
19 #include "base/stringprintf.h" 19 #include "base/stringprintf.h"
20 #include "base/strings/string_number_conversions.h" 20 #include "base/strings/string_number_conversions.h"
21 #include "base/strings/string_split.h" 21 #include "base/strings/string_split.h"
22 #include "base/utf_string_conversions.h" 22 #include "base/utf_string_conversions.h"
23 #include "base/win/windows_version.h" 23 #include "base/win/windows_version.h"
24 #include "build/build_config.h" 24 #include "build/build_config.h"
25 #include "chrome/browser/extensions/extension_info_map.h" 25 #include "chrome/browser/extensions/extension_info_map.h"
26 #include "chrome/browser/nacl_host/nacl_browser.h" 26 #include "chrome/browser/nacl_host/nacl_browser.h"
27 #include "chrome/browser/renderer_host/chrome_render_message_filter.h" 27 #include "chrome/browser/renderer_host/chrome_render_message_filter.h"
28 #include "chrome/browser/renderer_host/pepper/chrome_browser_pepper_host_factory .h" 28 #include "chrome/browser/renderer_host/pepper/chrome_browser_pepper_host_factory .h"
29 #include "chrome/common/chrome_constants.h"
30 #include "chrome/common/chrome_paths.h" 29 #include "chrome/common/chrome_paths.h"
31 #include "chrome/common/chrome_process_type.h" 30 #include "chrome/common/chrome_process_type.h"
32 #include "chrome/common/chrome_switches.h" 31 #include "chrome/common/chrome_switches.h"
33 #include "chrome/common/chrome_version_info.h" 32 #include "chrome/common/chrome_version_info.h"
34 #include "chrome/common/logging_chrome.h" 33 #include "chrome/common/logging_chrome.h"
35 #include "chrome/common/nacl_cmd_line.h" 34 #include "chrome/common/nacl_cmd_line.h"
36 #include "chrome/common/nacl_messages.h" 35 #include "chrome/common/nacl_messages.h"
37 #include "chrome/common/render_messages.h" 36 #include "chrome/common/render_messages.h"
38 #include "content/public/browser/browser_child_process_host.h" 37 #include "content/public/browser/browser_child_process_host.h"
39 #include "content/public/browser/browser_ppapi_host.h" 38 #include "content/public/browser/browser_ppapi_host.h"
(...skipping 501 matching lines...) Expand 10 before | Expand all | Expand 10 after
541 int flags = ChildProcessHost::CHILD_NORMAL; 540 int flags = ChildProcessHost::CHILD_NORMAL;
542 #endif 541 #endif
543 542
544 base::FilePath exe_path = ChildProcessHost::GetChildPath(flags); 543 base::FilePath exe_path = ChildProcessHost::GetChildPath(flags);
545 if (exe_path.empty()) 544 if (exe_path.empty())
546 return false; 545 return false;
547 546
548 #if defined(OS_WIN) 547 #if defined(OS_WIN)
549 // On Windows 64-bit NaCl loader is called nacl64.exe instead of chrome.exe 548 // On Windows 64-bit NaCl loader is called nacl64.exe instead of chrome.exe
550 if (RunningOnWOW64()) { 549 if (RunningOnWOW64()) {
551 base::FilePath module_path; 550 if (!GetNaclAppPath(exe_path)) {
552 if (!PathService::Get(base::FILE_MODULE, &module_path)) {
553 LOG(ERROR) << "NaCl process launch failed: could not resolve module";
554 return false; 551 return false;
555 } 552 }
556 exe_path = module_path.DirName().Append(chrome::kNaClAppName);
557 } 553 }
558 #endif 554 #endif
559 555
560 scoped_ptr<CommandLine> cmd_line(new CommandLine(exe_path)); 556 scoped_ptr<CommandLine> cmd_line(new CommandLine(exe_path));
561 nacl::CopyNaClCommandLineArguments(cmd_line.get()); 557 nacl::CopyNaClCommandLineArguments(cmd_line.get());
562 558
563 cmd_line->AppendSwitchASCII(switches::kProcessType, 559 cmd_line->AppendSwitchASCII(switches::kProcessType,
564 switches::kNaClLoaderProcess); 560 switches::kNaClLoaderProcess);
565 cmd_line->AppendSwitchASCII(switches::kProcessChannelID, channel_id); 561 cmd_line->AppendSwitchASCII(switches::kProcessChannelID, channel_id);
566 if (logging::DialogsAreSuppressed()) 562 if (logging::DialogsAreSuppressed())
(...skipping 500 matching lines...) Expand 10 before | Expand all | Expand 10 after
1067 weak_factory_.GetWeakPtr(), nacl_pid, process_handle, info); 1063 weak_factory_.GetWeakPtr(), nacl_pid, process_handle, info);
1068 } else { 1064 } else {
1069 NaClStartDebugExceptionHandlerThread( 1065 NaClStartDebugExceptionHandlerThread(
1070 process_handle.Take(), info, 1066 process_handle.Take(), info,
1071 base::MessageLoopProxy::current(), 1067 base::MessageLoopProxy::current(),
1072 base::Bind(&NaClProcessHost::OnDebugExceptionHandlerLaunchedByBroker, 1068 base::Bind(&NaClProcessHost::OnDebugExceptionHandlerLaunchedByBroker,
1073 weak_factory_.GetWeakPtr())); 1069 weak_factory_.GetWeakPtr()));
1074 return true; 1070 return true;
1075 } 1071 }
1076 } 1072 }
1073
1074 bool NaClProcessHost::GetNaclAppPath(base::FilePath& exe_path)
1075 {
Mark Seaborn 2013/05/31 19:42:30 Style is that '{' goes on previous line
1076 static const wchar_t kNaClAppName[] = L"nacl64";
dmichael (off chromium) 2013/05/31 19:42:18 nit: static doesn't really add anything here.
Lei Zhang 2013/05/31 19:45:48 Is this Windows-only code? If not, then it won't w
Mark Seaborn 2013/05/31 19:51:13 Yes, this is Windows-only. It's inside "#if defin
1077 base::FilePath module_path;
1078 if (!PathService::Get(base::FILE_MODULE, &module_path)) {
1079 LOG(ERROR) << "NaCl process launch failed: could not resolve module";
dmichael (off chromium) 2013/05/31 19:42:18 FWIW, this log used to only be emitted from this f
1080 return false;
1081 }
1082 exe_path = module_path.DirName().Append(kNaClAppName);
dmichael (off chromium) 2013/05/31 19:42:18 optional nit: Seems like you could just stick the
1083 return true;
1084 }
1085
Mark Seaborn 2013/05/31 19:51:13 Nit: make the whitespace after "#if" and before "#
Mark Seaborn 2013/05/31 19:51:13 Nit: make the whitespace after "#if" and before "#
1077 #endif 1086 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698