Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(456)

Side by Side Diff: components/nacl/browser/nacl_process_host.h

Issue 2514323004: Convert NaCl renderer-browser messages to mojo. (Closed)
Patch Set: Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <stddef.h> 10 #include <stddef.h>
11 #include <stdint.h> 11 #include <stdint.h>
12 12
13 #include <vector> 13 #include <vector>
14 14
15 #include "base/files/file.h" 15 #include "base/files/file.h"
16 #include "base/files/file_path.h" 16 #include "base/files/file_path.h"
17 #include "base/files/file_util_proxy.h" 17 #include "base/files/file_util_proxy.h"
18 #include "base/macros.h" 18 #include "base/macros.h"
19 #include "base/memory/ref_counted.h" 19 #include "base/memory/ref_counted.h"
20 #include "base/memory/shared_memory.h" 20 #include "base/memory/shared_memory.h"
21 #include "base/memory/weak_ptr.h" 21 #include "base/memory/weak_ptr.h"
22 #include "base/message_loop/message_loop.h" 22 #include "base/message_loop/message_loop.h"
23 #include "base/process/process.h" 23 #include "base/process/process.h"
24 #include "components/nacl/common/nacl.mojom.h"
24 #include "components/nacl/common/nacl_types.h" 25 #include "components/nacl/common/nacl_types.h"
25 #include "content/public/browser/browser_child_process_host_delegate.h" 26 #include "content/public/browser/browser_child_process_host_delegate.h"
26 #include "content/public/browser/browser_child_process_host_iterator.h" 27 #include "content/public/browser/browser_child_process_host_iterator.h"
27 #include "ipc/ipc_channel_handle.h" 28 #include "ipc/ipc_channel_handle.h"
28 #include "net/socket/socket_descriptor.h" 29 #include "net/socket/socket_descriptor.h"
29 #include "ppapi/shared_impl/ppapi_permissions.h" 30 #include "ppapi/shared_impl/ppapi_permissions.h"
30 #include "url/gurl.h" 31 #include "url/gurl.h"
31 32
32 namespace content { 33 namespace content {
33 class BrowserChildProcessHost; 34 class BrowserChildProcessHost;
(...skipping 10 matching lines...) Expand all
44 // to query the browser process for trusted information about a file. This 45 // to query the browser process for trusted information about a file. This
45 // helps establish that the file is known by the browser to be immutable 46 // helps establish that the file is known by the browser to be immutable
46 // and suitable for file-identity-based validation caching. lo == 0 && hi 47 // and suitable for file-identity-based validation caching. lo == 0 && hi
47 // == 0 indicates the token is invalid and no additional information is 48 // == 0 indicates the token is invalid and no additional information is
48 // available. 49 // available.
49 struct NaClFileToken { 50 struct NaClFileToken {
50 uint64_t lo; 51 uint64_t lo;
51 uint64_t hi; 52 uint64_t hi;
52 }; 53 };
53 54
54 class NaClHostMessageFilter;
55 void* AllocateAddressSpaceASLR(base::ProcessHandle process, size_t size); 55 void* AllocateAddressSpaceASLR(base::ProcessHandle process, size_t size);
56 56
57 // Represents the browser side of the browser <--> NaCl communication 57 // Represents the browser side of the browser <--> NaCl communication
58 // channel. There will be one NaClProcessHost per NaCl process 58 // channel. There will be one NaClProcessHost per NaCl process
59 // The browser is responsible for starting the NaCl process 59 // The browser is responsible for starting the NaCl process
60 // when requested by the renderer. 60 // when requested by the renderer.
61 // After that, most of the communication is directly between NaCl plugin 61 // After that, most of the communication is directly between NaCl plugin
62 // running in the renderer and NaCl processes. 62 // running in the renderer and NaCl processes.
63 class NaClProcessHost : public content::BrowserChildProcessHostDelegate { 63 class NaClProcessHost : public content::BrowserChildProcessHostDelegate {
64 public: 64 public:
65 // manifest_url: the URL of the manifest of the Native Client plugin being 65 // manifest_url: the URL of the manifest of the Native Client plugin being
66 // executed. 66 // executed.
67 // nexe_file: A file that corresponds to the nexe module to be loaded. 67 // nexe_file: A file that corresponds to the nexe module to be loaded.
68 // nexe_token: A cache validation token for nexe_file. 68 // nexe_token: A cache validation token for nexe_file.
69 // prefetched_resource_files_info: An array of resource files prefetched. 69 // prefetched_resource_files_info: An array of resource files prefetched.
70 // permissions: PPAPI permissions, to control access to private APIs. 70 // permissions: PPAPI permissions, to control access to private APIs.
71 // render_view_id: RenderView routing id, to control access to private APIs. 71 // render_view_id: RenderView routing id, to control access to private APIs.
72 // permission_bits: controls which interfaces the NaCl plugin can use. 72 // permission_bits: controls which interfaces the NaCl plugin can use.
73 // uses_nonsfi_mode: whether the program should be loaded under non-SFI mode. 73 // uses_nonsfi_mode: whether the program should be loaded under non-SFI mode.
74 // off_the_record: was the process launched from an incognito renderer? 74 // off_the_record: was the process launched from an incognito renderer?
75 // process_type: the type of NaCl process. 75 // process_type: the type of NaCl process.
76 // profile_directory: is the path of current profile directory. 76 // profile_directory: is the path of current profile directory.
77 NaClProcessHost( 77 NaClProcessHost(
78 const GURL& manifest_url, 78 const GURL& manifest_url,
79 base::File nexe_file, 79 base::File nexe_file,
80 const NaClFileToken& nexe_token, 80 const NaClFileToken& nexe_token,
81 const std::vector<NaClResourcePrefetchResult>& prefetched_resource_files, 81 const std::vector<NaClResourcePrefetchResult>& prefetched_resource_files,
82 ppapi::PpapiPermissions permissions, 82 ppapi::PpapiPermissions permissions,
83 int render_process_id,
83 int render_view_id, 84 int render_view_id,
84 uint32_t permission_bits, 85 uint32_t permission_bits,
85 bool uses_nonsfi_mode, 86 bool uses_nonsfi_mode,
86 bool off_the_record, 87 bool off_the_record,
87 NaClAppProcessType process_type, 88 NaClAppProcessType process_type,
88 const base::FilePath& profile_directory); 89 const base::FilePath& profile_directory);
89 ~NaClProcessHost() override; 90 ~NaClProcessHost() override;
90 91
91 void OnProcessCrashed(int exit_status) override; 92 void OnProcessCrashed(int exit_status) override;
92 93
93 // Do any minimal work that must be done at browser startup. 94 // Do any minimal work that must be done at browser startup.
94 static void EarlyStartup(); 95 static void EarlyStartup();
95 96
96 #if defined(OS_POSIX) && !defined(OS_MACOSX) 97 #if defined(OS_POSIX) && !defined(OS_MACOSX)
97 // Launch the NaCl zygote early in the browser startup. 98 // Launch the NaCl zygote early in the browser startup.
98 static void EarlyZygoteLaunch(); 99 static void EarlyZygoteLaunch();
99 #endif // defined(OS_POSIX) && !defined(OS_MACOSX) 100 #endif // defined(OS_POSIX) && !defined(OS_MACOSX)
100 101
101 // Specifies throttling time in milliseconds for PpapiHostMsg_Keepalive IPCs. 102 // Specifies throttling time in milliseconds for PpapiHostMsg_Keepalive IPCs.
102 static void SetPpapiKeepAliveThrottleForTesting(unsigned milliseconds); 103 static void SetPpapiKeepAliveThrottleForTesting(unsigned milliseconds);
103 104
104 // Initialize the new NaCl process. Result is returned by sending ipc 105 // Initialize the new NaCl process. Result is returned via |callback|.
105 // message reply_msg. 106 void Launch(const base::FilePath& manifest_path,
106 void Launch(NaClHostMessageFilter* nacl_host_message_filter, 107 const mojom::NaClHost::LaunchNaClCallback& callback);
107 IPC::Message* reply_msg,
108 const base::FilePath& manifest_path);
109 108
110 void OnChannelConnected(int32_t peer_pid) override; 109 void OnChannelConnected(int32_t peer_pid) override;
111 110
112 #if defined(OS_WIN) 111 #if defined(OS_WIN)
113 void OnProcessLaunchedByBroker(base::ProcessHandle handle); 112 void OnProcessLaunchedByBroker(base::ProcessHandle handle);
114 void OnDebugExceptionHandlerLaunchedByBroker(bool success); 113 void OnDebugExceptionHandlerLaunchedByBroker(bool success);
115 #endif 114 #endif
116 115
117 bool Send(IPC::Message* msg); 116 bool Send(IPC::Message* msg);
118 117
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 void ReplyToRenderer( 150 void ReplyToRenderer(
152 mojo::ScopedMessagePipeHandle ppapi_channel_handle, 151 mojo::ScopedMessagePipeHandle ppapi_channel_handle,
153 mojo::ScopedMessagePipeHandle trusted_channel_handle, 152 mojo::ScopedMessagePipeHandle trusted_channel_handle,
154 mojo::ScopedMessagePipeHandle manifest_service_channel_handle); 153 mojo::ScopedMessagePipeHandle manifest_service_channel_handle);
155 154
156 // Sends the reply with error message to the renderer. 155 // Sends the reply with error message to the renderer.
157 void SendErrorToRenderer(const std::string& error_message); 156 void SendErrorToRenderer(const std::string& error_message);
158 157
159 // Sends the reply message to the renderer. Either result or 158 // Sends the reply message to the renderer. Either result or
160 // error message must be empty. 159 // error message must be empty.
161 void SendMessageToRenderer(const NaClLaunchResult& result, 160 void SendMessageToRenderer(mojom::NaClLaunchResultPtr result,
162 const std::string& error_message); 161 const std::string& error_message);
163 162
164 // Sends the message to the NaCl process to load the plugin. Returns true 163 // Sends the message to the NaCl process to load the plugin. Returns true
165 // on success. 164 // on success.
166 bool StartNaClExecution(); 165 bool StartNaClExecution();
167 166
168 void StartNaClFileResolved( 167 void StartNaClFileResolved(
169 NaClStartParams params, 168 NaClStartParams params,
170 const base::FilePath& file_path, 169 const base::FilePath& file_path,
171 base::File nexe_file); 170 base::File nexe_file);
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 NaClFileToken nexe_token_; 207 NaClFileToken nexe_token_;
209 std::vector<NaClResourcePrefetchResult> prefetched_resource_files_; 208 std::vector<NaClResourcePrefetchResult> prefetched_resource_files_;
210 209
211 ppapi::PpapiPermissions permissions_; 210 ppapi::PpapiPermissions permissions_;
212 211
213 #if defined(OS_WIN) 212 #if defined(OS_WIN)
214 // This field becomes true when the broker successfully launched 213 // This field becomes true when the broker successfully launched
215 // the NaCl loader. 214 // the NaCl loader.
216 bool process_launched_by_broker_; 215 bool process_launched_by_broker_;
217 #endif 216 #endif
218 // The NaClHostMessageFilter that requested this NaCl process. We use
219 // this for sending the reply once the process has started.
220 scoped_refptr<NaClHostMessageFilter> nacl_host_message_filter_;
221 217
222 // The reply message to send. We must always send this message when the 218 // The result callback. We must always call this callback when the sub-process
223 // sub-process either succeeds or fails to unblock the renderer waiting for 219 // either succeeds or fails to unblock the renderer waiting for the reply.
224 // the reply. NULL when there is no reply to send. 220 mojom::NaClHost::LaunchNaClCallback launch_callback_;
225 IPC::Message* reply_msg_;
226 #if defined(OS_WIN) 221 #if defined(OS_WIN)
227 bool debug_exception_handler_requested_; 222 bool debug_exception_handler_requested_;
228 std::unique_ptr<IPC::Message> attach_debug_exception_handler_reply_msg_; 223 std::unique_ptr<IPC::Message> attach_debug_exception_handler_reply_msg_;
229 #endif 224 #endif
230 225
231 // The file path to the manifest is passed to nacl-gdb when it is used to 226 // The file path to the manifest is passed to nacl-gdb when it is used to
232 // debug the NaCl loader. 227 // debug the NaCl loader.
233 base::FilePath manifest_path_; 228 base::FilePath manifest_path_;
234 229
235 std::unique_ptr<content::BrowserChildProcessHost> process_; 230 std::unique_ptr<content::BrowserChildProcessHost> process_;
236 231
237 bool uses_nonsfi_mode_; 232 bool uses_nonsfi_mode_;
238 233
239 bool enable_debug_stub_; 234 bool enable_debug_stub_;
240 bool enable_crash_throttling_; 235 bool enable_crash_throttling_;
241 bool off_the_record_; 236 const bool off_the_record_;
242 NaClAppProcessType process_type_; 237 const NaClAppProcessType process_type_;
243 238
244 const base::FilePath profile_directory_; 239 const base::FilePath profile_directory_;
245 240
246 // Channel proxy to terminate the NaCl-Browser PPAPI channel. 241 // Channel proxy to terminate the NaCl-Browser PPAPI channel.
247 std::unique_ptr<IPC::ChannelProxy> ipc_proxy_channel_; 242 std::unique_ptr<IPC::ChannelProxy> ipc_proxy_channel_;
248 // Browser host for plugin process. 243 // Browser host for plugin process.
249 std::unique_ptr<content::BrowserPpapiHost> ppapi_host_; 244 std::unique_ptr<content::BrowserPpapiHost> ppapi_host_;
250 245
251 int render_view_id_; 246 const int render_process_id_;
247 const int render_view_id_;
252 248
253 // Throttling time in milliseconds for PpapiHostMsg_Keepalive IPCs. 249 // Throttling time in milliseconds for PpapiHostMsg_Keepalive IPCs.
254 static unsigned keepalive_throttle_interval_milliseconds_; 250 static unsigned keepalive_throttle_interval_milliseconds_;
255 251
256 // Shared memory provided to the plugin and renderer for 252 // Shared memory provided to the plugin and renderer for
257 // reporting crash information. 253 // reporting crash information.
258 base::SharedMemory crash_info_shmem_; 254 base::SharedMemory crash_info_shmem_;
259 255
260 base::WeakPtrFactory<NaClProcessHost> weak_factory_; 256 base::WeakPtrFactory<NaClProcessHost> weak_factory_;
261 257
262 DISALLOW_COPY_AND_ASSIGN(NaClProcessHost); 258 DISALLOW_COPY_AND_ASSIGN(NaClProcessHost);
263 }; 259 };
264 260
265 } // namespace nacl 261 } // namespace nacl
266 262
267 #endif // COMPONENTS_NACL_BROWSER_NACL_PROCESS_HOST_H_ 263 #endif // COMPONENTS_NACL_BROWSER_NACL_PROCESS_HOST_H_
OLDNEW
« no previous file with comments | « components/nacl/browser/nacl_host_message_filter.cc ('k') | components/nacl/browser/nacl_process_host.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698