Removed unused VideoCaptureCapability parameters.
[chromium-blink-merge.git] / content / public / browser / utility_process_host.h
blob2cff030e1f788d2a893c491ce177b97a4280824c
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_PUBLIC_BROWSER_UTILITY_PROCESS_HOST_H_
6 #define CONTENT_PUBLIC_BROWSER_UTILITY_PROCESS_HOST_H_
8 #include "base/environment.h"
9 #include "base/process/launch.h"
10 #include "base/threading/thread.h"
11 #include "content/common/content_export.h"
12 #include "ipc/ipc_sender.h"
14 namespace base {
15 class FilePath;
16 class SequencedTaskRunner;
19 namespace content {
20 class UtilityProcessHostClient;
21 struct ChildProcessData;
23 typedef base::Thread* (*UtilityMainThreadFactoryFunction)(
24 const std::string& id);
26 // This class acts as the browser-side host to a utility child process. A
27 // utility process is a short-lived process that is created to run a specific
28 // task. This class lives solely on the IO thread.
29 // If you need a single method call in the process, use StartFooBar(p).
30 // If you need multiple batches of work to be done in the process, use
31 // StartBatchMode(), then multiple calls to StartFooBar(p), then finish with
32 // EndBatchMode().
34 // Note: If your class keeps a ptr to an object of this type, grab a weak ptr to
35 // avoid a use after free since this object is deleted synchronously but the
36 // client notification is asynchronous. See http://crbug.com/108871.
37 class UtilityProcessHost : public IPC::Sender,
38 public base::SupportsWeakPtr<UtilityProcessHost> {
39 public:
40 // Used to create a utility process.
41 CONTENT_EXPORT static UtilityProcessHost* Create(
42 UtilityProcessHostClient* client,
43 base::SequencedTaskRunner* client_task_runner);
45 virtual ~UtilityProcessHost() {}
47 // Starts utility process in batch mode. Caller must call EndBatchMode()
48 // to finish the utility process.
49 virtual bool StartBatchMode() = 0;
51 // Ends the utility process. Must be called after StartBatchMode().
52 virtual void EndBatchMode() = 0;
54 // Allows a directory to be opened through the sandbox, in case it's needed by
55 // the operation.
56 virtual void SetExposedDir(const base::FilePath& dir) = 0;
58 // Allows a mdns to use network in sandbox.
59 virtual void EnableMDns() = 0;
61 // Make the process run without a sandbox.
62 virtual void DisableSandbox() = 0;
64 // If the sandbox is being used and we are on Linux, launch the process from
65 // the zygote. Can only be used for tasks that do not require FS access.
66 virtual void EnableZygote() = 0;
68 // Returns information about the utility child process.
69 virtual const ChildProcessData& GetData() = 0;
71 #if defined(OS_POSIX)
72 virtual void SetEnv(const base::EnvironmentMap& env) = 0;
73 #endif
75 CONTENT_EXPORT static void RegisterUtilityMainThreadFactory(
76 UtilityMainThreadFactoryFunction create);
79 }; // namespace content
81 #endif // CONTENT_PUBLIC_BROWSER_UTILITY_PROCESS_HOST_H_