| 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 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "base/process_util.h" | 9 #include "base/process_util.h" |
| 10 #include "content/common/content_export.h" | 10 #include "content/common/content_export.h" |
| 11 #include "content/public/browser/browser_thread.h" | 11 #include "content/public/browser/browser_thread.h" |
| 12 #include "ipc/ipc_message.h" | 12 #include "ipc/ipc_sender.h" |
| 13 | 13 |
| 14 class FilePath; | 14 class FilePath; |
| 15 | 15 |
| 16 namespace content { | 16 namespace content { |
| 17 | 17 |
| 18 class UtilityProcessHostClient; | 18 class UtilityProcessHostClient; |
| 19 | 19 |
| 20 // This class acts as the browser-side host to a utility child process. A | 20 // This class acts as the browser-side host to a utility child process. A |
| 21 // utility process is a short-lived process that is created to run a specific | 21 // utility process is a short-lived process that is created to run a specific |
| 22 // task. This class lives solely on the IO thread. | 22 // task. This class lives solely on the IO thread. |
| 23 // If you need a single method call in the process, use StartFooBar(p). | 23 // If you need a single method call in the process, use StartFooBar(p). |
| 24 // If you need multiple batches of work to be done in the process, use | 24 // If you need multiple batches of work to be done in the process, use |
| 25 // StartBatchMode(), then multiple calls to StartFooBar(p), then finish with | 25 // StartBatchMode(), then multiple calls to StartFooBar(p), then finish with |
| 26 // EndBatchMode(). | 26 // EndBatchMode(). |
| 27 // | 27 // |
| 28 // Note: If your class keeps a ptr to an object of this type, grab a weak ptr to | 28 // Note: If your class keeps a ptr to an object of this type, grab a weak ptr to |
| 29 // avoid a use after free since this object is deleted synchronously but the | 29 // avoid a use after free since this object is deleted synchronously but the |
| 30 // client notification is asynchronous. See http://crbug.com/108871. | 30 // client notification is asynchronous. See http://crbug.com/108871. |
| 31 class UtilityProcessHost : public IPC::Message::Sender, | 31 class UtilityProcessHost : public IPC::Sender, |
| 32 public base::SupportsWeakPtr<UtilityProcessHost> { | 32 public base::SupportsWeakPtr<UtilityProcessHost> { |
| 33 public: | 33 public: |
| 34 // Used to create a utility process. | 34 // Used to create a utility process. |
| 35 CONTENT_EXPORT static UtilityProcessHost* Create( | 35 CONTENT_EXPORT static UtilityProcessHost* Create( |
| 36 UtilityProcessHostClient* client, | 36 UtilityProcessHostClient* client, |
| 37 BrowserThread::ID client_thread_id); | 37 BrowserThread::ID client_thread_id); |
| 38 | 38 |
| 39 virtual ~UtilityProcessHost() {} | 39 virtual ~UtilityProcessHost() {} |
| 40 | 40 |
| 41 // Starts utility process in batch mode. Caller must call EndBatchMode() | 41 // Starts utility process in batch mode. Caller must call EndBatchMode() |
| (...skipping 15 matching lines...) Expand all Loading... |
| 57 virtual void EnableZygote() = 0; | 57 virtual void EnableZygote() = 0; |
| 58 | 58 |
| 59 #if defined(OS_POSIX) | 59 #if defined(OS_POSIX) |
| 60 virtual void SetEnv(const base::EnvironmentVector& env) = 0; | 60 virtual void SetEnv(const base::EnvironmentVector& env) = 0; |
| 61 #endif | 61 #endif |
| 62 }; | 62 }; |
| 63 | 63 |
| 64 }; // namespace content | 64 }; // namespace content |
| 65 | 65 |
| 66 #endif // CONTENT_PUBLIC_BROWSER_UTILITY_PROCESS_HOST_H_ | 66 #endif // CONTENT_PUBLIC_BROWSER_UTILITY_PROCESS_HOST_H_ |
| OLD | NEW |