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
3 // found in the LICENSE file.
5 #ifndef CONTENT_BROWSER_UTILITY_PROCESS_HOST_IMPL_H_
6 #define CONTENT_BROWSER_UTILITY_PROCESS_HOST_IMPL_H_
11 #include "base/basictypes.h"
12 #include "base/compiler_specific.h"
13 #include "base/memory/ref_counted.h"
14 #include "base/memory/scoped_ptr.h"
15 #include "base/memory/weak_ptr.h"
16 #include "content/public/browser/browser_child_process_host_delegate.h"
17 #include "content/public/browser/utility_process_host.h"
20 class SequencedTaskRunner
;
24 class BrowserChildProcessHostImpl
;
26 class CONTENT_EXPORT UtilityProcessHostImpl
27 : public NON_EXPORTED_BASE(UtilityProcessHost
),
28 public BrowserChildProcessHostDelegate
{
30 UtilityProcessHostImpl(UtilityProcessHostClient
* client
,
31 base::SequencedTaskRunner
* client_task_runner
);
32 virtual ~UtilityProcessHostImpl();
34 // UtilityProcessHost implementation:
35 virtual bool Send(IPC::Message
* message
) OVERRIDE
;
36 virtual bool StartBatchMode() OVERRIDE
;
37 virtual void EndBatchMode() OVERRIDE
;
38 virtual void SetExposedDir(const FilePath
& dir
) OVERRIDE
;
39 virtual void DisableSandbox() OVERRIDE
;
40 virtual void EnableZygote() OVERRIDE
;
41 virtual const ChildProcessData
& GetData() OVERRIDE
;
43 virtual void SetEnv(const base::EnvironmentVector
& env
) OVERRIDE
;
46 void set_child_flags(int flags
) { child_flags_
= flags
; }
49 // Starts a process if necessary. Returns true if it succeeded or a process
50 // has already been started via StartBatchMode().
53 // BrowserChildProcessHost:
54 virtual bool OnMessageReceived(const IPC::Message
& message
) OVERRIDE
;
55 virtual void OnProcessCrashed(int exit_code
) OVERRIDE
;
57 // A pointer to our client interface, who will be informed of progress.
58 scoped_refptr
<UtilityProcessHostClient
> client_
;
59 scoped_refptr
<base::SequencedTaskRunner
> client_task_runner_
;
60 // True when running in batch mode, i.e., StartBatchMode() has been called
61 // and the utility process will run until EndBatchMode().
64 FilePath exposed_dir_
;
66 // Whether to pass switches::kNoSandbox to the child.
69 // Flags defined in ChildProcessHost with which to start the process.
72 // Launch the utility process from the zygote. Defaults to false.
73 bool use_linux_zygote_
;
75 base::EnvironmentVector env_
;
79 scoped_ptr
<BrowserChildProcessHostImpl
> process_
;
81 DISALLOW_COPY_AND_ASSIGN(UtilityProcessHostImpl
);
84 } // namespace content
86 #endif // CONTENT_BROWSER_UTILITY_PROCESS_HOST_IMPL_H_