OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 CHROME_BROWSER_NACL_HOST_NACL_PROCESS_HOST_H_ | 5 #ifndef CHROME_BROWSER_NACL_HOST_NACL_PROCESS_HOST_H_ |
6 #define CHROME_BROWSER_NACL_HOST_NACL_PROCESS_HOST_H_ | 6 #define CHROME_BROWSER_NACL_HOST_NACL_PROCESS_HOST_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "build/build_config.h" | 9 #include "build/build_config.h" |
10 | 10 |
11 #include "base/ref_counted.h" | 11 #include "base/ref_counted.h" |
12 #include "chrome/browser/browser_child_process_host.h" | 12 #include "chrome/browser/browser_child_process_host.h" |
13 #include "chrome/common/nacl_types.h" | 13 #include "chrome/common/nacl_types.h" |
14 #include "native_client/src/shared/imc/nacl_imc.h" | |
15 | 14 |
16 class RenderMessageFilter; | 15 class RenderMessageFilter; |
17 | 16 |
18 // Represents the browser side of the browser <--> NaCl communication | 17 // Represents the browser side of the browser <--> NaCl communication |
19 // channel. There will be one NaClProcessHost per NaCl process | 18 // channel. There will be one NaClProcessHost per NaCl process |
20 // The browser is responsible for starting the NaCl process | 19 // The browser is responsible for starting the NaCl process |
21 // when requested by the renderer. | 20 // when requested by the renderer. |
22 // After that, most of the communication is directly between NaCl plugin | 21 // After that, most of the communication is directly between NaCl plugin |
23 // running in the renderer and NaCl processes. | 22 // running in the renderer and NaCl processes. |
24 class NaClProcessHost : public BrowserChildProcessHost { | 23 class NaClProcessHost : public BrowserChildProcessHost { |
25 public: | 24 public: |
26 NaClProcessHost(ResourceDispatcherHost *resource_dispatcher_host, | 25 NaClProcessHost(ResourceDispatcherHost *resource_dispatcher_host, |
27 const std::wstring& url); | 26 const std::wstring& url); |
28 ~NaClProcessHost(); | 27 ~NaClProcessHost(); |
29 | 28 |
30 // Initialize the new NaCl process, returning true on success. | 29 // Initialize the new NaCl process, returning true on success. |
31 bool Launch(RenderMessageFilter* render_message_filter, | 30 bool Launch(RenderMessageFilter* render_message_filter, |
32 int socket_count, | 31 int socket_count, |
33 IPC::Message* reply_msg); | 32 IPC::Message* reply_msg); |
34 | 33 |
35 virtual bool OnMessageReceived(const IPC::Message& msg); | 34 virtual bool OnMessageReceived(const IPC::Message& msg); |
36 | 35 |
37 void OnProcessLaunchedByBroker(base::ProcessHandle handle); | 36 void OnProcessLaunchedByBroker(base::ProcessHandle handle); |
38 | 37 |
39 protected: | 38 protected: |
40 virtual base::TerminationStatus GetChildTerminationStatus(int* exit_code); | 39 virtual base::TerminationStatus GetChildTerminationStatus(int* exit_code); |
41 virtual void OnChildDied(); | 40 virtual void OnChildDied(); |
42 | 41 |
43 private: | 42 private: |
| 43 // Internal class that holds the nacl::Handle objecs so that |
| 44 // nacl_process_host.h doesn't include NaCl headers. Needed since it's |
| 45 // included by src\content, which can't depend on the NaCl gyp file because it |
| 46 // depends on chrome.gyp (circular dependency). |
| 47 struct NaClInternal; |
| 48 |
44 bool LaunchSelLdr(); | 49 bool LaunchSelLdr(); |
45 | 50 |
46 void SendStartMessage(); | 51 void SendStartMessage(); |
47 | 52 |
48 virtual void OnProcessLaunched(); | 53 virtual void OnProcessLaunched(); |
49 | 54 |
50 virtual bool CanShutdown(); | 55 virtual bool CanShutdown(); |
51 | 56 |
52 #if defined(OS_WIN) | 57 #if defined(OS_WIN) |
53 // Check whether the browser process is running on WOW64 - Windows only | 58 // Check whether the browser process is running on WOW64 - Windows only |
54 void CheckIsWow64(); | 59 void CheckIsWow64(); |
55 #endif | 60 #endif |
56 | 61 |
57 private: | 62 private: |
58 ResourceDispatcherHost* resource_dispatcher_host_; | 63 ResourceDispatcherHost* resource_dispatcher_host_; |
59 | 64 |
60 // The RenderMessageFilter that requested this NaCl process. We use this | 65 // The RenderMessageFilter that requested this NaCl process. We use this |
61 // for sending the reply once the process has started. | 66 // for sending the reply once the process has started. |
62 scoped_refptr<RenderMessageFilter> render_message_filter_; | 67 scoped_refptr<RenderMessageFilter> render_message_filter_; |
63 | 68 |
64 // The reply message to send. | 69 // The reply message to send. |
65 IPC::Message* reply_msg_; | 70 IPC::Message* reply_msg_; |
66 | 71 |
67 // Socket pairs for the NaCl process and renderer. | 72 // Socket pairs for the NaCl process and renderer. |
68 std::vector<nacl::Handle> sockets_for_renderer_; | 73 scoped_ptr<NaClInternal> internal_; |
69 std::vector<nacl::Handle> sockets_for_sel_ldr_; | |
70 | 74 |
71 // Windows platform flag | 75 // Windows platform flag |
72 bool running_on_wow64_; | 76 bool running_on_wow64_; |
73 | 77 |
74 DISALLOW_COPY_AND_ASSIGN(NaClProcessHost); | 78 DISALLOW_COPY_AND_ASSIGN(NaClProcessHost); |
75 }; | 79 }; |
76 | 80 |
77 #endif // CHROME_BROWSER_NACL_HOST_NACL_PROCESS_HOST_H_ | 81 #endif // CHROME_BROWSER_NACL_HOST_NACL_PROCESS_HOST_H_ |
OLD | NEW |