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

Side by Side Diff: chrome/browser/chrome_content_browser_client.cc

Issue 1187213002: Revert of Moved logic for mapping child process FDs for ICU and V8 into child_process_launcher.cc (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 6 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
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 "chrome/browser/chrome_content_browser_client.h" 5 #include "chrome/browser/chrome_content_browser_client.h"
6 6
7 #include <set> 7 #include <set>
8 #include <utility> 8 #include <utility>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/bind.h" 11 #include "base/bind.h"
12 #include "base/bind_helpers.h" 12 #include "base/bind_helpers.h"
13 #include "base/command_line.h" 13 #include "base/command_line.h"
14 #include "base/files/scoped_file.h" 14 #include "base/files/scoped_file.h"
15 #include "base/i18n/icu_util.h"
15 #include "base/lazy_instance.h" 16 #include "base/lazy_instance.h"
16 #include "base/path_service.h" 17 #include "base/path_service.h"
17 #include "base/prefs/pref_service.h" 18 #include "base/prefs/pref_service.h"
18 #include "base/prefs/scoped_user_pref_update.h" 19 #include "base/prefs/scoped_user_pref_update.h"
19 #include "base/strings/string_number_conversions.h" 20 #include "base/strings/string_number_conversions.h"
20 #include "base/strings/utf_string_conversions.h" 21 #include "base/strings/utf_string_conversions.h"
21 #include "base/thread_task_runner_handle.h" 22 #include "base/thread_task_runner_handle.h"
22 #include "base/threading/sequenced_worker_pool.h" 23 #include "base/threading/sequenced_worker_pool.h"
23 #include "chrome/browser/after_startup_task_utils.h" 24 #include "chrome/browser/after_startup_task_utils.h"
24 #include "chrome/browser/browser_about_handler.h" 25 #include "chrome/browser/browser_about_handler.h"
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 #include "content/public/browser/render_view_host.h" 118 #include "content/public/browser/render_view_host.h"
118 #include "content/public/browser/resource_context.h" 119 #include "content/public/browser/resource_context.h"
119 #include "content/public/browser/site_instance.h" 120 #include "content/public/browser/site_instance.h"
120 #include "content/public/browser/web_contents.h" 121 #include "content/public/browser/web_contents.h"
121 #include "content/public/common/child_process_host.h" 122 #include "content/public/common/child_process_host.h"
122 #include "content/public/common/content_descriptors.h" 123 #include "content/public/common/content_descriptors.h"
123 #include "content/public/common/service_registry.h" 124 #include "content/public/common/service_registry.h"
124 #include "content/public/common/url_utils.h" 125 #include "content/public/common/url_utils.h"
125 #include "content/public/common/web_preferences.h" 126 #include "content/public/common/web_preferences.h"
126 #include "device/devices_app/devices_app.h" 127 #include "device/devices_app/devices_app.h"
128 #include "gin/v8_initializer.h"
127 #include "net/base/mime_util.h" 129 #include "net/base/mime_util.h"
128 #include "net/cookies/canonical_cookie.h" 130 #include "net/cookies/canonical_cookie.h"
129 #include "net/cookies/cookie_options.h" 131 #include "net/cookies/cookie_options.h"
130 #include "net/ssl/ssl_cert_request_info.h" 132 #include "net/ssl/ssl_cert_request_info.h"
131 #include "ppapi/host/ppapi_host.h" 133 #include "ppapi/host/ppapi_host.h"
132 #include "storage/browser/fileapi/external_mount_points.h" 134 #include "storage/browser/fileapi/external_mount_points.h"
133 #include "ui/base/l10n/l10n_util.h" 135 #include "ui/base/l10n/l10n_util.h"
134 #include "ui/base/resource/resource_bundle.h" 136 #include "ui/base/resource/resource_bundle.h"
135 #include "ui/resources/grit/ui_resources.h" 137 #include "ui/resources/grit/ui_resources.h"
136 138
(...skipping 464 matching lines...) Expand 10 before | Expand all | Expand 10 after
601 incognito)); 603 incognito));
602 } 604 }
603 #endif // defined(ENABLE_EXTENSIONS) 605 #endif // defined(ENABLE_EXTENSIONS)
604 606
605 } // namespace 607 } // namespace
606 608
607 namespace chrome { 609 namespace chrome {
608 610
609 ChromeContentBrowserClient::ChromeContentBrowserClient() 611 ChromeContentBrowserClient::ChromeContentBrowserClient()
610 : 612 :
613 #if defined(OS_POSIX) && !defined(OS_MACOSX)
614 v8_natives_fd_(-1),
615 v8_snapshot_fd_(-1),
616 #endif // OS_POSIX && !OS_MACOSX
611 weak_factory_(this) { 617 weak_factory_(this) {
612 #if defined(ENABLE_PLUGINS) 618 #if defined(ENABLE_PLUGINS)
613 for (size_t i = 0; i < arraysize(kPredefinedAllowedDevChannelOrigins); ++i) 619 for (size_t i = 0; i < arraysize(kPredefinedAllowedDevChannelOrigins); ++i)
614 allowed_dev_channel_origins_.insert(kPredefinedAllowedDevChannelOrigins[i]); 620 allowed_dev_channel_origins_.insert(kPredefinedAllowedDevChannelOrigins[i]);
615 for (size_t i = 0; i < arraysize(kPredefinedAllowedFileHandleOrigins); ++i) 621 for (size_t i = 0; i < arraysize(kPredefinedAllowedFileHandleOrigins); ++i)
616 allowed_file_handle_origins_.insert(kPredefinedAllowedFileHandleOrigins[i]); 622 allowed_file_handle_origins_.insert(kPredefinedAllowedFileHandleOrigins[i]);
617 for (size_t i = 0; i < arraysize(kPredefinedAllowedSocketOrigins); ++i) 623 for (size_t i = 0; i < arraysize(kPredefinedAllowedSocketOrigins); ++i)
618 allowed_socket_origins_.insert(kPredefinedAllowedSocketOrigins[i]); 624 allowed_socket_origins_.insert(kPredefinedAllowedSocketOrigins[i]);
619 625
620 extra_parts_.push_back(new ChromeContentBrowserClientPluginsPart); 626 extra_parts_.push_back(new ChromeContentBrowserClientPluginsPart);
(...skipping 541 matching lines...) Expand 10 before | Expand all | Expand 10 after
1162 } 1168 }
1163 if (browser_command_line.HasSwitch( 1169 if (browser_command_line.HasSwitch(
1164 switches::kDisableOfflineAutoReloadVisibleOnly)) { 1170 switches::kDisableOfflineAutoReloadVisibleOnly)) {
1165 return false; 1171 return false;
1166 } 1172 }
1167 return true; 1173 return true;
1168 } 1174 }
1169 1175
1170 } // namespace 1176 } // namespace
1171 1177
1178 // When Chrome is updated on non-Windows platforms, the new files (like
1179 // V8 natives and snapshot) can have the same names as the previous
1180 // versions. Since the renderers for an existing Chrome browser process
1181 // are likely not compatible with the new files, the browser keeps hold
1182 // of the old files using an open fd. This fd is passed to subprocesses
1183 // like renderers. Here we add the flag to tell the subprocesses where
1184 // to find these file descriptors.
1185 void ChromeContentBrowserClient::AppendMappedFileCommandLineSwitches(
1186 base::CommandLine* command_line) {
1187 #if defined(OS_POSIX) && !defined(OS_MACOSX)
1188 #if defined(V8_USE_EXTERNAL_STARTUP_DATA)
1189 std::string process_type =
1190 command_line->GetSwitchValueASCII(switches::kProcessType);
1191 if (process_type != switches::kZygoteProcess) {
1192 // We want to pass the natives by fd because after an update the file may
1193 // be updated, but we want the newly launched renderers to get the old one,
1194 // opened by the browser when it started.
1195 DCHECK(natives_fd_exists());
1196 command_line->AppendSwitch(::switches::kV8NativesPassedByFD);
1197 if (snapshot_fd_exists())
1198 command_line->AppendSwitch(::switches::kV8SnapshotPassedByFD);
1199 }
1200 #endif // V8_USE_EXTERNAL_STARTUP_DATA
1201 #endif // OS_POSIX && !OS_MACOSX
1202 }
1203
1172 void ChromeContentBrowserClient::AppendExtraCommandLineSwitches( 1204 void ChromeContentBrowserClient::AppendExtraCommandLineSwitches(
1173 base::CommandLine* command_line, 1205 base::CommandLine* command_line,
1174 int child_process_id) { 1206 int child_process_id) {
1175 #if defined(OS_MACOSX) 1207 #if defined(OS_MACOSX)
1176 scoped_ptr<metrics::ClientInfo> client_info = 1208 scoped_ptr<metrics::ClientInfo> client_info =
1177 GoogleUpdateSettings::LoadMetricsClientInfo(); 1209 GoogleUpdateSettings::LoadMetricsClientInfo();
1178 if (client_info) { 1210 if (client_info) {
1179 command_line->AppendSwitchASCII(switches::kMetricsClientID, 1211 command_line->AppendSwitchASCII(switches::kMetricsClientID,
1180 client_info->client_id); 1212 client_info->client_id);
1181 } 1213 }
(...skipping 1025 matching lines...) Expand 10 before | Expand all | Expand 10 after
2207 extra_parts_[i]->GetAdditionalFileSystemBackends( 2239 extra_parts_[i]->GetAdditionalFileSystemBackends(
2208 browser_context, storage_partition_path, additional_backends); 2240 browser_context, storage_partition_path, additional_backends);
2209 } 2241 }
2210 } 2242 }
2211 2243
2212 #if defined(OS_POSIX) && !defined(OS_MACOSX) 2244 #if defined(OS_POSIX) && !defined(OS_MACOSX)
2213 void ChromeContentBrowserClient::GetAdditionalMappedFilesForChildProcess( 2245 void ChromeContentBrowserClient::GetAdditionalMappedFilesForChildProcess(
2214 const base::CommandLine& command_line, 2246 const base::CommandLine& command_line,
2215 int child_process_id, 2247 int child_process_id,
2216 FileDescriptorInfo* mappings) { 2248 FileDescriptorInfo* mappings) {
2249 #if defined(V8_USE_EXTERNAL_STARTUP_DATA)
2250 if (!natives_fd_exists()) {
2251 int v8_natives_fd = -1;
2252 int v8_snapshot_fd = -1;
2253 if (gin::V8Initializer::OpenV8FilesForChildProcesses(&v8_natives_fd,
2254 &v8_snapshot_fd)) {
2255 v8_natives_fd_.reset(v8_natives_fd);
2256 v8_snapshot_fd_.reset(v8_snapshot_fd);
2257 }
2258 }
2259 // V8 can't start up without the source of the natives, but it can
2260 // start up (slower) without the snapshot.
2261 DCHECK(natives_fd_exists());
2262 mappings->Share(kV8NativesDataDescriptor, v8_natives_fd_.get());
2263 if (snapshot_fd_exists())
2264 mappings->Share(kV8SnapshotDataDescriptor, v8_snapshot_fd_.get());
2265 #endif // V8_USE_EXTERNAL_STARTUP_DATA
2266
2217 #if defined(OS_ANDROID) 2267 #if defined(OS_ANDROID)
2218 base::FilePath data_path; 2268 base::FilePath data_path;
2219 PathService::Get(ui::DIR_RESOURCE_PAKS_ANDROID, &data_path); 2269 PathService::Get(ui::DIR_RESOURCE_PAKS_ANDROID, &data_path);
2220 DCHECK(!data_path.empty()); 2270 DCHECK(!data_path.empty());
2221 2271
2222 int flags = base::File::FLAG_OPEN | base::File::FLAG_READ; 2272 int flags = base::File::FLAG_OPEN | base::File::FLAG_READ;
2223 base::FilePath chrome_resources_pak = 2273 base::FilePath chrome_resources_pak =
2224 data_path.AppendASCII("chrome_100_percent.pak"); 2274 data_path.AppendASCII("chrome_100_percent.pak");
2225 base::File file(chrome_resources_pak, flags); 2275 base::File file(chrome_resources_pak, flags);
2226 DCHECK(file.IsValid()); 2276 DCHECK(file.IsValid());
(...skipping 23 matching lines...) Expand all
2250 base::ScopedFD(file.TakePlatformFile())); 2300 base::ScopedFD(file.TakePlatformFile()));
2251 } else { 2301 } else {
2252 LOG(ERROR) << "Failed to create file for minidump, crash reporting will " 2302 LOG(ERROR) << "Failed to create file for minidump, crash reporting will "
2253 "be disabled for this process."; 2303 "be disabled for this process.";
2254 } 2304 }
2255 } 2305 }
2256 2306
2257 base::FilePath app_data_path; 2307 base::FilePath app_data_path;
2258 PathService::Get(base::DIR_ANDROID_APP_DATA, &app_data_path); 2308 PathService::Get(base::DIR_ANDROID_APP_DATA, &app_data_path);
2259 DCHECK(!app_data_path.empty()); 2309 DCHECK(!app_data_path.empty());
2310
2311 flags = base::File::FLAG_OPEN | base::File::FLAG_READ;
2312 base::FilePath icudata_path =
2313 app_data_path.AppendASCII(base::i18n::kIcuDataFileName);
2314 base::File icudata_file(icudata_path, flags);
2315 DCHECK(icudata_file.IsValid());
2316 mappings->Transfer(kAndroidICUDataDescriptor,
2317 base::ScopedFD(icudata_file.TakePlatformFile()));
2260 #else 2318 #else
2261 int crash_signal_fd = GetCrashSignalFD(command_line); 2319 int crash_signal_fd = GetCrashSignalFD(command_line);
2262 if (crash_signal_fd >= 0) { 2320 if (crash_signal_fd >= 0) {
2263 mappings->Share(kCrashDumpSignal, crash_signal_fd); 2321 mappings->Share(kCrashDumpSignal, crash_signal_fd);
2264 } 2322 }
2265 #endif // defined(OS_ANDROID) 2323 #endif // defined(OS_ANDROID)
2266 } 2324 }
2267 #endif // defined(OS_POSIX) && !defined(OS_MACOSX) 2325 #endif // defined(OS_POSIX) && !defined(OS_MACOSX)
2268 2326
2269 #if defined(OS_WIN) 2327 #if defined(OS_WIN)
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
2434 switches::kDisableWebRtcEncryption, 2492 switches::kDisableWebRtcEncryption,
2435 }; 2493 };
2436 to_command_line->CopySwitchesFrom(from_command_line, 2494 to_command_line->CopySwitchesFrom(from_command_line,
2437 kWebRtcDevSwitchNames, 2495 kWebRtcDevSwitchNames,
2438 arraysize(kWebRtcDevSwitchNames)); 2496 arraysize(kWebRtcDevSwitchNames));
2439 } 2497 }
2440 } 2498 }
2441 #endif // defined(ENABLE_WEBRTC) 2499 #endif // defined(ENABLE_WEBRTC)
2442 2500
2443 } // namespace chrome 2501 } // namespace chrome
OLDNEW
« no previous file with comments | « chrome/browser/chrome_content_browser_client.h ('k') | chromecast/browser/cast_content_browser_client.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698