| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/utility_process_host.h" | 5 #include "chrome/browser/utility_process_host.h" |
| 6 | 6 |
| 7 #include "app/app_switches.h" | 7 #include "app/app_switches.h" |
| 8 #include "app/l10n_util.h" | 8 #include "app/l10n_util.h" |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
| 11 #include "base/message_loop.h" | 11 #include "base/message_loop.h" |
| 12 #include "chrome/browser/browser_process.h" |
| 12 #include "chrome/common/chrome_switches.h" | 13 #include "chrome/common/chrome_switches.h" |
| 13 #include "chrome/common/render_messages.h" | 14 #include "chrome/common/render_messages.h" |
| 14 #include "ipc/ipc_switches.h" | 15 #include "ipc/ipc_switches.h" |
| 15 | 16 |
| 16 UtilityProcessHost::UtilityProcessHost(ResourceDispatcherHost* rdh, | 17 UtilityProcessHost::UtilityProcessHost(ResourceDispatcherHost* rdh, |
| 17 Client* client, | 18 Client* client, |
| 18 ChromeThread::ID client_thread_id) | 19 ChromeThread::ID client_thread_id) |
| 19 : ChildProcessHost(UTILITY_PROCESS, rdh), | 20 : ChildProcessHost(UTILITY_PROCESS, rdh), |
| 20 client_(client), | 21 client_(client), |
| 21 client_thread_id_(client_thread_id) { | 22 client_thread_id_(client_thread_id) { |
| (...skipping 26 matching lines...) Expand all Loading... |
| 48 | 49 |
| 49 Send(new UtilityMsg_ParseUpdateManifest(xml)); | 50 Send(new UtilityMsg_ParseUpdateManifest(xml)); |
| 50 return true; | 51 return true; |
| 51 } | 52 } |
| 52 | 53 |
| 53 FilePath UtilityProcessHost::GetUtilityProcessCmd() { | 54 FilePath UtilityProcessHost::GetUtilityProcessCmd() { |
| 54 return GetChildPath(); | 55 return GetChildPath(); |
| 55 } | 56 } |
| 56 | 57 |
| 57 bool UtilityProcessHost::StartProcess(const FilePath& exposed_dir) { | 58 bool UtilityProcessHost::StartProcess(const FilePath& exposed_dir) { |
| 58 #if defined(OS_LINUX) | |
| 59 // TODO(port): We should not reach here on Linux (crbug.com/22703). | |
| 60 // (crbug.com/23837) covers enabling this on Linux. | |
| 61 NOTREACHED(); | |
| 62 return false; | |
| 63 #endif | |
| 64 | |
| 65 // Name must be set or metrics_service will crash in any test which | 59 // Name must be set or metrics_service will crash in any test which |
| 66 // launches a UtilityProcessHost. | 60 // launches a UtilityProcessHost. |
| 67 set_name(L"utility process"); | 61 set_name(L"utility process"); |
| 68 | 62 |
| 69 if (!CreateChannel()) | 63 if (!CreateChannel()) |
| 70 return false; | 64 return false; |
| 71 | 65 |
| 72 FilePath exe_path = GetUtilityProcessCmd(); | 66 FilePath exe_path = GetUtilityProcessCmd(); |
| 73 if (exe_path.empty()) { | 67 if (exe_path.empty()) { |
| 74 NOTREACHED() << "Unable to get utility process binary name."; | 68 NOTREACHED() << "Unable to get utility process binary name."; |
| 75 return false; | 69 return false; |
| 76 } | 70 } |
| 77 | 71 |
| 78 CommandLine* cmd_line = new CommandLine(exe_path); | 72 CommandLine* cmd_line = new CommandLine(exe_path); |
| 79 cmd_line->AppendSwitchWithValue(switches::kProcessType, | 73 cmd_line->AppendSwitchWithValue(switches::kProcessType, |
| 80 switches::kUtilityProcess); | 74 switches::kUtilityProcess); |
| 81 cmd_line->AppendSwitchWithValue(switches::kProcessChannelID, | 75 cmd_line->AppendSwitchWithValue(switches::kProcessChannelID, |
| 82 ASCIIToWide(channel_id())); | 76 ASCIIToWide(channel_id())); |
| 83 // Pass on the browser locale. | 77 // Pass on the browser locale. TODO(tony): This touches the disk and |
| 78 // checks for locale dlls/pak files. It shouldn't need to. |
| 84 std::string locale = l10n_util::GetApplicationLocale(L""); | 79 std::string locale = l10n_util::GetApplicationLocale(L""); |
| 85 cmd_line->AppendSwitchWithValue(switches::kLang, ASCIIToWide(locale)); | 80 cmd_line->AppendSwitchWithValue(switches::kLang, locale); |
| 86 | 81 |
| 87 SetCrashReporterCommandLine(cmd_line); | 82 SetCrashReporterCommandLine(cmd_line); |
| 88 | 83 |
| 89 const CommandLine& browser_command_line = *CommandLine::ForCurrentProcess(); | 84 const CommandLine& browser_command_line = *CommandLine::ForCurrentProcess(); |
| 90 if (browser_command_line.HasSwitch(switches::kChromeFrame)) | 85 if (browser_command_line.HasSwitch(switches::kChromeFrame)) |
| 91 cmd_line->AppendSwitch(switches::kChromeFrame); | 86 cmd_line->AppendSwitch(switches::kChromeFrame); |
| 92 | 87 |
| 93 #if defined(OS_POSIX) | 88 #if defined(OS_POSIX) |
| 94 // TODO(port): Sandbox this on Linux. Also, zygote this to work with | 89 // TODO(port): Sandbox this on Linux. Also, zygote this to work with |
| 95 // Linux updating. | 90 // Linux updating. |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 IPC_MESSAGE_HANDLER(UtilityHostMsg_UnpackWebResource_Succeeded, | 134 IPC_MESSAGE_HANDLER(UtilityHostMsg_UnpackWebResource_Succeeded, |
| 140 Client::OnUnpackWebResourceSucceeded) | 135 Client::OnUnpackWebResourceSucceeded) |
| 141 IPC_MESSAGE_HANDLER(UtilityHostMsg_UnpackWebResource_Failed, | 136 IPC_MESSAGE_HANDLER(UtilityHostMsg_UnpackWebResource_Failed, |
| 142 Client::OnUnpackWebResourceFailed) | 137 Client::OnUnpackWebResourceFailed) |
| 143 IPC_MESSAGE_HANDLER(UtilityHostMsg_ParseUpdateManifest_Succeeded, | 138 IPC_MESSAGE_HANDLER(UtilityHostMsg_ParseUpdateManifest_Succeeded, |
| 144 Client::OnParseUpdateManifestSucceeded) | 139 Client::OnParseUpdateManifestSucceeded) |
| 145 IPC_MESSAGE_HANDLER(UtilityHostMsg_ParseUpdateManifest_Failed, | 140 IPC_MESSAGE_HANDLER(UtilityHostMsg_ParseUpdateManifest_Failed, |
| 146 Client::OnParseUpdateManifestFailed) | 141 Client::OnParseUpdateManifestFailed) |
| 147 IPC_END_MESSAGE_MAP_EX() | 142 IPC_END_MESSAGE_MAP_EX() |
| 148 } | 143 } |
| OLD | NEW |