| 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 "ash/shell/content_client/shell_content_browser_client.h" | 5 #include "ash/shell/content_client/shell_content_browser_client.h" |
| 6 | 6 |
| 7 #include "ash/shell/content_client/shell_browser_main_parts.h" | 7 #include "ash/shell/content_client/shell_browser_main_parts.h" |
| 8 #include "base/command_line.h" |
| 8 #include "content/public/common/content_descriptors.h" | 9 #include "content/public/common/content_descriptors.h" |
| 10 #include "content/public/common/content_switches.h" |
| 9 #include "content/shell/browser/shell_browser_context.h" | 11 #include "content/shell/browser/shell_browser_context.h" |
| 10 #include "gin/v8_initializer.h" | 12 #include "gin/v8_initializer.h" |
| 11 #include "third_party/skia/include/core/SkBitmap.h" | 13 #include "third_party/skia/include/core/SkBitmap.h" |
| 12 | 14 |
| 13 namespace ash { | 15 namespace ash { |
| 14 namespace shell { | 16 namespace shell { |
| 15 | 17 |
| 16 ShellContentBrowserClient::ShellContentBrowserClient() | 18 ShellContentBrowserClient::ShellContentBrowserClient() |
| 17 : | 19 : |
| 18 #if defined(OS_POSIX) && !defined(OS_MACOSX) | 20 #if defined(OS_POSIX) && !defined(OS_MACOSX) |
| (...skipping 15 matching lines...) Expand all Loading... |
| 34 net::URLRequestContextGetter* ShellContentBrowserClient::CreateRequestContext( | 36 net::URLRequestContextGetter* ShellContentBrowserClient::CreateRequestContext( |
| 35 content::BrowserContext* content_browser_context, | 37 content::BrowserContext* content_browser_context, |
| 36 content::ProtocolHandlerMap* protocol_handlers, | 38 content::ProtocolHandlerMap* protocol_handlers, |
| 37 content::URLRequestInterceptorScopedVector request_interceptors) { | 39 content::URLRequestInterceptorScopedVector request_interceptors) { |
| 38 content::ShellBrowserContext* shell_context = | 40 content::ShellBrowserContext* shell_context = |
| 39 static_cast<content::ShellBrowserContext*>(content_browser_context); | 41 static_cast<content::ShellBrowserContext*>(content_browser_context); |
| 40 return shell_context->CreateRequestContext(protocol_handlers, | 42 return shell_context->CreateRequestContext(protocol_handlers, |
| 41 request_interceptors.Pass()); | 43 request_interceptors.Pass()); |
| 42 } | 44 } |
| 43 | 45 |
| 46 void ShellContentBrowserClient::AppendExtraCommandLineSwitches( |
| 47 base::CommandLine* command_line, |
| 48 int child_process_id) { |
| 49 #if defined(OS_POSIX) && !defined(OS_MACOSX) |
| 50 #if defined(V8_USE_EXTERNAL_STARTUP_DATA) |
| 51 std::string process_type = |
| 52 command_line->GetSwitchValueASCII(switches::kProcessType); |
| 53 if (process_type != switches::kZygoteProcess) { |
| 54 command_line->AppendSwitch(::switches::kV8NativesPassedByFD); |
| 55 command_line->AppendSwitch(::switches::kV8SnapshotPassedByFD); |
| 56 } |
| 57 #endif // V8_USE_EXTERNAL_STARTUP_DATA |
| 58 #endif // OS_POSIX && !OS_MACOSX |
| 59 } |
| 60 |
| 44 #if defined(OS_POSIX) && !defined(OS_MACOSX) | 61 #if defined(OS_POSIX) && !defined(OS_MACOSX) |
| 45 void ShellContentBrowserClient::GetAdditionalMappedFilesForChildProcess( | 62 void ShellContentBrowserClient::GetAdditionalMappedFilesForChildProcess( |
| 46 const base::CommandLine& command_line, | 63 const base::CommandLine& command_line, |
| 47 int child_process_id, | 64 int child_process_id, |
| 48 content::FileDescriptorInfo* mappings) { | 65 content::FileDescriptorInfo* mappings) { |
| 49 #if defined(V8_USE_EXTERNAL_STARTUP_DATA) | 66 #if defined(V8_USE_EXTERNAL_STARTUP_DATA) |
| 50 if (v8_natives_fd_.get() == -1 || v8_snapshot_fd_.get() == -1) { | 67 if (v8_natives_fd_.get() == -1 || v8_snapshot_fd_.get() == -1) { |
| 51 int v8_natives_fd = -1; | 68 int v8_natives_fd = -1; |
| 52 int v8_snapshot_fd = -1; | 69 int v8_snapshot_fd = -1; |
| 53 if (gin::V8Initializer::OpenV8FilesForChildProcesses(&v8_natives_fd, | 70 if (gin::V8Initializer::OpenV8FilesForChildProcesses(&v8_natives_fd, |
| 54 &v8_snapshot_fd)) { | 71 &v8_snapshot_fd)) { |
| 55 v8_natives_fd_.reset(v8_natives_fd); | 72 v8_natives_fd_.reset(v8_natives_fd); |
| 56 v8_snapshot_fd_.reset(v8_snapshot_fd); | 73 v8_snapshot_fd_.reset(v8_snapshot_fd); |
| 57 } | 74 } |
| 58 } | 75 } |
| 59 DCHECK(v8_natives_fd_.get() != -1 && v8_snapshot_fd_.get() != -1); | 76 DCHECK(v8_natives_fd_.get() != -1 && v8_snapshot_fd_.get() != -1); |
| 60 mappings->Share(kV8NativesDataDescriptor, v8_natives_fd_.get()); | 77 mappings->Share(kV8NativesDataDescriptor, v8_natives_fd_.get()); |
| 61 mappings->Share(kV8SnapshotDataDescriptor, v8_snapshot_fd_.get()); | 78 mappings->Share(kV8SnapshotDataDescriptor, v8_snapshot_fd_.get()); |
| 62 #endif // V8_USE_EXTERNAL_STARTUP_DATA | 79 #endif // V8_USE_EXTERNAL_STARTUP_DATA |
| 63 } | 80 } |
| 64 #endif // OS_POSIX && !OS_MACOSX | 81 #endif // OS_POSIX && !OS_MACOSX |
| 65 | 82 |
| 66 content::ShellBrowserContext* ShellContentBrowserClient::browser_context() { | 83 content::ShellBrowserContext* ShellContentBrowserClient::browser_context() { |
| 67 return shell_browser_main_parts_->browser_context(); | 84 return shell_browser_main_parts_->browser_context(); |
| 68 } | 85 } |
| 69 | 86 |
| 70 } // namespace examples | 87 } // namespace examples |
| 71 } // namespace views | 88 } // namespace views |
| OLD | NEW |