| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/shell/browser/shell_content_browser_client.h" | 5 #include "content/shell/browser/shell_content_browser_client.h" |
| 6 | 6 |
| 7 #include "base/base_switches.h" | 7 #include "base/base_switches.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/files/file.h" | 9 #include "base/files/file.h" |
| 10 #include "base/files/file_util.h" | 10 #include "base/files/file_util.h" |
| (...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 326 nullptr, | 326 nullptr, |
| 327 gfx::Size())->web_contents()); | 327 gfx::Size())->web_contents()); |
| 328 } | 328 } |
| 329 | 329 |
| 330 #if defined(OS_POSIX) && !defined(OS_MACOSX) | 330 #if defined(OS_POSIX) && !defined(OS_MACOSX) |
| 331 void ShellContentBrowserClient::GetAdditionalMappedFilesForChildProcess( | 331 void ShellContentBrowserClient::GetAdditionalMappedFilesForChildProcess( |
| 332 const base::CommandLine& command_line, | 332 const base::CommandLine& command_line, |
| 333 int child_process_id, | 333 int child_process_id, |
| 334 FileDescriptorInfo* mappings) { | 334 FileDescriptorInfo* mappings) { |
| 335 #if defined(V8_USE_EXTERNAL_STARTUP_DATA) | 335 #if defined(V8_USE_EXTERNAL_STARTUP_DATA) |
| 336 if (v8_snapshot_fd_.get() == -1 && v8_natives_fd_.get() == -1) { | 336 if (v8_natives_fd_.get() == -1 || v8_snapshot_fd_.get() == -1) { |
| 337 base::FilePath v8_data_path; | 337 int v8_natives_fd = -1; |
| 338 PathService::Get(gin::V8Initializer::kV8SnapshotBasePathKey, &v8_data_path); | 338 int v8_snapshot_fd = -1; |
| 339 DCHECK(!v8_data_path.empty()); | 339 if (gin::V8Initializer::OpenV8FilesForChildProcesses(&v8_natives_fd, |
| 340 | 340 &v8_snapshot_fd)) { |
| 341 int file_flags = base::File::FLAG_OPEN | base::File::FLAG_READ; | 341 v8_natives_fd_.reset(v8_natives_fd); |
| 342 base::FilePath v8_natives_data_path = | 342 v8_snapshot_fd_.reset(v8_snapshot_fd); |
| 343 v8_data_path.AppendASCII(gin::V8Initializer::kNativesFileName); | 343 } |
| 344 base::FilePath v8_snapshot_data_path = | |
| 345 v8_data_path.AppendASCII(gin::V8Initializer::kSnapshotFileName); | |
| 346 base::File v8_natives_data_file(v8_natives_data_path, file_flags); | |
| 347 base::File v8_snapshot_data_file(v8_snapshot_data_path, file_flags); | |
| 348 DCHECK(v8_natives_data_file.IsValid()); | |
| 349 DCHECK(v8_snapshot_data_file.IsValid()); | |
| 350 v8_natives_fd_.reset(v8_natives_data_file.TakePlatformFile()); | |
| 351 v8_snapshot_fd_.reset(v8_snapshot_data_file.TakePlatformFile()); | |
| 352 } | 344 } |
| 345 DCHECK(v8_natives_fd_.get() != -1 && v8_snapshot_fd_.get() != -1); |
| 353 mappings->Share(kV8NativesDataDescriptor, v8_natives_fd_.get()); | 346 mappings->Share(kV8NativesDataDescriptor, v8_natives_fd_.get()); |
| 354 mappings->Share(kV8SnapshotDataDescriptor, v8_snapshot_fd_.get()); | 347 mappings->Share(kV8SnapshotDataDescriptor, v8_snapshot_fd_.get()); |
| 355 #endif // V8_USE_EXTERNAL_STARTUP_DATA | 348 #endif // V8_USE_EXTERNAL_STARTUP_DATA |
| 356 | 349 |
| 357 #if defined(OS_ANDROID) | 350 #if defined(OS_ANDROID) |
| 358 int flags = base::File::FLAG_OPEN | base::File::FLAG_READ; | 351 int flags = base::File::FLAG_OPEN | base::File::FLAG_READ; |
| 359 base::FilePath pak_file; | 352 base::FilePath pak_file; |
| 360 bool r = PathService::Get(base::DIR_ANDROID_APP_DATA, &pak_file); | 353 bool r = PathService::Get(base::DIR_ANDROID_APP_DATA, &pak_file); |
| 361 CHECK(r); | 354 CHECK(r); |
| 362 pak_file = pak_file.Append(FILE_PATH_LITERAL("paks")); | 355 pak_file = pak_file.Append(FILE_PATH_LITERAL("paks")); |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 422 ShellBrowserContext* | 415 ShellBrowserContext* |
| 423 ShellContentBrowserClient::ShellBrowserContextForBrowserContext( | 416 ShellContentBrowserClient::ShellBrowserContextForBrowserContext( |
| 424 BrowserContext* content_browser_context) { | 417 BrowserContext* content_browser_context) { |
| 425 if (content_browser_context == browser_context()) | 418 if (content_browser_context == browser_context()) |
| 426 return browser_context(); | 419 return browser_context(); |
| 427 DCHECK_EQ(content_browser_context, off_the_record_browser_context()); | 420 DCHECK_EQ(content_browser_context, off_the_record_browser_context()); |
| 428 return off_the_record_browser_context(); | 421 return off_the_record_browser_context(); |
| 429 } | 422 } |
| 430 | 423 |
| 431 } // namespace content | 424 } // namespace content |
| OLD | NEW |