OLD | NEW |
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/utility_process_host.h" | 5 #include "content/browser/utility_process_host.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
11 #include "base/utf_string_conversions.h" | 11 #include "base/utf_string_conversions.h" |
12 #include "content/common/child_process_host.h" | 12 #include "content/common/child_process_host_impl.h" |
13 #include "content/common/utility_messages.h" | 13 #include "content/common/utility_messages.h" |
14 #include "content/public/browser/content_browser_client.h" | 14 #include "content/public/browser/content_browser_client.h" |
15 #include "content/public/common/content_switches.h" | 15 #include "content/public/common/content_switches.h" |
16 #include "ipc/ipc_switches.h" | 16 #include "ipc/ipc_switches.h" |
17 #include "ui/base/ui_base_switches.h" | 17 #include "ui/base/ui_base_switches.h" |
18 #include "webkit/plugins/plugin_switches.h" | 18 #include "webkit/plugins/plugin_switches.h" |
19 | 19 |
20 using content::BrowserThread; | 20 using content::BrowserThread; |
| 21 using content::ChildProcessHost; |
21 | 22 |
22 UtilityProcessHost::Client::Client() { | 23 UtilityProcessHost::Client::Client() { |
23 } | 24 } |
24 | 25 |
25 UtilityProcessHost::Client::~Client() { | 26 UtilityProcessHost::Client::~Client() { |
26 } | 27 } |
27 | 28 |
28 void UtilityProcessHost::Client::OnProcessCrashed(int exit_code) { | 29 void UtilityProcessHost::Client::OnProcessCrashed(int exit_code) { |
29 } | 30 } |
30 | 31 |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 if (started_) | 81 if (started_) |
81 return true; | 82 return true; |
82 started_ = true; | 83 started_ = true; |
83 | 84 |
84 if (is_batch_mode_) | 85 if (is_batch_mode_) |
85 return true; | 86 return true; |
86 // Name must be set or metrics_service will crash in any test which | 87 // Name must be set or metrics_service will crash in any test which |
87 // launches a UtilityProcessHost. | 88 // launches a UtilityProcessHost. |
88 set_name(ASCIIToUTF16("utility process")); | 89 set_name(ASCIIToUTF16("utility process")); |
89 | 90 |
90 if (!child_process_host()->CreateChannel()) | 91 std::string channel_id = child_process_host()->CreateChannel(); |
| 92 if (channel_id.empty()) |
91 return false; | 93 return false; |
92 | 94 |
93 FilePath exe_path = GetUtilityProcessCmd(); | 95 FilePath exe_path = GetUtilityProcessCmd(); |
94 if (exe_path.empty()) { | 96 if (exe_path.empty()) { |
95 NOTREACHED() << "Unable to get utility process binary name."; | 97 NOTREACHED() << "Unable to get utility process binary name."; |
96 return false; | 98 return false; |
97 } | 99 } |
98 | 100 |
99 CommandLine* cmd_line = new CommandLine(exe_path); | 101 CommandLine* cmd_line = new CommandLine(exe_path); |
100 cmd_line->AppendSwitchASCII(switches::kProcessType, | 102 cmd_line->AppendSwitchASCII(switches::kProcessType, |
101 switches::kUtilityProcess); | 103 switches::kUtilityProcess); |
102 cmd_line->AppendSwitchASCII(switches::kProcessChannelID, | 104 cmd_line->AppendSwitchASCII(switches::kProcessChannelID, channel_id); |
103 child_process_host()->channel_id()); | |
104 std::string locale = | 105 std::string locale = |
105 content::GetContentClient()->browser()->GetApplicationLocale(); | 106 content::GetContentClient()->browser()->GetApplicationLocale(); |
106 cmd_line->AppendSwitchASCII(switches::kLang, locale); | 107 cmd_line->AppendSwitchASCII(switches::kLang, locale); |
107 | 108 |
108 const CommandLine& browser_command_line = *CommandLine::ForCurrentProcess(); | 109 const CommandLine& browser_command_line = *CommandLine::ForCurrentProcess(); |
109 if (browser_command_line.HasSwitch(switches::kChromeFrame)) | 110 if (browser_command_line.HasSwitch(switches::kChromeFrame)) |
110 cmd_line->AppendSwitch(switches::kChromeFrame); | 111 cmd_line->AppendSwitch(switches::kChromeFrame); |
111 if (no_sandbox_ || browser_command_line.HasSwitch(switches::kNoSandbox)) | 112 if (no_sandbox_ || browser_command_line.HasSwitch(switches::kNoSandbox)) |
112 cmd_line->AppendSwitch(switches::kNoSandbox); | 113 cmd_line->AppendSwitch(switches::kNoSandbox); |
113 if (browser_command_line.HasSwitch(switches::kDebugPluginLoading)) | 114 if (browser_command_line.HasSwitch(switches::kDebugPluginLoading)) |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 base::IgnoreReturn<bool>( | 147 base::IgnoreReturn<bool>( |
147 base::Bind(&Client::OnMessageReceived, client_.get(), message))); | 148 base::Bind(&Client::OnMessageReceived, client_.get(), message))); |
148 return true; | 149 return true; |
149 } | 150 } |
150 | 151 |
151 void UtilityProcessHost::OnProcessCrashed(int exit_code) { | 152 void UtilityProcessHost::OnProcessCrashed(int exit_code) { |
152 BrowserThread::PostTask( | 153 BrowserThread::PostTask( |
153 client_thread_id_, FROM_HERE, | 154 client_thread_id_, FROM_HERE, |
154 base::Bind(&Client::OnProcessCrashed, client_.get(), exit_code)); | 155 base::Bind(&Client::OnProcessCrashed, client_.get(), exit_code)); |
155 } | 156 } |
OLD | NEW |