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 "content/browser/browser_child_process_host.h" | 14 #include "content/browser/browser_child_process_host.h" |
15 #include "content/browser/browser_thread.h" | 15 #include "content/browser/browser_thread.h" |
| 16 #include "content/common/content_export.h" |
16 | 17 |
17 // This class acts as the browser-side host to a utility child process. A | 18 // This class acts as the browser-side host to a utility child process. A |
18 // utility process is a short-lived sandboxed process that is created to run | 19 // utility process is a short-lived sandboxed process that is created to run |
19 // a specific task. This class lives solely on the IO thread. | 20 // a specific task. This class lives solely on the IO thread. |
20 // If you need a single method call in the sandbox, use StartFooBar(p). | 21 // If you need a single method call in the sandbox, use StartFooBar(p). |
21 // If you need multiple batches of work to be done in the sandboxed process, | 22 // If you need multiple batches of work to be done in the sandboxed process, |
22 // use StartBatchMode(), then multiple calls to StartFooBar(p), | 23 // use StartBatchMode(), then multiple calls to StartFooBar(p), |
23 // then finish with EndBatchMode(). | 24 // then finish with EndBatchMode(). |
24 class UtilityProcessHost : public BrowserChildProcessHost { | 25 class CONTENT_EXPORT UtilityProcessHost : public BrowserChildProcessHost { |
25 public: | 26 public: |
26 // An interface to be implemented by consumers of the utility process to | 27 // An interface to be implemented by consumers of the utility process to |
27 // get results back. All functions are called on the thread passed along | 28 // get results back. All functions are called on the thread passed along |
28 // to UtilityProcessHost. | 29 // to UtilityProcessHost. |
29 class Client : public base::RefCountedThreadSafe<Client> { | 30 class CONTENT_EXPORT Client : public base::RefCountedThreadSafe<Client> { |
30 public: | 31 public: |
31 Client(); | 32 Client(); |
32 | 33 |
33 // Called when the process has crashed. | 34 // Called when the process has crashed. |
34 virtual void OnProcessCrashed(int exit_code); | 35 virtual void OnProcessCrashed(int exit_code); |
35 | 36 |
36 // Allow the client to filter IPC messages. | 37 // Allow the client to filter IPC messages. |
37 virtual bool OnMessageReceived(const IPC::Message& message); | 38 virtual bool OnMessageReceived(const IPC::Message& message); |
38 | 39 |
39 protected: | 40 protected: |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 // Allows a directory to be opened through the sandbox, in case it's needed by | 89 // Allows a directory to be opened through the sandbox, in case it's needed by |
89 // the operation. | 90 // the operation. |
90 FilePath exposed_dir_; | 91 FilePath exposed_dir_; |
91 | 92 |
92 bool started_; | 93 bool started_; |
93 | 94 |
94 DISALLOW_COPY_AND_ASSIGN(UtilityProcessHost); | 95 DISALLOW_COPY_AND_ASSIGN(UtilityProcessHost); |
95 }; | 96 }; |
96 | 97 |
97 #endif // CONTENT_BROWSER_UTILITY_PROCESS_HOST_H_ | 98 #endif // CONTENT_BROWSER_UTILITY_PROCESS_HOST_H_ |
OLD | NEW |