| 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 <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" |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 #include "ipc/ipc_switches.h" | 46 #include "ipc/ipc_switches.h" |
| 47 #include "media/base/media.h" | 47 #include "media/base/media.h" |
| 48 #include "sandbox/win/src/sandbox_types.h" | 48 #include "sandbox/win/src/sandbox_types.h" |
| 49 #include "ui/base/ui_base_paths.h" | 49 #include "ui/base/ui_base_paths.h" |
| 50 #include "ui/base/ui_base_switches.h" | 50 #include "ui/base/ui_base_switches.h" |
| 51 | 51 |
| 52 #ifdef V8_USE_EXTERNAL_STARTUP_DATA | 52 #ifdef V8_USE_EXTERNAL_STARTUP_DATA |
| 53 #include "gin/public/isolate_holder.h" | 53 #include "gin/public/isolate_holder.h" |
| 54 #endif | 54 #endif |
| 55 | 55 |
| 56 #if defined(OS_ANDROID) | |
| 57 #include "content/public/common/content_descriptors.h" | |
| 58 #endif | |
| 59 | |
| 60 #if defined(USE_TCMALLOC) | 56 #if defined(USE_TCMALLOC) |
| 61 #include "third_party/tcmalloc/chromium/src/gperftools/malloc_extension.h" | 57 #include "third_party/tcmalloc/chromium/src/gperftools/malloc_extension.h" |
| 62 #if defined(TYPE_PROFILING) | 58 #if defined(TYPE_PROFILING) |
| 63 #include "base/allocator/type_profiler.h" | 59 #include "base/allocator/type_profiler.h" |
| 64 #include "base/allocator/type_profiler_tcmalloc.h" | 60 #include "base/allocator/type_profiler_tcmalloc.h" |
| 65 #endif | 61 #endif |
| 66 #endif | 62 #endif |
| 67 | 63 |
| 68 #if !defined(OS_IOS) | 64 #if !defined(OS_IOS) |
| 69 #include "content/app/mojo/mojo_init.h" | 65 #include "content/app/mojo/mojo_init.h" |
| (...skipping 21 matching lines...) Expand all Loading... |
| 91 #endif // !OS_IOS | 87 #endif // !OS_IOS |
| 92 #endif // OS_WIN | 88 #endif // OS_WIN |
| 93 | 89 |
| 94 #if defined(OS_POSIX) | 90 #if defined(OS_POSIX) |
| 95 #include <signal.h> | 91 #include <signal.h> |
| 96 | 92 |
| 97 #include "base/posix/global_descriptors.h" | 93 #include "base/posix/global_descriptors.h" |
| 98 #include "content/public/common/content_descriptors.h" | 94 #include "content/public/common/content_descriptors.h" |
| 99 | 95 |
| 100 #if !defined(OS_MACOSX) | 96 #if !defined(OS_MACOSX) |
| 97 #include "content/public/common/content_descriptors.h" |
| 101 #include "content/public/common/zygote_fork_delegate_linux.h" | 98 #include "content/public/common/zygote_fork_delegate_linux.h" |
| 102 #endif | 99 #endif |
| 103 #if !defined(OS_MACOSX) && !defined(OS_ANDROID) | 100 #if !defined(OS_MACOSX) && !defined(OS_ANDROID) |
| 104 #include "content/zygote/zygote_main.h" | 101 #include "content/zygote/zygote_main.h" |
| 105 #endif | 102 #endif |
| 106 | 103 |
| 107 #endif // OS_POSIX | 104 #endif // OS_POSIX |
| 108 | 105 |
| 109 #if !defined(OS_MACOSX) && defined(USE_TCMALLOC) | 106 #if !defined(OS_MACOSX) && defined(USE_TCMALLOC) |
| 110 extern "C" { | 107 extern "C" { |
| (...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 512 SetupSignalHandlers(); | 509 SetupSignalHandlers(); |
| 513 | 510 |
| 514 base::GlobalDescriptors* g_fds = base::GlobalDescriptors::GetInstance(); | 511 base::GlobalDescriptors* g_fds = base::GlobalDescriptors::GetInstance(); |
| 515 g_fds->Set(kPrimaryIPCChannel, | 512 g_fds->Set(kPrimaryIPCChannel, |
| 516 kPrimaryIPCChannel + base::GlobalDescriptors::kBaseDescriptor); | 513 kPrimaryIPCChannel + base::GlobalDescriptors::kBaseDescriptor); |
| 517 #endif // !OS_ANDROID && !OS_IOS | 514 #endif // !OS_ANDROID && !OS_IOS |
| 518 | 515 |
| 519 #if defined(OS_LINUX) || defined(OS_OPENBSD) | 516 #if defined(OS_LINUX) || defined(OS_OPENBSD) |
| 520 g_fds->Set(kCrashDumpSignal, | 517 g_fds->Set(kCrashDumpSignal, |
| 521 kCrashDumpSignal + base::GlobalDescriptors::kBaseDescriptor); | 518 kCrashDumpSignal + base::GlobalDescriptors::kBaseDescriptor); |
| 522 #endif | 519 #if defined(V8_USE_EXTERNAL_STARTUP_DATA) |
| 520 g_fds->Set( |
| 521 kV8NativesDataDescriptor, |
| 522 kV8NativesDataDescriptor + base::GlobalDescriptors::kBaseDescriptor); |
| 523 g_fds->Set( |
| 524 kV8SnapshotDataDescriptor, |
| 525 kV8SnapshotDataDescriptor + base::GlobalDescriptors::kBaseDescriptor); |
| 526 #endif // V8_USE_EXTERNAL_STARTUP_DATA |
| 527 #endif // OS_LINUX || OS_OPENBSD |
| 528 |
| 523 | 529 |
| 524 #endif // !OS_WIN | 530 #endif // !OS_WIN |
| 525 | 531 |
| 526 is_initialized_ = true; | 532 is_initialized_ = true; |
| 527 delegate_ = params.delegate; | 533 delegate_ = params.delegate; |
| 528 | 534 |
| 529 // The exit manager is in charge of calling the dtors of singleton objects. | 535 // The exit manager is in charge of calling the dtors of singleton objects. |
| 530 // On Android, AtExitManager is set up when library is loaded. | 536 // On Android, AtExitManager is set up when library is loaded. |
| 531 // On iOS, it's set up in main(), which can't call directly through to here. | 537 // On iOS, it's set up in main(), which can't call directly through to here. |
| 532 // A consequence of this is that you can't use the ctor/dtor-based | 538 // A consequence of this is that you can't use the ctor/dtor-based |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 682 int icudata_fd = base::GlobalDescriptors::GetInstance()->MaybeGet( | 688 int icudata_fd = base::GlobalDescriptors::GetInstance()->MaybeGet( |
| 683 kAndroidICUDataDescriptor); | 689 kAndroidICUDataDescriptor); |
| 684 if (icudata_fd != -1) { | 690 if (icudata_fd != -1) { |
| 685 auto icudata_region = base::GlobalDescriptors::GetInstance()->GetRegion( | 691 auto icudata_region = base::GlobalDescriptors::GetInstance()->GetRegion( |
| 686 kAndroidICUDataDescriptor); | 692 kAndroidICUDataDescriptor); |
| 687 CHECK(base::i18n::InitializeICUWithFileDescriptor(icudata_fd, | 693 CHECK(base::i18n::InitializeICUWithFileDescriptor(icudata_fd, |
| 688 icudata_region)); | 694 icudata_region)); |
| 689 } else { | 695 } else { |
| 690 CHECK(base::i18n::InitializeICU()); | 696 CHECK(base::i18n::InitializeICU()); |
| 691 } | 697 } |
| 698 #else |
| 699 CHECK(base::i18n::InitializeICU()); |
| 700 #endif // OS_ANDROID |
| 692 | 701 |
| 693 #if defined(V8_USE_EXTERNAL_STARTUP_DATA) | 702 #if defined(V8_USE_EXTERNAL_STARTUP_DATA) |
| 694 int v8_natives_fd = base::GlobalDescriptors::GetInstance()->MaybeGet( | 703 #if defined(OS_POSIX) && !defined(OS_MACOSX) |
| 695 kV8NativesDataDescriptor); | 704 if (process_type.empty() || process_type == switches::kZygoteProcess) { |
| 696 int v8_snapshot_fd = base::GlobalDescriptors::GetInstance()->MaybeGet( | 705 // Load snapshot from file for browser or zygote process. |
| 697 kV8SnapshotDataDescriptor); | 706 CHECK(gin::IsolateHolder::LoadV8Snapshot()); |
| 698 if (v8_natives_fd != -1 && v8_snapshot_fd != -1) { | 707 } else { |
| 699 auto v8_natives_region = | 708 base::GlobalDescriptors* g_fds = base::GlobalDescriptors::GetInstance(); |
| 700 base::GlobalDescriptors::GetInstance()->GetRegion( | 709 int v8_natives_fd = g_fds->Get(kV8NativesDataDescriptor); |
| 701 kV8NativesDataDescriptor); | 710 int v8_snapshot_fd = g_fds->Get(kV8SnapshotDataDescriptor); |
| 702 auto v8_snapshot_region = | 711 auto v8_natives_region = g_fds->GetRegion(kV8NativesDataDescriptor); |
| 703 base::GlobalDescriptors::GetInstance()->GetRegion( | 712 auto v8_snapshot_region = g_fds->GetRegion(kV8SnapshotDataDescriptor); |
| 704 kV8SnapshotDataDescriptor); | |
| 705 CHECK(gin::IsolateHolder::LoadV8SnapshotFd( | 713 CHECK(gin::IsolateHolder::LoadV8SnapshotFd( |
| 706 v8_natives_fd, v8_natives_region.offset, v8_natives_region.size, | 714 v8_natives_fd, v8_natives_region.offset, v8_natives_region.size, |
| 707 v8_snapshot_fd, v8_snapshot_region.offset, v8_snapshot_region.size)); | 715 v8_snapshot_fd, v8_snapshot_region.offset, v8_snapshot_region.size)); |
| 708 } else { | |
| 709 CHECK(gin::IsolateHolder::LoadV8Snapshot()); | |
| 710 } | 716 } |
| 711 #endif // V8_USE_EXTERNAL_STARTUP_DATA | |
| 712 | |
| 713 #else | 717 #else |
| 714 CHECK(base::i18n::InitializeICU()); | |
| 715 #if defined(V8_USE_EXTERNAL_STARTUP_DATA) | |
| 716 CHECK(gin::IsolateHolder::LoadV8Snapshot()); | 718 CHECK(gin::IsolateHolder::LoadV8Snapshot()); |
| 719 #endif // OS_POSIX |
| 717 #endif // V8_USE_EXTERNAL_STARTUP_DATA | 720 #endif // V8_USE_EXTERNAL_STARTUP_DATA |
| 718 #endif // OS_ANDROID | |
| 719 | 721 |
| 720 if (delegate_) | 722 if (delegate_) |
| 721 delegate_->PreSandboxStartup(); | 723 delegate_->PreSandboxStartup(); |
| 722 | 724 |
| 723 if (!process_type.empty()) | 725 if (!process_type.empty()) |
| 724 CommonSubprocessInit(process_type); | 726 CommonSubprocessInit(process_type); |
| 725 | 727 |
| 726 #if defined(OS_WIN) | 728 #if defined(OS_WIN) |
| 727 CHECK(InitializeSandbox(params.sandbox_info)); | 729 CHECK(InitializeSandbox(params.sandbox_info)); |
| 728 #elif defined(OS_MACOSX) && !defined(OS_IOS) | 730 #elif defined(OS_MACOSX) && !defined(OS_IOS) |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 822 | 824 |
| 823 DISALLOW_COPY_AND_ASSIGN(ContentMainRunnerImpl); | 825 DISALLOW_COPY_AND_ASSIGN(ContentMainRunnerImpl); |
| 824 }; | 826 }; |
| 825 | 827 |
| 826 // static | 828 // static |
| 827 ContentMainRunner* ContentMainRunner::Create() { | 829 ContentMainRunner* ContentMainRunner::Create() { |
| 828 return new ContentMainRunnerImpl(); | 830 return new ContentMainRunnerImpl(); |
| 829 } | 831 } |
| 830 | 832 |
| 831 } // namespace content | 833 } // namespace content |
| OLD | NEW |