OLD | NEW |
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/public/app/content_main_runner.h" | 5 #include "content/public/app/content_main_runner.h" |
6 | 6 |
7 #include "base/at_exit.h" | 7 #include "base/at_exit.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/debug/debugger.h" | 9 #include "base/debug/debugger.h" |
10 #include "base/debug/trace_event.h" | 10 #include "base/debug/trace_event.h" |
| 11 #include "base/file_path.h" |
11 #include "base/i18n/icu_util.h" | 12 #include "base/i18n/icu_util.h" |
12 #include "base/logging.h" | 13 #include "base/logging.h" |
13 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
14 #include "base/metrics/stats_table.h" | 15 #include "base/metrics/stats_table.h" |
| 16 #include "base/path_service.h" |
15 #include "base/process_util.h" | 17 #include "base/process_util.h" |
16 #include "base/stringprintf.h" | 18 #include "base/stringprintf.h" |
17 #include "base/string_number_conversions.h" | 19 #include "base/string_number_conversions.h" |
18 #include "content/browser/browser_main.h" | 20 #include "content/browser/browser_main.h" |
19 #include "content/common/set_process_title.h" | 21 #include "content/common/set_process_title.h" |
20 #include "content/public/app/content_main_delegate.h" | 22 #include "content/public/app/content_main_delegate.h" |
21 #include "content/public/app/startup_helper_win.h" | 23 #include "content/public/app/startup_helper_win.h" |
22 #include "content/public/common/content_client.h" | 24 #include "content/public/common/content_client.h" |
23 #include "content/public/common/content_constants.h" | 25 #include "content/public/common/content_constants.h" |
24 #include "content/public/common/content_paths.h" | 26 #include "content/public/common/content_paths.h" |
25 #include "content/public/common/content_switches.h" | 27 #include "content/public/common/content_switches.h" |
26 #include "content/public/common/main_function_params.h" | 28 #include "content/public/common/main_function_params.h" |
27 #include "content/public/common/sandbox_init.h" | 29 #include "content/public/common/sandbox_init.h" |
28 #include "crypto/nss_util.h" | 30 #include "crypto/nss_util.h" |
29 #include "ipc/ipc_switches.h" | 31 #include "ipc/ipc_switches.h" |
| 32 #include "media/base/media.h" |
30 #include "sandbox/src/sandbox_types.h" | 33 #include "sandbox/src/sandbox_types.h" |
31 #include "ui/base/ui_base_switches.h" | 34 #include "ui/base/ui_base_switches.h" |
32 #include "ui/base/ui_base_paths.h" | 35 #include "ui/base/ui_base_paths.h" |
33 #include "webkit/glue/webkit_glue.h" | 36 #include "webkit/glue/webkit_glue.h" |
34 | 37 |
35 #if defined(OS_WIN) | 38 #if defined(OS_WIN) |
36 #include <atlbase.h> | 39 #include <atlbase.h> |
37 #include <atlapp.h> | 40 #include <atlapp.h> |
38 #include <malloc.h> | 41 #include <malloc.h> |
39 #elif defined(OS_MACOSX) | 42 #elif defined(OS_MACOSX) |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
190 int RunZygote(const content::MainFunctionParams& main_function_params, | 193 int RunZygote(const content::MainFunctionParams& main_function_params, |
191 content::ContentMainDelegate* delegate) { | 194 content::ContentMainDelegate* delegate) { |
192 static const MainFunction kMainFunctions[] = { | 195 static const MainFunction kMainFunctions[] = { |
193 { switches::kRendererProcess, RendererMain }, | 196 { switches::kRendererProcess, RendererMain }, |
194 { switches::kWorkerProcess, WorkerMain }, | 197 { switches::kWorkerProcess, WorkerMain }, |
195 { switches::kPpapiPluginProcess, PpapiPluginMain }, | 198 { switches::kPpapiPluginProcess, PpapiPluginMain }, |
196 { switches::kUtilityProcess, UtilityMain }, | 199 { switches::kUtilityProcess, UtilityMain }, |
197 }; | 200 }; |
198 | 201 |
199 scoped_ptr<content::ZygoteForkDelegate> zygote_fork_delegate; | 202 scoped_ptr<content::ZygoteForkDelegate> zygote_fork_delegate; |
200 if (delegate) zygote_fork_delegate.reset(delegate->ZygoteStarting()); | 203 if (delegate) { |
| 204 zygote_fork_delegate.reset(delegate->ZygoteStarting()); |
| 205 // Each Renderer we spawn will re-attempt initialization of the media |
| 206 // libraries, at which point failure will be detected and handled, so |
| 207 // we do not need to cope with initialization failures here. |
| 208 FilePath media_path; |
| 209 if (PathService::Get(content::DIR_MEDIA_LIBS, &media_path)) |
| 210 media::InitializeMediaLibrary(media_path); |
| 211 } |
201 | 212 |
202 // This function call can return multiple times, once per fork(). | 213 // This function call can return multiple times, once per fork(). |
203 if (!ZygoteMain(main_function_params, zygote_fork_delegate.get())) | 214 if (!ZygoteMain(main_function_params, zygote_fork_delegate.get())) |
204 return 1; | 215 return 1; |
205 | 216 |
206 if (delegate) delegate->ZygoteForked(); | 217 if (delegate) delegate->ZygoteForked(); |
207 | 218 |
208 // Zygote::HandleForkRequest may have reallocated the command | 219 // Zygote::HandleForkRequest may have reallocated the command |
209 // line so update it here with the new version. | 220 // line so update it here with the new version. |
210 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 221 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
(...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
556 } // namespace | 567 } // namespace |
557 | 568 |
558 namespace content { | 569 namespace content { |
559 | 570 |
560 // static | 571 // static |
561 ContentMainRunner* ContentMainRunner::Create() { | 572 ContentMainRunner* ContentMainRunner::Create() { |
562 return new ContentMainRunnerImpl(); | 573 return new ContentMainRunnerImpl(); |
563 } | 574 } |
564 | 575 |
565 } // namespace content | 576 } // namespace content |
OLD | NEW |