| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 "build/build_config.h" | 5 #include "build/build_config.h" |
| 6 | 6 |
| 7 #if defined(OS_WIN) | 7 #if defined(OS_WIN) |
| 8 #include <windows.h> | 8 #include <windows.h> |
| 9 #include <objidl.h> | 9 #include <objidl.h> |
| 10 #include <mlang.h> | 10 #include <mlang.h> |
| 11 #endif | 11 #endif |
| 12 | 12 |
| 13 #include "chrome/renderer/render_process.h" | 13 #include "chrome/renderer/render_process.h" |
| 14 | 14 |
| 15 #include "base/basictypes.h" | 15 #include "base/basictypes.h" |
| 16 #include "base/command_line.h" | 16 #include "base/command_line.h" |
| 17 #include "base/compiler_specific.h" | 17 #include "base/compiler_specific.h" |
| 18 #include "base/file_util.h" | 18 #include "base/file_util.h" |
| 19 #include "base/message_loop.h" | 19 #include "base/message_loop.h" |
| 20 #include "base/histogram.h" | 20 #include "base/histogram.h" |
| 21 #include "base/path_service.h" | 21 #include "base/path_service.h" |
| 22 #include "base/sys_info.h" | 22 #include "base/sys_info.h" |
| 23 // TODO(jar): DNS calls should be renderer specific, not including browser. | 23 // TODO(jar): DNS calls should be renderer specific, not including browser. |
| 24 #include "chrome/browser/net/dns_global.h" | 24 #include "chrome/browser/net/dns_global.h" |
| 25 #include "chrome/common/chrome_switches.h" | 25 #include "chrome/common/chrome_switches.h" |
| 26 #include "chrome/common/chrome_paths.h" | 26 #include "chrome/common/chrome_paths.h" |
| 27 #include "chrome/common/render_messages.h" | 27 #include "chrome/common/render_messages.h" |
| 28 #include "chrome/common/nacl_types.h" | |
| 29 #include "chrome/common/transport_dib.h" | 28 #include "chrome/common/transport_dib.h" |
| 30 #include "chrome/renderer/render_view.h" | 29 #include "chrome/renderer/render_view.h" |
| 31 #include "ipc/ipc_channel.h" | 30 #include "ipc/ipc_channel.h" |
| 32 #include "ipc/ipc_message_utils.h" | 31 #include "ipc/ipc_message_utils.h" |
| 33 #include "media/base/media.h" | 32 #include "media/base/media.h" |
| 34 #include "native_client/src/trusted/plugin/nacl_entry_points.h" | |
| 35 #include "webkit/glue/webkit_glue.h" | 33 #include "webkit/glue/webkit_glue.h" |
| 36 | 34 |
| 37 //----------------------------------------------------------------------------- | 35 //----------------------------------------------------------------------------- |
| 38 | 36 |
| 39 RenderProcess::RenderProcess() | 37 RenderProcess::RenderProcess() |
| 40 : ALLOW_THIS_IN_INITIALIZER_LIST(shared_mem_cache_cleaner_( | 38 : ALLOW_THIS_IN_INITIALIZER_LIST(shared_mem_cache_cleaner_( |
| 41 base::TimeDelta::FromSeconds(5), | 39 base::TimeDelta::FromSeconds(5), |
| 42 this, &RenderProcess::ClearTransportDIBCache)), | 40 this, &RenderProcess::ClearTransportDIBCache)), |
| 43 sequence_number_(0) { | 41 sequence_number_(0) { |
| 44 in_process_plugins_ = InProcessPlugins(); | 42 in_process_plugins_ = InProcessPlugins(); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 75 } | 73 } |
| 76 | 74 |
| 77 if (command_line.HasSwitch(switches::kEnableWatchdog)) { | 75 if (command_line.HasSwitch(switches::kEnableWatchdog)) { |
| 78 // TODO(JAR): Need to implement renderer IO msgloop watchdog. | 76 // TODO(JAR): Need to implement renderer IO msgloop watchdog. |
| 79 } | 77 } |
| 80 | 78 |
| 81 if (command_line.HasSwitch(switches::kDumpHistogramsOnExit)) { | 79 if (command_line.HasSwitch(switches::kDumpHistogramsOnExit)) { |
| 82 StatisticsRecorder::set_dump_on_exit(true); | 80 StatisticsRecorder::set_dump_on_exit(true); |
| 83 } | 81 } |
| 84 | 82 |
| 85 if (command_line.HasSwitch(switches::kInternalNaCl)) | |
| 86 RegisterInternalNaClPlugin(RenderProcess::LaunchNaClProcess); | |
| 87 | |
| 88 FilePath module_path; | 83 FilePath module_path; |
| 89 initialized_media_library_ = | 84 initialized_media_library_ = |
| 90 PathService::Get(base::DIR_MODULE, &module_path) && | 85 PathService::Get(base::DIR_MODULE, &module_path) && |
| 91 media::InitializeMediaLibrary(module_path); | 86 media::InitializeMediaLibrary(module_path); |
| 92 } | 87 } |
| 93 | 88 |
| 94 RenderProcess::~RenderProcess() { | 89 RenderProcess::~RenderProcess() { |
| 95 // TODO(port) | 90 // TODO(port) |
| 96 // Try and limit what we pull in for our non-Win unit test bundle | 91 // Try and limit what we pull in for our non-Win unit test bundle |
| 97 #ifndef NDEBUG | 92 #ifndef NDEBUG |
| (...skipping 12 matching lines...) Expand all Loading... |
| 110 // implementation only allows one UI loop per process. | 105 // implementation only allows one UI loop per process. |
| 111 if (command_line.HasSwitch(switches::kInProcessPlugins)) | 106 if (command_line.HasSwitch(switches::kInProcessPlugins)) |
| 112 NOTIMPLEMENTED() << ": in process plugins not supported on Linux"; | 107 NOTIMPLEMENTED() << ": in process plugins not supported on Linux"; |
| 113 return command_line.HasSwitch(switches::kInProcessPlugins); | 108 return command_line.HasSwitch(switches::kInProcessPlugins); |
| 114 #else | 109 #else |
| 115 return command_line.HasSwitch(switches::kInProcessPlugins) || | 110 return command_line.HasSwitch(switches::kInProcessPlugins) || |
| 116 command_line.HasSwitch(switches::kSingleProcess); | 111 command_line.HasSwitch(switches::kSingleProcess); |
| 117 #endif | 112 #endif |
| 118 } | 113 } |
| 119 | 114 |
| 120 bool RenderProcess::LaunchNaClProcess(int imc_fd, | |
| 121 nacl::Handle* handle) { | |
| 122 // TODO(gregoryd): nacl::FileDescriptor will be soon merged with | |
| 123 // base::FileDescriptor | |
| 124 nacl::FileDescriptor descriptor; | |
| 125 if (!RenderThread::current()->Send( | |
| 126 new ViewHostMsg_LaunchNaCl(imc_fd, &descriptor))) { | |
| 127 return false; | |
| 128 } | |
| 129 *handle = NATIVE_HANDLE(descriptor); | |
| 130 return true; | |
| 131 } | |
| 132 | |
| 133 // ----------------------------------------------------------------------------- | 115 // ----------------------------------------------------------------------------- |
| 134 // Platform specific code for dealing with bitmap transport... | 116 // Platform specific code for dealing with bitmap transport... |
| 135 | 117 |
| 136 TransportDIB* RenderProcess::CreateTransportDIB(size_t size) { | 118 TransportDIB* RenderProcess::CreateTransportDIB(size_t size) { |
| 137 #if defined(OS_WIN) || defined(OS_LINUX) | 119 #if defined(OS_WIN) || defined(OS_LINUX) |
| 138 // Windows and Linux create transport DIBs inside the renderer | 120 // Windows and Linux create transport DIBs inside the renderer |
| 139 return TransportDIB::Create(size, sequence_number_++); | 121 return TransportDIB::Create(size, sequence_number_++); |
| 140 #elif defined(OS_MACOSX) // defined(OS_WIN) || defined(OS_LINUX) | 122 #elif defined(OS_MACOSX) // defined(OS_WIN) || defined(OS_LINUX) |
| 141 // Mac creates transport DIBs in the browser, so we need to do a sync IPC to | 123 // Mac creates transport DIBs in the browser, so we need to do a sync IPC to |
| 142 // get one. | 124 // get one. |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 257 } | 239 } |
| 258 | 240 |
| 259 void RenderProcess::ClearTransportDIBCache() { | 241 void RenderProcess::ClearTransportDIBCache() { |
| 260 for (size_t i = 0; i < arraysize(shared_mem_cache_); ++i) { | 242 for (size_t i = 0; i < arraysize(shared_mem_cache_); ++i) { |
| 261 if (shared_mem_cache_[i]) { | 243 if (shared_mem_cache_[i]) { |
| 262 FreeTransportDIB(shared_mem_cache_[i]); | 244 FreeTransportDIB(shared_mem_cache_[i]); |
| 263 shared_mem_cache_[i] = NULL; | 245 shared_mem_cache_[i] = NULL; |
| 264 } | 246 } |
| 265 } | 247 } |
| 266 } | 248 } |
| OLD | NEW |