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 #ifndef COMPONENTS_NACL_BROWSER_NACL_PROCESS_HOST_H_ | 5 #ifndef COMPONENTS_NACL_BROWSER_NACL_PROCESS_HOST_H_ |
6 #define COMPONENTS_NACL_BROWSER_NACL_PROCESS_HOST_H_ | 6 #define COMPONENTS_NACL_BROWSER_NACL_PROCESS_HOST_H_ |
7 | 7 |
8 #include "build/build_config.h" | 8 #include "build/build_config.h" |
9 | 9 |
10 #include "base/files/file.h" | 10 #include "base/files/file.h" |
11 #include "base/files/file_path.h" | 11 #include "base/files/file_path.h" |
12 #include "base/files/file_util_proxy.h" | 12 #include "base/files/file_util_proxy.h" |
13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
14 #include "base/memory/weak_ptr.h" | 14 #include "base/memory/weak_ptr.h" |
15 #include "base/message_loop/message_loop.h" | 15 #include "base/message_loop/message_loop.h" |
16 #include "base/process/process.h" | 16 #include "base/process/process.h" |
17 #include "components/nacl/common/nacl_types.h" | 17 #include "components/nacl/common/nacl_types.h" |
18 #include "content/public/browser/browser_child_process_host_delegate.h" | 18 #include "content/public/browser/browser_child_process_host_delegate.h" |
19 #include "content/public/browser/browser_child_process_host_iterator.h" | 19 #include "content/public/browser/browser_child_process_host_iterator.h" |
20 #include "ipc/ipc_channel_handle.h" | 20 #include "ipc/ipc_channel_handle.h" |
21 #include "net/socket/socket_descriptor.h" | 21 #include "net/socket/socket_descriptor.h" |
22 #include "ppapi/shared_impl/ppapi_permissions.h" | 22 #include "ppapi/shared_impl/ppapi_permissions.h" |
23 #include "url/gurl.h" | 23 #include "url/gurl.h" |
24 | 24 |
| 25 // NaClFileToken here is forward declared here instead of including |
| 26 // nacl_file_info.h because that file isn't safe to include for disable_nacl=1 |
| 27 // builds. |
| 28 // TODO(teravest): Stop building this header in disable_nacl=1 builds and |
| 29 // include nacl_file_info.h instead of forward declaring NaClFileToken. |
| 30 struct NaClFileToken; |
| 31 |
25 namespace content { | 32 namespace content { |
26 class BrowserChildProcessHost; | 33 class BrowserChildProcessHost; |
27 class BrowserPpapiHost; | 34 class BrowserPpapiHost; |
28 } | 35 } |
29 | 36 |
30 namespace IPC { | 37 namespace IPC { |
31 class ChannelProxy; | 38 class ChannelProxy; |
32 } | 39 } |
33 | 40 |
34 namespace nacl { | 41 namespace nacl { |
35 | 42 |
36 class NaClHostMessageFilter; | 43 class NaClHostMessageFilter; |
37 void* AllocateAddressSpaceASLR(base::ProcessHandle process, size_t size); | 44 void* AllocateAddressSpaceASLR(base::ProcessHandle process, size_t size); |
38 | 45 |
39 // Represents the browser side of the browser <--> NaCl communication | 46 // Represents the browser side of the browser <--> NaCl communication |
40 // channel. There will be one NaClProcessHost per NaCl process | 47 // channel. There will be one NaClProcessHost per NaCl process |
41 // The browser is responsible for starting the NaCl process | 48 // The browser is responsible for starting the NaCl process |
42 // when requested by the renderer. | 49 // when requested by the renderer. |
43 // After that, most of the communication is directly between NaCl plugin | 50 // After that, most of the communication is directly between NaCl plugin |
44 // running in the renderer and NaCl processes. | 51 // running in the renderer and NaCl processes. |
45 class NaClProcessHost : public content::BrowserChildProcessHostDelegate { | 52 class NaClProcessHost : public content::BrowserChildProcessHostDelegate { |
46 public: | 53 public: |
47 // manifest_url: the URL of the manifest of the Native Client plugin being | 54 // manifest_url: the URL of the manifest of the Native Client plugin being |
48 // executed. | 55 // executed. |
| 56 // nexe_file: A file that corresponds to the nexe module to be loaded. |
| 57 // nexe_token: A cache validation token for nexe_file. |
49 // permissions: PPAPI permissions, to control access to private APIs. | 58 // permissions: PPAPI permissions, to control access to private APIs. |
50 // render_view_id: RenderView routing id, to control access to private APIs. | 59 // render_view_id: RenderView routing id, to control access to private APIs. |
51 // permission_bits: controls which interfaces the NaCl plugin can use. | 60 // permission_bits: controls which interfaces the NaCl plugin can use. |
52 // uses_irt: whether the launched process should use the IRT. | 61 // uses_irt: whether the launched process should use the IRT. |
53 // uses_nonsfi_mode: whether the program should be loaded under non-SFI mode. | 62 // uses_nonsfi_mode: whether the program should be loaded under non-SFI mode. |
54 // enable_dyncode_syscalls: whether the launched process should allow dyncode | 63 // enable_dyncode_syscalls: whether the launched process should allow dyncode |
55 // and mmap with PROT_EXEC. | 64 // and mmap with PROT_EXEC. |
56 // enable_exception_handling: whether the launched process should allow | 65 // enable_exception_handling: whether the launched process should allow |
57 // hardware exception handling. | 66 // hardware exception handling. |
58 // enable_crash_throttling: whether a crash of this process contributes | 67 // enable_crash_throttling: whether a crash of this process contributes |
59 // to the crash throttling statistics, and also | 68 // to the crash throttling statistics, and also |
60 // whether this process should not start when too | 69 // whether this process should not start when too |
61 // many crashes have been observed. | 70 // many crashes have been observed. |
62 // off_the_record: was the process launched from an incognito renderer? | 71 // off_the_record: was the process launched from an incognito renderer? |
63 // profile_directory: is the path of current profile directory. | 72 // profile_directory: is the path of current profile directory. |
64 NaClProcessHost(const GURL& manifest_url, | 73 NaClProcessHost(const GURL& manifest_url, |
65 base::File nexe_file, | 74 base::File nexe_file, |
| 75 const NaClFileToken& nexe_token, |
66 ppapi::PpapiPermissions permissions, | 76 ppapi::PpapiPermissions permissions, |
67 int render_view_id, | 77 int render_view_id, |
68 uint32 permission_bits, | 78 uint32 permission_bits, |
69 bool uses_irt, | 79 bool uses_irt, |
70 bool uses_nonsfi_mode, | 80 bool uses_nonsfi_mode, |
71 bool enable_dyncode_syscalls, | 81 bool enable_dyncode_syscalls, |
72 bool enable_exception_handling, | 82 bool enable_exception_handling, |
73 bool enable_crash_throttling, | 83 bool enable_crash_throttling, |
74 bool off_the_record, | 84 bool off_the_record, |
75 const base::FilePath& profile_directory); | 85 const base::FilePath& profile_directory); |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
183 // created. | 193 // created. |
184 void OnPpapiChannelsCreated( | 194 void OnPpapiChannelsCreated( |
185 const IPC::ChannelHandle& browser_channel_handle, | 195 const IPC::ChannelHandle& browser_channel_handle, |
186 const IPC::ChannelHandle& ppapi_renderer_channel_handle, | 196 const IPC::ChannelHandle& ppapi_renderer_channel_handle, |
187 const IPC::ChannelHandle& trusted_renderer_channel_handle, | 197 const IPC::ChannelHandle& trusted_renderer_channel_handle, |
188 const IPC::ChannelHandle& manifest_service_channel_handle); | 198 const IPC::ChannelHandle& manifest_service_channel_handle); |
189 | 199 |
190 GURL manifest_url_; | 200 GURL manifest_url_; |
191 base::File nexe_file_; | 201 base::File nexe_file_; |
192 | 202 |
| 203 // TODO(teravest): Use NaClFileInfo here, but without breaking the |
| 204 // disable_nacl=1 build. (Why is this file even built with disable_nacl=1?) |
| 205 uint64_t nexe_token_lo_; |
| 206 uint64_t nexe_token_hi_; |
| 207 |
193 ppapi::PpapiPermissions permissions_; | 208 ppapi::PpapiPermissions permissions_; |
194 | 209 |
195 #if defined(OS_WIN) | 210 #if defined(OS_WIN) |
196 // This field becomes true when the broker successfully launched | 211 // This field becomes true when the broker successfully launched |
197 // the NaCl loader. | 212 // the NaCl loader. |
198 bool process_launched_by_broker_; | 213 bool process_launched_by_broker_; |
199 #endif | 214 #endif |
200 // The NaClHostMessageFilter that requested this NaCl process. We use | 215 // The NaClHostMessageFilter that requested this NaCl process. We use |
201 // this for sending the reply once the process has started. | 216 // this for sending the reply once the process has started. |
202 scoped_refptr<NaClHostMessageFilter> nacl_host_message_filter_; | 217 scoped_refptr<NaClHostMessageFilter> nacl_host_message_filter_; |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
242 | 257 |
243 // Throttling time in milliseconds for PpapiHostMsg_Keepalive IPCs. | 258 // Throttling time in milliseconds for PpapiHostMsg_Keepalive IPCs. |
244 static unsigned keepalive_throttle_interval_milliseconds_; | 259 static unsigned keepalive_throttle_interval_milliseconds_; |
245 | 260 |
246 DISALLOW_COPY_AND_ASSIGN(NaClProcessHost); | 261 DISALLOW_COPY_AND_ASSIGN(NaClProcessHost); |
247 }; | 262 }; |
248 | 263 |
249 } // namespace nacl | 264 } // namespace nacl |
250 | 265 |
251 #endif // COMPONENTS_NACL_BROWSER_NACL_PROCESS_HOST_H_ | 266 #endif // COMPONENTS_NACL_BROWSER_NACL_PROCESS_HOST_H_ |
OLD | NEW |