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" |
28 #include "chrome/common/transport_dib.h" | 29 #include "chrome/common/transport_dib.h" |
29 #include "chrome/renderer/render_view.h" | 30 #include "chrome/renderer/render_view.h" |
30 #include "ipc/ipc_channel.h" | 31 #include "ipc/ipc_channel.h" |
31 #include "ipc/ipc_message_utils.h" | 32 #include "ipc/ipc_message_utils.h" |
32 #include "media/base/media.h" | 33 #include "media/base/media.h" |
| 34 #include "native_client/src/trusted/plugin/nacl_entry_points.h" |
33 #include "webkit/glue/webkit_glue.h" | 35 #include "webkit/glue/webkit_glue.h" |
34 | 36 |
35 //----------------------------------------------------------------------------- | 37 //----------------------------------------------------------------------------- |
36 | 38 |
37 RenderProcess::RenderProcess() | 39 RenderProcess::RenderProcess() |
38 : ALLOW_THIS_IN_INITIALIZER_LIST(shared_mem_cache_cleaner_( | 40 : ALLOW_THIS_IN_INITIALIZER_LIST(shared_mem_cache_cleaner_( |
39 base::TimeDelta::FromSeconds(5), | 41 base::TimeDelta::FromSeconds(5), |
40 this, &RenderProcess::ClearTransportDIBCache)), | 42 this, &RenderProcess::ClearTransportDIBCache)), |
41 sequence_number_(0) { | 43 sequence_number_(0) { |
42 in_process_plugins_ = InProcessPlugins(); | 44 in_process_plugins_ = InProcessPlugins(); |
(...skipping 30 matching lines...) Expand all Loading... |
73 } | 75 } |
74 | 76 |
75 if (command_line.HasSwitch(switches::kEnableWatchdog)) { | 77 if (command_line.HasSwitch(switches::kEnableWatchdog)) { |
76 // TODO(JAR): Need to implement renderer IO msgloop watchdog. | 78 // TODO(JAR): Need to implement renderer IO msgloop watchdog. |
77 } | 79 } |
78 | 80 |
79 if (command_line.HasSwitch(switches::kDumpHistogramsOnExit)) { | 81 if (command_line.HasSwitch(switches::kDumpHistogramsOnExit)) { |
80 StatisticsRecorder::set_dump_on_exit(true); | 82 StatisticsRecorder::set_dump_on_exit(true); |
81 } | 83 } |
82 | 84 |
| 85 if (command_line.HasSwitch(switches::kInternalNaCl)) |
| 86 RegisterInternalNaClPlugin(RenderProcess::LaunchNaClProcess); |
| 87 |
83 FilePath module_path; | 88 FilePath module_path; |
84 initialized_media_library_ = | 89 initialized_media_library_ = |
85 PathService::Get(base::DIR_MODULE, &module_path) && | 90 PathService::Get(base::DIR_MODULE, &module_path) && |
86 media::InitializeMediaLibrary(module_path); | 91 media::InitializeMediaLibrary(module_path); |
87 } | 92 } |
88 | 93 |
89 RenderProcess::~RenderProcess() { | 94 RenderProcess::~RenderProcess() { |
90 // TODO(port) | 95 // TODO(port) |
91 // Try and limit what we pull in for our non-Win unit test bundle | 96 // Try and limit what we pull in for our non-Win unit test bundle |
92 #ifndef NDEBUG | 97 #ifndef NDEBUG |
(...skipping 12 matching lines...) Expand all Loading... |
105 // implementation only allows one UI loop per process. | 110 // implementation only allows one UI loop per process. |
106 if (command_line.HasSwitch(switches::kInProcessPlugins)) | 111 if (command_line.HasSwitch(switches::kInProcessPlugins)) |
107 NOTIMPLEMENTED() << ": in process plugins not supported on Linux"; | 112 NOTIMPLEMENTED() << ": in process plugins not supported on Linux"; |
108 return command_line.HasSwitch(switches::kInProcessPlugins); | 113 return command_line.HasSwitch(switches::kInProcessPlugins); |
109 #else | 114 #else |
110 return command_line.HasSwitch(switches::kInProcessPlugins) || | 115 return command_line.HasSwitch(switches::kInProcessPlugins) || |
111 command_line.HasSwitch(switches::kSingleProcess); | 116 command_line.HasSwitch(switches::kSingleProcess); |
112 #endif | 117 #endif |
113 } | 118 } |
114 | 119 |
| 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 |
115 // ----------------------------------------------------------------------------- | 133 // ----------------------------------------------------------------------------- |
116 // Platform specific code for dealing with bitmap transport... | 134 // Platform specific code for dealing with bitmap transport... |
117 | 135 |
118 TransportDIB* RenderProcess::CreateTransportDIB(size_t size) { | 136 TransportDIB* RenderProcess::CreateTransportDIB(size_t size) { |
119 #if defined(OS_WIN) || defined(OS_LINUX) | 137 #if defined(OS_WIN) || defined(OS_LINUX) |
120 // Windows and Linux create transport DIBs inside the renderer | 138 // Windows and Linux create transport DIBs inside the renderer |
121 return TransportDIB::Create(size, sequence_number_++); | 139 return TransportDIB::Create(size, sequence_number_++); |
122 #elif defined(OS_MACOSX) // defined(OS_WIN) || defined(OS_LINUX) | 140 #elif defined(OS_MACOSX) // defined(OS_WIN) || defined(OS_LINUX) |
123 // Mac creates transport DIBs in the browser, so we need to do a sync IPC to | 141 // Mac creates transport DIBs in the browser, so we need to do a sync IPC to |
124 // get one. | 142 // get one. |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
239 } | 257 } |
240 | 258 |
241 void RenderProcess::ClearTransportDIBCache() { | 259 void RenderProcess::ClearTransportDIBCache() { |
242 for (size_t i = 0; i < arraysize(shared_mem_cache_); ++i) { | 260 for (size_t i = 0; i < arraysize(shared_mem_cache_); ++i) { |
243 if (shared_mem_cache_[i]) { | 261 if (shared_mem_cache_[i]) { |
244 FreeTransportDIB(shared_mem_cache_[i]); | 262 FreeTransportDIB(shared_mem_cache_[i]); |
245 shared_mem_cache_[i] = NULL; | 263 shared_mem_cache_[i] = NULL; |
246 } | 264 } |
247 } | 265 } |
248 } | 266 } |
OLD | NEW |