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_PUBLIC_BROWSER_UTILITY_PROCESS_HOST_H_ | 5 #ifndef CONTENT_PUBLIC_BROWSER_UTILITY_PROCESS_HOST_H_ |
6 #define CONTENT_PUBLIC_BROWSER_UTILITY_PROCESS_HOST_H_ | 6 #define CONTENT_PUBLIC_BROWSER_UTILITY_PROCESS_HOST_H_ |
7 | 7 |
8 #include "base/environment.h" | 8 #include "base/environment.h" |
9 #include "base/process/launch.h" | 9 #include "base/process/launch.h" |
10 #include "base/threading/thread.h" | 10 #include "base/threading/thread.h" |
11 #include "build/build_config.h" | 11 #include "build/build_config.h" |
12 #include "content/common/content_export.h" | 12 #include "content/common/content_export.h" |
13 #include "ipc/ipc_sender.h" | 13 #include "ipc/ipc_sender.h" |
14 | 14 |
15 namespace base { | 15 namespace base { |
16 class FilePath; | 16 class FilePath; |
17 class SequencedTaskRunner; | 17 class SequencedTaskRunner; |
18 } | 18 } |
19 | 19 |
| 20 namespace shell { |
| 21 class InterfaceProvider; |
| 22 class InterfaceRegistry; |
| 23 } |
| 24 |
20 namespace content { | 25 namespace content { |
21 class ServiceRegistry; | 26 class ServiceRegistry; |
22 class UtilityProcessHostClient; | 27 class UtilityProcessHostClient; |
23 struct ChildProcessData; | 28 struct ChildProcessData; |
24 | 29 |
25 // This class acts as the browser-side host to a utility child process. A | 30 // This class acts as the browser-side host to a utility child process. A |
26 // utility process is a short-lived process that is created to run a specific | 31 // utility process is a short-lived process that is created to run a specific |
27 // task. This class lives solely on the IO thread. | 32 // task. This class lives solely on the IO thread. |
28 // If you need a single method call in the process, use StartFooBar(p). | 33 // If you need a single method call in the process, use StartFooBar(p). |
29 // If you need multiple batches of work to be done in the process, use | 34 // If you need multiple batches of work to be done in the process, use |
30 // StartBatchMode(), then multiple calls to StartFooBar(p), then finish with | 35 // StartBatchMode(), then multiple calls to StartFooBar(p), then finish with |
31 // EndBatchMode(). | 36 // EndBatchMode(). |
32 // If you need to call Mojo services, use Start() to start the child | 37 // If you need to bind Mojo interfaces, use Start() to start the child |
33 // process and GetServiceRegistry() to get the service registry to connect to | 38 // process and GetRemoteInterfaces() to get the shell::InterfaceProvider to |
34 // the child's Mojo services. | 39 // connect to the child's Mojo interfaces. |
35 // | 40 // |
36 // Note: If your class keeps a ptr to an object of this type, grab a weak ptr to | 41 // Note: If your class keeps a ptr to an object of this type, grab a weak ptr to |
37 // avoid a use after free since this object is deleted synchronously but the | 42 // avoid a use after free since this object is deleted synchronously but the |
38 // client notification is asynchronous. See http://crbug.com/108871. | 43 // client notification is asynchronous. See http://crbug.com/108871. |
39 class UtilityProcessHost : public IPC::Sender { | 44 class UtilityProcessHost : public IPC::Sender { |
40 public: | 45 public: |
41 // Used to create a utility process. |client| is optional. If supplied it will | 46 // Used to create a utility process. |client| is optional. If supplied it will |
42 // be notified of incoming messages from the utility process. | 47 // be notified of incoming messages from the utility process. |
43 // |client_task_runner| is required if |client| is supplied and is the task | 48 // |client_task_runner| is required if |client| is supplied and is the task |
44 // runner upon which |client| will be invoked. | 49 // runner upon which |client| will be invoked. |
(...skipping 27 matching lines...) Expand all Loading... |
72 // Returns information about the utility child process. | 77 // Returns information about the utility child process. |
73 virtual const ChildProcessData& GetData() = 0; | 78 virtual const ChildProcessData& GetData() = 0; |
74 | 79 |
75 #if defined(OS_POSIX) | 80 #if defined(OS_POSIX) |
76 virtual void SetEnv(const base::EnvironmentMap& env) = 0; | 81 virtual void SetEnv(const base::EnvironmentMap& env) = 0; |
77 #endif | 82 #endif |
78 | 83 |
79 // Starts the utility process. | 84 // Starts the utility process. |
80 virtual bool Start() = 0; | 85 virtual bool Start() = 0; |
81 | 86 |
82 // Returns the ServiceRegistry for this process. Will never return nullptr. | 87 // Returns the shell::InterfaceRegistry the browser process uses to expose |
83 virtual ServiceRegistry* GetServiceRegistry() = 0; | 88 // interfaces to the utility process. |
| 89 virtual shell::InterfaceRegistry* GetInterfaceRegistry() = 0; |
| 90 |
| 91 // Returns the shell::InterfaceProvider the browser process can use to bind |
| 92 // interfaces exposed to it from the utility process. |
| 93 virtual shell::InterfaceProvider* GetRemoteInterfaces() = 0; |
84 | 94 |
85 // Set the name of the process to appear in the task manager. | 95 // Set the name of the process to appear in the task manager. |
86 virtual void SetName(const base::string16& name) = 0; | 96 virtual void SetName(const base::string16& name) = 0; |
87 }; | 97 }; |
88 | 98 |
89 }; // namespace content | 99 }; // namespace content |
90 | 100 |
91 #endif // CONTENT_PUBLIC_BROWSER_UTILITY_PROCESS_HOST_H_ | 101 #endif // CONTENT_PUBLIC_BROWSER_UTILITY_PROCESS_HOST_H_ |
OLD | NEW |