OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_BROWSER_UTILITY_PROCESS_HOST_H_ | 5 #ifndef CONTENT_BROWSER_UTILITY_PROCESS_HOST_H_ |
6 #define CONTENT_BROWSER_UTILITY_PROCESS_HOST_H_ | 6 #define CONTENT_BROWSER_UTILITY_PROCESS_HOST_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
14 #include "base/process_util.h" | 14 #include "base/process_util.h" |
15 #include "base/memory/weak_ptr.h" | |
15 #include "content/common/content_export.h" | 16 #include "content/common/content_export.h" |
16 #include "content/public/browser/browser_child_process_host_delegate.h" | 17 #include "content/public/browser/browser_child_process_host_delegate.h" |
17 #include "content/public/browser/browser_thread.h" | 18 #include "content/public/browser/browser_thread.h" |
18 #include "ipc/ipc_message.h" | 19 #include "ipc/ipc_message.h" |
19 | 20 |
20 class BrowserChildProcessHostImpl; | 21 class BrowserChildProcessHostImpl; |
21 | 22 |
22 // This class acts as the browser-side host to a utility child process. A | 23 // This class acts as the browser-side host to a utility child process. A |
23 // utility process is a short-lived sandboxed process that is created to run | 24 // utility process is a short-lived sandboxed process that is created to run |
24 // a specific task. This class lives solely on the IO thread. | 25 // a specific task. This class lives solely on the IO thread. |
25 // If you need a single method call in the sandbox, use StartFooBar(p). | 26 // If you need a single method call in the sandbox, use StartFooBar(p). |
26 // If you need multiple batches of work to be done in the sandboxed process, | 27 // If you need multiple batches of work to be done in the sandboxed process, |
27 // use StartBatchMode(), then multiple calls to StartFooBar(p), | 28 // use StartBatchMode(), then multiple calls to StartFooBar(p), |
28 // then finish with EndBatchMode(). | 29 // then finish with EndBatchMode(). |
30 // | |
31 // Note: If you keep a ptr to an object of this class that is used in a task | |
jam
2012/01/26 23:32:15
nit: i think what you want to say here is that if
| |
32 // other than the one in which it was created, grab a weak ptr to it to avoid | |
33 // a use after free. See http://crbug.com/108871. | |
29 class CONTENT_EXPORT UtilityProcessHost | 34 class CONTENT_EXPORT UtilityProcessHost |
30 : public content::BrowserChildProcessHostDelegate, | 35 : public content::BrowserChildProcessHostDelegate, |
31 public IPC::Message::Sender { | 36 public IPC::Message::Sender, |
37 public base::SupportsWeakPtr<UtilityProcessHost> { | |
32 public: | 38 public: |
33 // An interface to be implemented by consumers of the utility process to | 39 // An interface to be implemented by consumers of the utility process to |
34 // get results back. All functions are called on the thread passed along | 40 // get results back. All functions are called on the thread passed along |
35 // to UtilityProcessHost. | 41 // to UtilityProcessHost. |
36 class CONTENT_EXPORT Client : public base::RefCountedThreadSafe<Client> { | 42 class CONTENT_EXPORT Client : public base::RefCountedThreadSafe<Client> { |
37 public: | 43 public: |
38 Client(); | 44 Client(); |
39 | 45 |
40 // Called when the process has crashed. | 46 // Called when the process has crashed. |
41 virtual void OnProcessCrashed(int exit_code); | 47 virtual void OnProcessCrashed(int exit_code); |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
114 base::environment_vector env_; | 120 base::environment_vector env_; |
115 | 121 |
116 bool started_; | 122 bool started_; |
117 | 123 |
118 scoped_ptr<BrowserChildProcessHostImpl> process_; | 124 scoped_ptr<BrowserChildProcessHostImpl> process_; |
119 | 125 |
120 DISALLOW_COPY_AND_ASSIGN(UtilityProcessHost); | 126 DISALLOW_COPY_AND_ASSIGN(UtilityProcessHost); |
121 }; | 127 }; |
122 | 128 |
123 #endif // CONTENT_BROWSER_UTILITY_PROCESS_HOST_H_ | 129 #endif // CONTENT_BROWSER_UTILITY_PROCESS_HOST_H_ |
OLD | NEW |