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

Unified Diff: content/app/content_main_runner.cc

Issue 2684433003: Files required by a service now listed in manifest. (Closed)
Patch Set: Fixed analysis. Created 3 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: content/app/content_main_runner.cc
diff --git a/content/app/content_main_runner.cc b/content/app/content_main_runner.cc
index 934bac48a0bdbf6fff89c24b0d2d8719094f2eca..3585db17b5adf77793712738cb46253f11c81727 100644
--- a/content/app/content_main_runner.cc
+++ b/content/app/content_main_runner.cc
@@ -21,6 +21,7 @@
#include "base/debug/debugger.h"
#include "base/debug/stack_trace.h"
#include "base/feature_list.h"
+#include "base/file_descriptor_store.h"
#include "base/files/file_path.h"
#include "base/i18n/icu_util.h"
#include "base/lazy_instance.h"
@@ -56,6 +57,7 @@
#include "content/public/browser/content_browser_client.h"
#include "content/public/common/content_client.h"
#include "content/public/common/content_constants.h"
+#include "content/public/common/content_descriptor_keys.h"
#include "content/public/common/content_paths.h"
#include "content/public/common/content_switches.h"
#include "content/public/common/main_function_params.h"
@@ -68,6 +70,7 @@
#include "ipc/ipc_descriptors.h"
#include "media/base/media.h"
#include "ppapi/features/features.h"
+#include "services/service_manager/public/cpp/shared_file_util.h"
#include "ui/base/ui_base_paths.h"
#include "ui/base/ui_base_switches.h"
@@ -188,9 +191,9 @@ base::LazyInstance<ContentUtilityClient>
#if defined(V8_USE_EXTERNAL_STARTUP_DATA) && defined(OS_ANDROID)
#if defined __LP64__
-#define kV8SnapshotDataDescriptor kV8SnapshotDataDescriptor64
+#define kV8SnapshotDataDescriptor kV8Snapshot64DataDescriptor
#else
-#define kV8SnapshotDataDescriptor kV8SnapshotDataDescriptor32
+#define kV8SnapshotDataDescriptor kV8Snapshot32DataDescriptor
#endif
#endif
@@ -247,6 +250,22 @@ void CommonSubprocessInit() {
#endif
}
+void PopulateFDsFromCommandLine() {
+ const std::string& shared_file_param =
+ base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
+ switches::kSharedFiles);
+ if (shared_file_param.empty())
+ return;
+
+ std::map<int, std::string> shared_file_descriptors;
+ service_manager::ParseSharedFileSwitchValue(shared_file_param,
+ &shared_file_descriptors);
+ for (const auto& descriptor : shared_file_descriptors) {
+ base::FileDescriptorStore::GetInstance()->Set(descriptor.second,
+ descriptor.first);
+ }
+}
+
class ContentClientInitializer {
public:
static void Set(const std::string& process_type,
@@ -537,8 +556,8 @@ class ContentMainRunnerImpl : public ContentMainRunner {
InitializeMac();
#endif
- // On Android, the command line is initialized when library is loaded and
- // we have already started our TRACE_EVENT0.
+ // On Android, the command line is initialized and the FDs set when the
+ // library is loaded and we have already started our TRACE_EVENT0.
#if !defined(OS_ANDROID)
// argc/argv are ignored on Windows and Android; see command_line.h for
// details.
@@ -552,6 +571,8 @@ class ContentMainRunnerImpl : public ContentMainRunner {
base::CommandLine::Init(argc, argv);
+ PopulateFDsFromCommandLine();
+
base::EnableTerminationOnHeapCorruption();
// TODO(yiyaoliu, vadimt): Remove this once crbug.com/453640 is fixed.
@@ -709,32 +730,23 @@ class ContentMainRunnerImpl : public ContentMainRunner {
#if defined(V8_USE_EXTERNAL_STARTUP_DATA)
#if defined(OS_POSIX) && !defined(OS_MACOSX)
-#if !defined(OS_ANDROID)
- // kV8NativesDataDescriptor and kV8SnapshotDataDescriptor could be shared
- // with child processes via file descriptors. On Android they are set in
- // ChildProcessService::InternalInitChildProcess, otherwise set them here.
- if (command_line.HasSwitch(switches::kV8NativesPassedByFD)) {
- g_fds->Set(
- kV8NativesDataDescriptor,
- kV8NativesDataDescriptor + base::GlobalDescriptors::kBaseDescriptor);
- }
- if (command_line.HasSwitch(switches::kV8SnapshotPassedByFD)) {
- g_fds->Set(
- kV8SnapshotDataDescriptor,
- kV8SnapshotDataDescriptor + base::GlobalDescriptors::kBaseDescriptor);
- }
-#endif // !OS_ANDROID
- int v8_natives_fd = g_fds->MaybeGet(kV8NativesDataDescriptor);
- int v8_snapshot_fd = g_fds->MaybeGet(kV8SnapshotDataDescriptor);
+ base::FileDescriptorStore* file_descriptor_store =
+ base::FileDescriptorStore::GetInstance();
+ int v8_snapshot_fd =
+ file_descriptor_store->MaybeGet(kV8SnapshotDataDescriptor);
if (v8_snapshot_fd != -1) {
- auto v8_snapshot_region = g_fds->GetRegion(kV8SnapshotDataDescriptor);
+ auto v8_snapshot_region =
+ file_descriptor_store->GetRegion(kV8SnapshotDataDescriptor);
gin::V8Initializer::LoadV8SnapshotFromFD(
v8_snapshot_fd, v8_snapshot_region.offset, v8_snapshot_region.size);
} else {
gin::V8Initializer::LoadV8Snapshot();
}
+ int v8_natives_fd =
+ file_descriptor_store->MaybeGet(kV8NativesDataDescriptor);
if (v8_natives_fd != -1) {
- auto v8_natives_region = g_fds->GetRegion(kV8NativesDataDescriptor);
+ auto v8_natives_region =
+ file_descriptor_store->GetRegion(kV8NativesDataDescriptor);
gin::V8Initializer::LoadV8NativesFromFD(
v8_natives_fd, v8_natives_region.offset, v8_natives_region.size);
} else {

Powered by Google App Engine
This is Rietveld 408576698