| 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 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 | 7 | 
| 8 #include "build/build_config.h" | 8 #include "build/build_config.h" | 
| 9 | 9 | 
| 10 #include "base/file_path.h" | 10 #include "base/file_path.h" | 
| 11 #include "base/file_util_proxy.h" | 11 #include "base/file_util_proxy.h" | 
| 12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" | 
| 13 #include "base/memory/weak_ptr.h" | 13 #include "base/memory/weak_ptr.h" | 
| 14 #include "base/message_loop.h" | 14 #include "base/message_loop.h" | 
| 15 #include "base/process.h" | 15 #include "base/process.h" | 
| 16 #include "chrome/common/nacl_types.h" | 16 #include "chrome/common/nacl_types.h" | 
| 17 #include "content/public/browser/browser_child_process_host_delegate.h" | 17 #include "content/public/browser/browser_child_process_host_delegate.h" | 
| 18 #include "googleurl/src/gurl.h" | 18 #include "googleurl/src/gurl.h" | 
| 19 #include "ipc/ipc_channel_handle.h" | 19 #include "ipc/ipc_channel_handle.h" | 
| 20 | 20 | 
| 21 class ChromeRenderMessageFilter; | 21 class ChromeRenderMessageFilter; | 
| 22 class CommandLine; | 22 class CommandLine; | 
| 23 class ExtensionInfoMap; | 23 class ExtensionInfoMap; | 
| 24 | 24 | 
| 25 namespace content { | 25 namespace content { | 
| 26 class BrowserChildProcessHost; | 26 class BrowserChildProcessHost; | 
| 27 } | 27 } | 
| 28 | 28 | 
|  | 29 namespace IPC { | 
|  | 30 class ChannelProxy; | 
|  | 31 } | 
|  | 32 | 
| 29 // Represents the browser side of the browser <--> NaCl communication | 33 // Represents the browser side of the browser <--> NaCl communication | 
| 30 // channel. There will be one NaClProcessHost per NaCl process | 34 // channel. There will be one NaClProcessHost per NaCl process | 
| 31 // The browser is responsible for starting the NaCl process | 35 // The browser is responsible for starting the NaCl process | 
| 32 // when requested by the renderer. | 36 // when requested by the renderer. | 
| 33 // After that, most of the communication is directly between NaCl plugin | 37 // After that, most of the communication is directly between NaCl plugin | 
| 34 // running in the renderer and NaCl processes. | 38 // running in the renderer and NaCl processes. | 
| 35 class NaClProcessHost : public content::BrowserChildProcessHostDelegate { | 39 class NaClProcessHost : public content::BrowserChildProcessHostDelegate { | 
| 36  public: | 40  public: | 
| 37   // manifest_url: the URL of the manifest of the Native Client plugin being | 41   // manifest_url: the URL of the manifest of the Native Client plugin being | 
| 38   // executed. | 42   // executed. | 
| (...skipping 14 matching lines...) Expand all  Loading... | 
| 53   virtual void OnChannelConnected(int32 peer_pid) OVERRIDE; | 57   virtual void OnChannelConnected(int32 peer_pid) OVERRIDE; | 
| 54 | 58 | 
| 55 #if defined(OS_WIN) | 59 #if defined(OS_WIN) | 
| 56   void OnProcessLaunchedByBroker(base::ProcessHandle handle); | 60   void OnProcessLaunchedByBroker(base::ProcessHandle handle); | 
| 57   void OnDebugExceptionHandlerLaunchedByBroker(bool success); | 61   void OnDebugExceptionHandlerLaunchedByBroker(bool success); | 
| 58 #endif | 62 #endif | 
| 59 | 63 | 
| 60   bool Send(IPC::Message* msg); | 64   bool Send(IPC::Message* msg); | 
| 61 | 65 | 
| 62  private: | 66  private: | 
|  | 67   friend class PluginListener; | 
|  | 68 | 
| 63   // Internal class that holds the nacl::Handle objecs so that | 69   // Internal class that holds the nacl::Handle objecs so that | 
| 64   // nacl_process_host.h doesn't include NaCl headers.  Needed since it's | 70   // nacl_process_host.h doesn't include NaCl headers.  Needed since it's | 
| 65   // included by src\content, which can't depend on the NaCl gyp file because it | 71   // included by src\content, which can't depend on the NaCl gyp file because it | 
| 66   // depends on chrome.gyp (circular dependency). | 72   // depends on chrome.gyp (circular dependency). | 
| 67   struct NaClInternal; | 73   struct NaClInternal; | 
| 68 | 74 | 
|  | 75   // PluginListener that forwards any messages from untrusted code that aren't | 
|  | 76   // handled by the PepperMessageFilter to us. | 
|  | 77   class PluginListener : public IPC::Listener { | 
|  | 78    public: | 
|  | 79     explicit PluginListener(NaClProcessHost* host); | 
|  | 80     virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; | 
|  | 81    private: | 
|  | 82     // Non-owning pointer so we can forward messages to the host. | 
|  | 83     NaClProcessHost* host_; | 
|  | 84   }; | 
|  | 85 | 
| 69 #if defined(OS_WIN) | 86 #if defined(OS_WIN) | 
| 70   // Create command line for launching loader under nacl-gdb. | 87   // Create command line for launching loader under nacl-gdb. | 
| 71   scoped_ptr<CommandLine> GetCommandForLaunchWithGdb(const FilePath& nacl_gdb, | 88   scoped_ptr<CommandLine> GetCommandForLaunchWithGdb(const FilePath& nacl_gdb, | 
| 72                                                      CommandLine* line); | 89                                                      CommandLine* line); | 
| 73 #elif defined(OS_LINUX) | 90 #elif defined(OS_LINUX) | 
| 74   bool LaunchNaClGdb(base::ProcessId pid); | 91   bool LaunchNaClGdb(base::ProcessId pid); | 
| 75   void OnNaClGdbAttached(); | 92   void OnNaClGdbAttached(); | 
| 76 #endif | 93 #endif | 
| 77   // Get path to manifest on local disk if possible. | 94   // Get path to manifest on local disk if possible. | 
| 78   FilePath GetManifestPath(); | 95   FilePath GetManifestPath(); | 
| (...skipping 27 matching lines...) Expand all  Loading... | 
| 106   void OnQueryKnownToValidate(const std::string& signature, bool* result); | 123   void OnQueryKnownToValidate(const std::string& signature, bool* result); | 
| 107   void OnSetKnownToValidate(const std::string& signature); | 124   void OnSetKnownToValidate(const std::string& signature); | 
| 108 #if defined(OS_WIN) | 125 #if defined(OS_WIN) | 
| 109   // Message handler for Windows hardware exception handling. | 126   // Message handler for Windows hardware exception handling. | 
| 110   void OnAttachDebugExceptionHandler(const std::string& info, | 127   void OnAttachDebugExceptionHandler(const std::string& info, | 
| 111                                      IPC::Message* reply_msg); | 128                                      IPC::Message* reply_msg); | 
| 112   bool AttachDebugExceptionHandler(const std::string& info, | 129   bool AttachDebugExceptionHandler(const std::string& info, | 
| 113                                    IPC::Message* reply_msg); | 130                                    IPC::Message* reply_msg); | 
| 114 #endif | 131 #endif | 
| 115 | 132 | 
|  | 133   // Called when a PPAPI IPC channel has been created. | 
| 116   void OnPpapiChannelCreated(const IPC::ChannelHandle& channel_handle); | 134   void OnPpapiChannelCreated(const IPC::ChannelHandle& channel_handle); | 
|  | 135   // Called by PluginListener, so messages from the untrusted side of | 
|  | 136   // the IPC proxy can be handled. | 
|  | 137   bool OnUntrustedMessageForwarded(const IPC::Message& msg); | 
| 117 | 138 | 
| 118   GURL manifest_url_; | 139   GURL manifest_url_; | 
| 119 | 140 | 
| 120 #if defined(OS_WIN) | 141 #if defined(OS_WIN) | 
| 121   // This field becomes true when the broker successfully launched | 142   // This field becomes true when the broker successfully launched | 
| 122   // the NaCl loader. | 143   // the NaCl loader. | 
| 123   bool process_launched_by_broker_; | 144   bool process_launched_by_broker_; | 
| 124 #elif defined(OS_LINUX) | 145 #elif defined(OS_LINUX) | 
| 125   bool wait_for_nacl_gdb_; | 146   bool wait_for_nacl_gdb_; | 
| 126   MessageLoopForIO::FileDescriptorWatcher nacl_gdb_watcher_; | 147   MessageLoopForIO::FileDescriptorWatcher nacl_gdb_watcher_; | 
| (...skipping 25 matching lines...) Expand all  Loading... | 
| 152 | 173 | 
| 153   scoped_ptr<content::BrowserChildProcessHost> process_; | 174   scoped_ptr<content::BrowserChildProcessHost> process_; | 
| 154 | 175 | 
| 155   bool enable_exception_handling_; | 176   bool enable_exception_handling_; | 
| 156   bool enable_debug_stub_; | 177   bool enable_debug_stub_; | 
| 157 | 178 | 
| 158   bool off_the_record_; | 179   bool off_the_record_; | 
| 159 | 180 | 
| 160   bool enable_ipc_proxy_; | 181   bool enable_ipc_proxy_; | 
| 161 | 182 | 
|  | 183   // Channel proxy to terminate the NaCl-Browser PPAPI channel. | 
|  | 184   scoped_ptr<IPC::ChannelProxy> ipc_proxy_channel_; | 
|  | 185   // Plugin listener, to forward browser channel messages to us. | 
|  | 186   PluginListener ipc_plugin_listener_; | 
|  | 187 | 
| 162   DISALLOW_COPY_AND_ASSIGN(NaClProcessHost); | 188   DISALLOW_COPY_AND_ASSIGN(NaClProcessHost); | 
| 163 }; | 189 }; | 
| 164 | 190 | 
| 165 #endif  // CHROME_BROWSER_NACL_HOST_NACL_PROCESS_HOST_H_ | 191 #endif  // CHROME_BROWSER_NACL_HOST_NACL_PROCESS_HOST_H_ | 
| OLD | NEW | 
|---|