| 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 CONTENT_BROWSER_UTILITY_PROCESS_HOST_IMPL_H_ | 5 #ifndef CONTENT_BROWSER_UTILITY_PROCESS_HOST_IMPL_H_ |
| 6 #define CONTENT_BROWSER_UTILITY_PROCESS_HOST_IMPL_H_ | 6 #define CONTENT_BROWSER_UTILITY_PROCESS_HOST_IMPL_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
| 12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.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 "content/public/browser/browser_child_process_host_delegate.h" | 15 #include "content/public/browser/browser_child_process_host_delegate.h" |
| 16 #include "content/public/browser/utility_process_host.h" | 16 #include "content/public/browser/utility_process_host.h" |
| 17 | 17 |
| 18 namespace content { |
| 18 class BrowserChildProcessHostImpl; | 19 class BrowserChildProcessHostImpl; |
| 19 | 20 |
| 20 class CONTENT_EXPORT UtilityProcessHostImpl | 21 class CONTENT_EXPORT UtilityProcessHostImpl |
| 21 : public NON_EXPORTED_BASE(content::UtilityProcessHost), | 22 : public NON_EXPORTED_BASE(UtilityProcessHost), |
| 22 public content::BrowserChildProcessHostDelegate { | 23 public BrowserChildProcessHostDelegate { |
| 23 public: | 24 public: |
| 24 UtilityProcessHostImpl(content::UtilityProcessHostClient* client, | 25 UtilityProcessHostImpl(UtilityProcessHostClient* client, |
| 25 content::BrowserThread::ID client_thread_id); | 26 BrowserThread::ID client_thread_id); |
| 26 virtual ~UtilityProcessHostImpl(); | 27 virtual ~UtilityProcessHostImpl(); |
| 27 | 28 |
| 28 // UtilityProcessHost implementation: | 29 // UtilityProcessHost implementation: |
| 29 virtual bool Send(IPC::Message* message) OVERRIDE; | 30 virtual bool Send(IPC::Message* message) OVERRIDE; |
| 30 virtual bool StartBatchMode() OVERRIDE; | 31 virtual bool StartBatchMode() OVERRIDE; |
| 31 virtual void EndBatchMode() OVERRIDE; | 32 virtual void EndBatchMode() OVERRIDE; |
| 32 virtual void SetExposedDir(const FilePath& dir) OVERRIDE; | 33 virtual void SetExposedDir(const FilePath& dir) OVERRIDE; |
| 33 virtual void DisableSandbox() OVERRIDE; | 34 virtual void DisableSandbox() OVERRIDE; |
| 34 virtual void EnableZygote() OVERRIDE; | 35 virtual void EnableZygote() OVERRIDE; |
| 35 #if defined(OS_POSIX) | 36 #if defined(OS_POSIX) |
| 36 virtual void SetEnv(const base::EnvironmentVector& env) OVERRIDE; | 37 virtual void SetEnv(const base::EnvironmentVector& env) OVERRIDE; |
| 37 #endif | 38 #endif |
| 38 | 39 |
| 39 void set_child_flags(int flags) { child_flags_ = flags; } | 40 void set_child_flags(int flags) { child_flags_ = flags; } |
| 40 | 41 |
| 41 private: | 42 private: |
| 42 // Starts a process if necessary. Returns true if it succeeded or a process | 43 // Starts a process if necessary. Returns true if it succeeded or a process |
| 43 // has already been started via StartBatchMode(). | 44 // has already been started via StartBatchMode(). |
| 44 bool StartProcess(); | 45 bool StartProcess(); |
| 45 | 46 |
| 46 // BrowserChildProcessHost: | 47 // BrowserChildProcessHost: |
| 47 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; | 48 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; |
| 48 virtual void OnProcessCrashed(int exit_code) OVERRIDE; | 49 virtual void OnProcessCrashed(int exit_code) OVERRIDE; |
| 49 | 50 |
| 50 // A pointer to our client interface, who will be informed of progress. | 51 // A pointer to our client interface, who will be informed of progress. |
| 51 scoped_refptr<content::UtilityProcessHostClient> client_; | 52 scoped_refptr<UtilityProcessHostClient> client_; |
| 52 content::BrowserThread::ID client_thread_id_; | 53 BrowserThread::ID client_thread_id_; |
| 53 // True when running in batch mode, i.e., StartBatchMode() has been called | 54 // True when running in batch mode, i.e., StartBatchMode() has been called |
| 54 // and the utility process will run until EndBatchMode(). | 55 // and the utility process will run until EndBatchMode(). |
| 55 bool is_batch_mode_; | 56 bool is_batch_mode_; |
| 56 | 57 |
| 57 FilePath exposed_dir_; | 58 FilePath exposed_dir_; |
| 58 | 59 |
| 59 // Whether to pass switches::kNoSandbox to the child. | 60 // Whether to pass switches::kNoSandbox to the child. |
| 60 bool no_sandbox_; | 61 bool no_sandbox_; |
| 61 | 62 |
| 62 // Flags defined in ChildProcessHost with which to start the process. | 63 // Flags defined in ChildProcessHost with which to start the process. |
| 63 int child_flags_; | 64 int child_flags_; |
| 64 | 65 |
| 65 // Launch the utility process from the zygote. Defaults to false. | 66 // Launch the utility process from the zygote. Defaults to false. |
| 66 bool use_linux_zygote_; | 67 bool use_linux_zygote_; |
| 67 | 68 |
| 68 base::EnvironmentVector env_; | 69 base::EnvironmentVector env_; |
| 69 | 70 |
| 70 bool started_; | 71 bool started_; |
| 71 | 72 |
| 72 scoped_ptr<BrowserChildProcessHostImpl> process_; | 73 scoped_ptr<BrowserChildProcessHostImpl> process_; |
| 73 | 74 |
| 74 DISALLOW_COPY_AND_ASSIGN(UtilityProcessHostImpl); | 75 DISALLOW_COPY_AND_ASSIGN(UtilityProcessHostImpl); |
| 75 }; | 76 }; |
| 76 | 77 |
| 78 } // namespace content |
| 79 |
| 77 #endif // CONTENT_BROWSER_UTILITY_PROCESS_HOST_IMPL_H_ | 80 #endif // CONTENT_BROWSER_UTILITY_PROCESS_HOST_IMPL_H_ |
| OLD | NEW |