diff options
author | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-12-02 20:24:49 +0000 |
---|---|---|
committer | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-12-02 20:24:49 +0000 |
commit | 4cb4310995f3b92adceb1e44b792726f7fc8249c (patch) | |
tree | 1b8217ee615f97dee3e42aa5794488fb6e31f058 /chrome/service/service_utility_process_host.h | |
parent | 9d43955551544e2954c4e085c8b34c866543f38e (diff) | |
download | chromium_src-4cb4310995f3b92adceb1e44b792726f7fc8249c.zip chromium_src-4cb4310995f3b92adceb1e44b792726f7fc8249c.tar.gz chromium_src-4cb4310995f3b92adceb1e44b792726f7fc8249c.tar.bz2 |
Don't make classes derive from ChildProcessHost, and instead have them use it through composition. This cleans up the code and makes it easier to understand (as well as more closely conform to the Google C++ style guide). It also makes it possible to add an interface around ChildProcessHost in a future change.
BUG=98716
Review URL: http://codereview.chromium.org/8774040
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@112769 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/service/service_utility_process_host.h')
-rw-r--r-- | chrome/service/service_utility_process_host.h | 36 |
1 files changed, 23 insertions, 13 deletions
diff --git a/chrome/service/service_utility_process_host.h b/chrome/service/service_utility_process_host.h index 49e2450..77cb2f7 100644 --- a/chrome/service/service_utility_process_host.h +++ b/chrome/service/service_utility_process_host.h @@ -14,11 +14,15 @@ #include "base/basictypes.h" #include "base/file_path.h" #include "base/memory/ref_counted.h" +#include "base/memory/scoped_ptr.h" +#include "base/process.h" #include "base/task.h" #include "ipc/ipc_channel.h" -#include "chrome/service/service_child_process_host.h" +#include "content/public/common/child_process_host_delegate.h" #include "printing/pdf_render_settings.h" +class ChildProcessHost; +class CommandLine; class ScopedTempDir; namespace base { @@ -34,7 +38,7 @@ struct PrinterCapsAndDefaults; // Acts as the service-side host to a utility child process. A // utility process is a short-lived sandboxed process that is created to run // a specific task. -class ServiceUtilityProcessHost : public ServiceChildProcessHost { +class ServiceUtilityProcessHost : public content::ChildProcessHostDelegate { public: // Consumers of ServiceUtilityProcessHost must implement this interface to // get results back. All functions are called on the thread passed along @@ -101,9 +105,11 @@ class ServiceUtilityProcessHost : public ServiceChildProcessHost { // Allows this method to be overridden for tests. virtual FilePath GetUtilityProcessCmd(); - // ChildProcessHost implementation. + // ChildProcessHostDelegate implementation: virtual bool CanShutdown() OVERRIDE; - virtual void OnChildDied() OVERRIDE; + virtual void OnChildDisconnected() OVERRIDE; + virtual void ShutdownStarted() OVERRIDE; + virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; private: // Starts a process. Returns true iff it succeeded. |exposed_dir| is the @@ -111,22 +117,26 @@ class ServiceUtilityProcessHost : public ServiceChildProcessHost { // true. bool StartProcess(bool no_sandbox, const FilePath& exposed_dir); - // IPC messages: - virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; - // Called when at least one page in the specified PDF has been rendered - // successfully into metafile_path_; + // Launch the child process synchronously. + // TODO(sanjeevr): Determine whether we need to make the launch asynchronous. + // |exposed_dir| is the path to tbe exposed to the sandbox. This is ignored + // if |no_sandbox| is true. + bool Launch(CommandLine* cmd_line, + bool no_sandbox, + const FilePath& exposed_dir); + + base::ProcessHandle handle() const { return handle_; } + + // Messages handlers: void OnRenderPDFPagesToMetafileSucceeded(int highest_rendered_page_number); - // Called when PDF rendering failed. void OnRenderPDFPagesToMetafileFailed(); - // Called when the printer capabilities and defaults have been - // retrieved successfully. void OnGetPrinterCapsAndDefaultsSucceeded( const std::string& printer_name, const printing::PrinterCapsAndDefaults& caps_and_defaults); - // Called when the printer capabilities and defaults could not be - // retrieved successfully. void OnGetPrinterCapsAndDefaultsFailed(const std::string& printer_name); + scoped_ptr<ChildProcessHost> child_process_host_; + base::ProcessHandle handle_; // A pointer to our client interface, who will be informed of progress. scoped_refptr<Client> client_; scoped_refptr<base::MessageLoopProxy> client_message_loop_proxy_; |