Index: content/browser/utility_process_host_impl.h |
=================================================================== |
--- content/browser/utility_process_host_impl.h (revision 120256) |
+++ content/browser/utility_process_host_impl.h (working copy) |
@@ -10,80 +10,34 @@ |
#include <vector> |
#include "base/basictypes.h" |
+#include "base/compiler_specific.h" |
#include "base/memory/ref_counted.h" |
-#include "base/process_util.h" |
#include "base/memory/weak_ptr.h" |
-#include "content/common/content_export.h" |
#include "content/public/browser/browser_child_process_host_delegate.h" |
-#include "content/public/browser/browser_thread.h" |
-#include "ipc/ipc_message.h" |
+#include "content/public/browser/utility_process_host.h" |
class BrowserChildProcessHostImpl; |
-// This class acts as the browser-side host to a utility child process. A |
-// utility process is a short-lived sandboxed process that is created to run |
-// a specific task. This class lives solely on the IO thread. |
-// If you need a single method call in the sandbox, use StartFooBar(p). |
-// If you need multiple batches of work to be done in the sandboxed process, |
-// use StartBatchMode(), then multiple calls to StartFooBar(p), |
-// then finish with EndBatchMode(). |
-// |
-// Note: If your class keeps a ptr to an object of this type, grab a weak ptr to |
-// avoid a use after free. See http://crbug.com/108871. |
-class CONTENT_EXPORT UtilityProcessHost |
- : public content::BrowserChildProcessHostDelegate, |
- public IPC::Message::Sender, |
- public base::SupportsWeakPtr<UtilityProcessHost> { |
+class CONTENT_EXPORT UtilityProcessHostImpl |
+ : public NON_EXPORTED_BASE(content::UtilityProcessHost), |
+ public content::BrowserChildProcessHostDelegate { |
public: |
- // An interface to be implemented by consumers of the utility process to |
- // get results back. All functions are called on the thread passed along |
- // to UtilityProcessHost. |
- class CONTENT_EXPORT Client : public base::RefCountedThreadSafe<Client> { |
- public: |
- Client(); |
+ UtilityProcessHostImpl(content::UtilityProcessHostClient* client, |
+ content::BrowserThread::ID client_thread_id); |
+ virtual ~UtilityProcessHostImpl(); |
- // Called when the process has crashed. |
- virtual void OnProcessCrashed(int exit_code); |
- |
- // Allow the client to filter IPC messages. |
- virtual bool OnMessageReceived(const IPC::Message& message); |
- |
- protected: |
- friend class base::RefCountedThreadSafe<Client>; |
- |
- virtual ~Client(); |
- |
- private: |
- friend class UtilityProcessHost; |
- |
- DISALLOW_COPY_AND_ASSIGN(Client); |
- }; |
- |
- UtilityProcessHost(Client* client, |
- content::BrowserThread::ID client_thread_id); |
- virtual ~UtilityProcessHost(); |
- |
- // IPC::Message::Sender implementation: |
+ // UtilityProcessHost implementation: |
virtual bool Send(IPC::Message* message) OVERRIDE; |
- |
- // Starts utility process in batch mode. Caller must call EndBatchMode() |
- // to finish the utility process. |
- bool StartBatchMode(); |
- |
- // Ends the utility process. Must be called after StartBatchMode(). |
- void EndBatchMode(); |
- |
- void set_exposed_dir(const FilePath& dir) { exposed_dir_ = dir; } |
- void set_no_sandbox(bool flag) { no_sandbox_ = flag; } |
- void set_child_flags(int flags) { child_flags_ = flags; } |
- void set_use_linux_zygote(bool flag) { use_linux_zygote_ = flag; } |
+ virtual bool StartBatchMode() OVERRIDE; |
+ virtual void EndBatchMode() OVERRIDE; |
+ virtual void SetExposedDir(const FilePath& dir) OVERRIDE; |
+ virtual void DisableSandbox() OVERRIDE; |
+ virtual void EnableZygote() OVERRIDE; |
#if defined(OS_POSIX) |
- void set_env(const base::environment_vector& env) { env_ = env; } |
+ virtual void SetEnv(const base::environment_vector& env) OVERRIDE; |
#endif |
- protected: |
- // Allow these methods to be overridden for tests. |
- virtual FilePath GetUtilityProcessCmd(); |
+ void set_child_flags(int flags) { child_flags_ = flags; } |
private: |
// Starts a process if necessary. Returns true if it succeeded or a process |
@@ -95,14 +49,12 @@ |
virtual void OnProcessCrashed(int exit_code) OVERRIDE; |
// A pointer to our client interface, who will be informed of progress. |
- scoped_refptr<Client> client_; |
+ scoped_refptr<content::UtilityProcessHostClient> client_; |
content::BrowserThread::ID client_thread_id_; |
// True when running in batch mode, i.e., StartBatchMode() has been called |
// and the utility process will run until EndBatchMode(). |
bool is_batch_mode_; |
- // Allows a directory to be opened through the sandbox, in case it's needed by |
- // the operation. |
FilePath exposed_dir_; |
// Whether to pass switches::kNoSandbox to the child. |
@@ -111,9 +63,7 @@ |
// Flags defined in ChildProcessHost with which to start the process. |
int child_flags_; |
- // If the |no_sandbox_| flag is off, and we are on Linux, launch the |
- // utility process from the zygote. Defaults to false. |
- // Can only be used for tasks that do not require FS access. |
+ // Launch the utility process from the zygote. Defaults to false. |
bool use_linux_zygote_; |
base::environment_vector env_; |
@@ -122,7 +72,7 @@ |
scoped_ptr<BrowserChildProcessHostImpl> process_; |
- DISALLOW_COPY_AND_ASSIGN(UtilityProcessHost); |
+ DISALLOW_COPY_AND_ASSIGN(UtilityProcessHostImpl); |
}; |
#endif // CONTENT_BROWSER_UTILITY_PROCESS_HOST_H_ |