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

Side by Side Diff: chrome/browser/nacl_host/nacl_process_host.h

Issue 9150017: Add a Content API around BrowserChildProcessHost, similar to what was done with ChildProcessHost.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: fix?! Created 8 years, 11 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/file_path.h" 11 #include "base/file_path.h"
12 #include "base/file_util_proxy.h" 12 #include "base/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/process.h"
15 #include "chrome/common/nacl_types.h" 16 #include "chrome/common/nacl_types.h"
16 #include "content/browser/browser_child_process_host.h" 17 #include "content/public/browser/browser_child_process_host_delegate.h"
17 18
18 class ChromeRenderMessageFilter; 19 class ChromeRenderMessageFilter;
19 20
21 namespace content {
22 class BrowserChildProcessHost;
23 }
24
20 // Represents the browser side of the browser <--> NaCl communication 25 // Represents the browser side of the browser <--> NaCl communication
21 // channel. There will be one NaClProcessHost per NaCl process 26 // channel. There will be one NaClProcessHost per NaCl process
22 // The browser is responsible for starting the NaCl process 27 // The browser is responsible for starting the NaCl process
23 // when requested by the renderer. 28 // when requested by the renderer.
24 // After that, most of the communication is directly between NaCl plugin 29 // After that, most of the communication is directly between NaCl plugin
25 // running in the renderer and NaCl processes. 30 // running in the renderer and NaCl processes.
26 class NaClProcessHost : public BrowserChildProcessHost { 31 class NaClProcessHost : public content::BrowserChildProcessHostDelegate {
27 public: 32 public:
28 explicit NaClProcessHost(const std::wstring& url); 33 explicit NaClProcessHost(const std::wstring& url);
29 virtual ~NaClProcessHost(); 34 virtual ~NaClProcessHost();
30 35
31 // Do any minimal work that must be done at browser startup. 36 // Do any minimal work that must be done at browser startup.
32 static void EarlyStartup(); 37 static void EarlyStartup();
33 38
34 // Initialize the new NaCl process, returning true on success. On success, 39 // Initialize the new NaCl process, returning true on success. On success,
35 // the NaCl process host will assume responsibility for sending the reply 40 // the NaCl process host will assume responsibility for sending the reply
36 // message. On failure, the reply will not be sent and this is the caller's 41 // message. On failure, the reply will not be sent and this is the caller's
37 // responsibility to avoid hanging the renderer. 42 // responsibility to avoid hanging the renderer.
38 bool Launch(ChromeRenderMessageFilter* chrome_render_message_filter, 43 bool Launch(ChromeRenderMessageFilter* chrome_render_message_filter,
39 int socket_count, 44 int socket_count,
40 IPC::Message* reply_msg); 45 IPC::Message* reply_msg);
41 46
42 // BrowserChildProcessHost implementation:
43 virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE;
44 virtual void OnProcessCrashed(int exit_code) OVERRIDE;
45
46 void OnProcessLaunchedByBroker(base::ProcessHandle handle); 47 void OnProcessLaunchedByBroker(base::ProcessHandle handle);
47 48
48 private: 49 private:
49 // Internal class that holds the nacl::Handle objecs so that 50 // Internal class that holds the nacl::Handle objecs so that
50 // nacl_process_host.h doesn't include NaCl headers. Needed since it's 51 // nacl_process_host.h doesn't include NaCl headers. Needed since it's
51 // included by src\content, which can't depend on the NaCl gyp file because it 52 // included by src\content, which can't depend on the NaCl gyp file because it
52 // depends on chrome.gyp (circular dependency). 53 // depends on chrome.gyp (circular dependency).
53 struct NaClInternal; 54 struct NaClInternal;
54 55
55 bool LaunchSelLdr(); 56 bool LaunchSelLdr();
56 57
58 // BrowserChildProcessHostDelegate implementation:
59 virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE;
60 virtual void OnProcessCrashed(int exit_code) OVERRIDE;
57 virtual void OnProcessLaunched() OVERRIDE; 61 virtual void OnProcessLaunched() OVERRIDE;
58 62
59 void IrtReady(); 63 void IrtReady();
60 void SendStart(base::PlatformFile irt_file); 64 void SendStart(base::PlatformFile irt_file);
61 65
62 private: 66 private:
63 // The ChromeRenderMessageFilter that requested this NaCl process. We use 67 // The ChromeRenderMessageFilter that requested this NaCl process. We use
64 // this for sending the reply once the process has started. 68 // this for sending the reply once the process has started.
65 scoped_refptr<ChromeRenderMessageFilter> chrome_render_message_filter_; 69 scoped_refptr<ChromeRenderMessageFilter> chrome_render_message_filter_;
66 70
67 // The reply message to send. We must always send this message when the 71 // The reply message to send. We must always send this message when the
68 // sub-process either succeeds or fails to unblock the renderer waiting for 72 // sub-process either succeeds or fails to unblock the renderer waiting for
69 // the reply. NULL when there is no reply to send. 73 // the reply. NULL when there is no reply to send.
70 IPC::Message* reply_msg_; 74 IPC::Message* reply_msg_;
71 75
72 // Socket pairs for the NaCl process and renderer. 76 // Socket pairs for the NaCl process and renderer.
73 scoped_ptr<NaClInternal> internal_; 77 scoped_ptr<NaClInternal> internal_;
74 78
75 base::WeakPtrFactory<NaClProcessHost> weak_factory_; 79 base::WeakPtrFactory<NaClProcessHost> weak_factory_;
76 80
81 scoped_ptr<content::BrowserChildProcessHost> process_;
82
77 DISALLOW_COPY_AND_ASSIGN(NaClProcessHost); 83 DISALLOW_COPY_AND_ASSIGN(NaClProcessHost);
78 }; 84 };
79 85
80 #endif // CHROME_BROWSER_NACL_HOST_NACL_PROCESS_HOST_H_ 86 #endif // CHROME_BROWSER_NACL_HOST_NACL_PROCESS_HOST_H_
OLDNEW
« no previous file with comments | « chrome/browser/nacl_host/nacl_broker_service_win.cc ('k') | chrome/browser/nacl_host/nacl_process_host.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698