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

Side by Side Diff: content/app/content_main_runner.cc

Issue 269413004: Add support for multiple zygote fork delegates (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: IWYU Created 6 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « chrome/app/chrome_main_delegate.cc ('k') | content/public/app/content_main_delegate.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/public/app/content_main_runner.h" 5 #include "content/public/app/content_main_runner.h"
6 6
7 #include <stdlib.h> 7 #include <stdlib.h>
8 8
9 #include "base/allocator/allocator_extension.h" 9 #include "base/allocator/allocator_extension.h"
10 #include "base/at_exit.h" 10 #include "base/at_exit.h"
11 #include "base/command_line.h" 11 #include "base/command_line.h"
12 #include "base/debug/debugger.h" 12 #include "base/debug/debugger.h"
13 #include "base/debug/trace_event.h" 13 #include "base/debug/trace_event.h"
14 #include "base/files/file_path.h" 14 #include "base/files/file_path.h"
15 #include "base/i18n/icu_util.h" 15 #include "base/i18n/icu_util.h"
16 #include "base/lazy_instance.h" 16 #include "base/lazy_instance.h"
17 #include "base/logging.h" 17 #include "base/logging.h"
18 #include "base/memory/scoped_ptr.h" 18 #include "base/memory/scoped_ptr.h"
19 #include "base/memory/scoped_vector.h"
19 #include "base/metrics/stats_table.h" 20 #include "base/metrics/stats_table.h"
20 #include "base/path_service.h" 21 #include "base/path_service.h"
21 #include "base/process/launch.h" 22 #include "base/process/launch.h"
22 #include "base/process/memory.h" 23 #include "base/process/memory.h"
23 #include "base/process/process_handle.h" 24 #include "base/process/process_handle.h"
24 #include "base/profiler/alternate_timer.h" 25 #include "base/profiler/alternate_timer.h"
25 #include "base/strings/string_number_conversions.h" 26 #include "base/strings/string_number_conversions.h"
26 #include "base/strings/string_util.h" 27 #include "base/strings/string_util.h"
27 #include "base/strings/stringprintf.h" 28 #include "base/strings/stringprintf.h"
28 #include "content/browser/browser_main.h" 29 #include "content/browser/browser_main.h"
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after
291 ContentMainDelegate* delegate) { 292 ContentMainDelegate* delegate) {
292 static const MainFunction kMainFunctions[] = { 293 static const MainFunction kMainFunctions[] = {
293 { switches::kRendererProcess, RendererMain }, 294 { switches::kRendererProcess, RendererMain },
294 { switches::kWorkerProcess, WorkerMain }, 295 { switches::kWorkerProcess, WorkerMain },
295 #if defined(ENABLE_PLUGINS) 296 #if defined(ENABLE_PLUGINS)
296 { switches::kPpapiPluginProcess, PpapiPluginMain }, 297 { switches::kPpapiPluginProcess, PpapiPluginMain },
297 #endif 298 #endif
298 { switches::kUtilityProcess, UtilityMain }, 299 { switches::kUtilityProcess, UtilityMain },
299 }; 300 };
300 301
301 scoped_ptr<ZygoteForkDelegate> zygote_fork_delegate; 302 ScopedVector<ZygoteForkDelegate> zygote_fork_delegates;
302 if (delegate) { 303 if (delegate) {
303 zygote_fork_delegate.reset(delegate->ZygoteStarting()); 304 delegate->ZygoteStarting(&zygote_fork_delegates);
304 // Each Renderer we spawn will re-attempt initialization of the media 305 // Each Renderer we spawn will re-attempt initialization of the media
305 // libraries, at which point failure will be detected and handled, so 306 // libraries, at which point failure will be detected and handled, so
306 // we do not need to cope with initialization failures here. 307 // we do not need to cope with initialization failures here.
307 base::FilePath media_path; 308 base::FilePath media_path;
308 if (PathService::Get(DIR_MEDIA_LIBS, &media_path)) 309 if (PathService::Get(DIR_MEDIA_LIBS, &media_path))
309 media::InitializeMediaLibrary(media_path); 310 media::InitializeMediaLibrary(media_path);
310 } 311 }
311 312
312 // This function call can return multiple times, once per fork(). 313 // This function call can return multiple times, once per fork().
313 if (!ZygoteMain(main_function_params, zygote_fork_delegate.get())) 314 if (!ZygoteMain(main_function_params, zygote_fork_delegates.Pass()))
314 return 1; 315 return 1;
315 316
316 if (delegate) delegate->ZygoteForked(); 317 if (delegate) delegate->ZygoteForked();
317 318
318 // Zygote::HandleForkRequest may have reallocated the command 319 // Zygote::HandleForkRequest may have reallocated the command
319 // line so update it here with the new version. 320 // line so update it here with the new version.
320 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); 321 const CommandLine& command_line = *CommandLine::ForCurrentProcess();
321 std::string process_type = 322 std::string process_type =
322 command_line.GetSwitchValueASCII(switches::kProcessType); 323 command_line.GetSwitchValueASCII(switches::kProcessType);
323 ContentClientInitializer::Set(process_type, delegate); 324 ContentClientInitializer::Set(process_type, delegate);
(...skipping 475 matching lines...) Expand 10 before | Expand all | Expand 10 after
799 800
800 DISALLOW_COPY_AND_ASSIGN(ContentMainRunnerImpl); 801 DISALLOW_COPY_AND_ASSIGN(ContentMainRunnerImpl);
801 }; 802 };
802 803
803 // static 804 // static
804 ContentMainRunner* ContentMainRunner::Create() { 805 ContentMainRunner* ContentMainRunner::Create() {
805 return new ContentMainRunnerImpl(); 806 return new ContentMainRunnerImpl();
806 } 807 }
807 808
808 } // namespace content 809 } // namespace content
OLDNEW
« no previous file with comments | « chrome/app/chrome_main_delegate.cc ('k') | content/public/app/content_main_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698