| 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" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 class UtilityProcessHostClient; | 22 class UtilityProcessHostClient; |
| 23 struct ChildProcessData; | 23 struct ChildProcessData; |
| 24 | 24 |
| 25 // This class acts as the browser-side host to a utility child process. A | 25 // 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 | 26 // utility process is a short-lived process that is created to run a specific |
| 27 // task. This class lives solely on the IO thread. | 27 // task. This class lives solely on the IO thread. |
| 28 // If you need a single method call in the process, use StartFooBar(p). | 28 // 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 | 29 // 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 | 30 // StartBatchMode(), then multiple calls to StartFooBar(p), then finish with |
| 31 // EndBatchMode(). | 31 // EndBatchMode(). |
| 32 // If you need to call Mojo services, use StartMojoMode() to start the child | 32 // If you need to call Mojo services, use Start() to start the child |
| 33 // process and GetServiceRegistry() to get the service registry to connect to | 33 // process and GetServiceRegistry() to get the service registry to connect to |
| 34 // the child's Mojo services. | 34 // the child's Mojo services. |
| 35 // | 35 // |
| 36 // Note: If your class keeps a ptr to an object of this type, grab a weak ptr to | 36 // 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 | 37 // avoid a use after free since this object is deleted synchronously but the |
| 38 // client notification is asynchronous. See http://crbug.com/108871. | 38 // client notification is asynchronous. See http://crbug.com/108871. |
| 39 class UtilityProcessHost : public IPC::Sender { | 39 class UtilityProcessHost : public IPC::Sender { |
| 40 public: | 40 public: |
| 41 // Used to create a utility process. |client| is optional. If supplied it will | 41 // Used to create a utility process. |client| is optional. If supplied it will |
| 42 // be notified of incoming messages from the utility process. | 42 // be notified of incoming messages from the utility process. |
| (...skipping 26 matching lines...) Expand all Loading... |
| 69 virtual void ElevatePrivileges() = 0; | 69 virtual void ElevatePrivileges() = 0; |
| 70 #endif | 70 #endif |
| 71 | 71 |
| 72 // Returns information about the utility child process. | 72 // Returns information about the utility child process. |
| 73 virtual const ChildProcessData& GetData() = 0; | 73 virtual const ChildProcessData& GetData() = 0; |
| 74 | 74 |
| 75 #if defined(OS_POSIX) | 75 #if defined(OS_POSIX) |
| 76 virtual void SetEnv(const base::EnvironmentMap& env) = 0; | 76 virtual void SetEnv(const base::EnvironmentMap& env) = 0; |
| 77 #endif | 77 #endif |
| 78 | 78 |
| 79 // Starts the utility process in Mojo mode. | 79 // Starts the utility process. |
| 80 virtual bool StartMojoMode() = 0; | 80 virtual bool Start() = 0; |
| 81 | 81 |
| 82 // Returns the ServiceRegistry for this process. Will return nullptr if | 82 // Returns the ServiceRegistry for this process. Will never return nullptr. |
| 83 // the process was not started with StartMojoMode(). | |
| 84 virtual ServiceRegistry* GetServiceRegistry() = 0; | 83 virtual ServiceRegistry* GetServiceRegistry() = 0; |
| 85 | 84 |
| 86 // Set the name of the process to appear in the task manager. | 85 // Set the name of the process to appear in the task manager. |
| 87 virtual void SetName(const base::string16& name) = 0; | 86 virtual void SetName(const base::string16& name) = 0; |
| 88 }; | 87 }; |
| 89 | 88 |
| 90 }; // namespace content | 89 }; // namespace content |
| 91 | 90 |
| 92 #endif // CONTENT_PUBLIC_BROWSER_UTILITY_PROCESS_HOST_H_ | 91 #endif // CONTENT_PUBLIC_BROWSER_UTILITY_PROCESS_HOST_H_ |
| OLD | NEW |