OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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/child_process_launcher_helper_posix.h" | 5 #include "content/browser/child_process_launcher_helper_posix.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/metrics/field_trial.h" | 8 #include "base/metrics/field_trial.h" |
9 #include "base/posix/global_descriptors.h" | 9 #include "base/posix/global_descriptors.h" |
10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
11 #include "base/strings/string_util.h" | 11 #include "base/strings/string_util.h" |
12 #include "content/browser/file_descriptor_info_impl.h" | 12 #include "content/browser/posix_file_descriptor_info_impl.h" |
13 #include "content/public/browser/content_browser_client.h" | 13 #include "content/public/browser/content_browser_client.h" |
14 #include "content/public/common/content_client.h" | 14 #include "content/public/common/content_client.h" |
15 #include "content/public/common/content_descriptors.h" | 15 #include "content/public/common/content_descriptors.h" |
16 #include "content/public/common/content_switches.h" | 16 #include "content/public/common/content_switches.h" |
17 #include "mojo/edk/embedder/platform_handle.h" | 17 #include "mojo/edk/embedder/platform_handle.h" |
18 #include "services/catalog/public/cpp/manifest_parsing_util.h" | 18 #include "services/catalog/public/cpp/manifest_parsing_util.h" |
19 #include "services/service_manager/embedder/shared_file_util.h" | 19 #include "services/service_manager/embedder/shared_file_util.h" |
20 #include "services/service_manager/embedder/switches.h" | 20 #include "services/service_manager/embedder/switches.h" |
21 | 21 |
22 namespace content { | 22 namespace content { |
(...skipping 41 matching lines...) Loading... |
64 return base::kInvalidPlatformFile; | 64 return base::kInvalidPlatformFile; |
65 } | 65 } |
66 // g_opened_files becomes the owner of the file descriptor. | 66 // g_opened_files becomes the owner of the file descriptor. |
67 base::PlatformFile fd = file.TakePlatformFile(); | 67 base::PlatformFile fd = file.TakePlatformFile(); |
68 (*opened_files)[path] = std::make_pair(fd, *region); | 68 (*opened_files)[path] = std::make_pair(fd, *region); |
69 return fd; | 69 return fd; |
70 } | 70 } |
71 | 71 |
72 } // namespace | 72 } // namespace |
73 | 73 |
74 std::unique_ptr<FileDescriptorInfo> CreateDefaultPosixFilesToMap( | 74 std::unique_ptr<PosixFileDescriptorInfo> CreateDefaultPosixFilesToMap( |
75 int child_process_id, | 75 int child_process_id, |
76 const mojo::edk::PlatformHandle& mojo_client_handle, | 76 const mojo::edk::PlatformHandle& mojo_client_handle, |
77 bool include_service_required_files, | 77 bool include_service_required_files, |
78 const std::string& process_type, | 78 const std::string& process_type, |
79 base::CommandLine* command_line) { | 79 base::CommandLine* command_line) { |
80 std::unique_ptr<FileDescriptorInfo> files_to_register( | 80 std::unique_ptr<PosixFileDescriptorInfo> files_to_register( |
81 FileDescriptorInfoImpl::Create()); | 81 PosixFileDescriptorInfoImpl::Create()); |
82 | 82 |
83 base::SharedMemoryHandle shm = base::FieldTrialList::GetFieldTrialHandle(); | 83 base::SharedMemoryHandle shm = base::FieldTrialList::GetFieldTrialHandle(); |
84 if (shm.IsValid()) { | 84 if (shm.IsValid()) { |
85 files_to_register->Share( | 85 files_to_register->Share( |
86 kFieldTrialDescriptor, | 86 kFieldTrialDescriptor, |
87 base::SharedMemory::GetFdFromSharedMemoryHandle(shm)); | 87 base::SharedMemory::GetFdFromSharedMemoryHandle(shm)); |
88 } | 88 } |
89 | 89 |
90 DCHECK(mojo_client_handle.is_valid()); | 90 DCHECK(mojo_client_handle.is_valid()); |
91 files_to_register->Share(kMojoIPCChannel, mojo_client_handle.handle); | 91 files_to_register->Share(kMojoIPCChannel, mojo_client_handle.handle); |
(...skipping 52 matching lines...) Loading... |
144 DCHECK(GetRequiredFilesByServiceMap().count(service_name) == 0); | 144 DCHECK(GetRequiredFilesByServiceMap().count(service_name) == 0); |
145 GetRequiredFilesByServiceMap()[service_name] = std::move(required_files); | 145 GetRequiredFilesByServiceMap()[service_name] = std::move(required_files); |
146 } | 146 } |
147 | 147 |
148 void ResetFilesToShareForTestingPosix() { | 148 void ResetFilesToShareForTestingPosix() { |
149 GetRequiredFilesByServiceMap().clear(); | 149 GetRequiredFilesByServiceMap().clear(); |
150 } | 150 } |
151 | 151 |
152 } // namespace internal | 152 } // namespace internal |
153 } // namespace content | 153 } // namespace content |
OLD | NEW |