OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 CHROME_BROWSER_UTILITY_PROCESS_HOST_H_ | 5 #ifndef CHROME_BROWSER_UTILITY_PROCESS_HOST_H_ |
6 #define CHROME_BROWSER_UTILITY_PROCESS_HOST_H_ | 6 #define CHROME_BROWSER_UTILITY_PROCESS_HOST_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
11 #include "base/ref_counted.h" | 11 #include "base/ref_counted.h" |
12 #include "base/task.h" | 12 #include "base/task.h" |
| 13 #include "chrome/browser/chrome_thread.h" |
13 #include "chrome/common/child_process_host.h" | 14 #include "chrome/common/child_process_host.h" |
14 #include "chrome/common/extensions/update_manifest.h" | 15 #include "chrome/common/extensions/update_manifest.h" |
15 #include "ipc/ipc_channel.h" | 16 #include "ipc/ipc_channel.h" |
16 | 17 |
17 class CommandLine; | 18 class CommandLine; |
18 class DictionaryValue; | 19 class DictionaryValue; |
19 class ListValue; | 20 class ListValue; |
20 class MessageLoop; | |
21 | 21 |
22 // This class acts as the browser-side host to a utility child process. A | 22 // 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 | 23 // 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. | 24 // a specific task. This class lives solely on the IO thread. |
25 class UtilityProcessHost : public ChildProcessHost { | 25 class UtilityProcessHost : public ChildProcessHost { |
26 public: | 26 public: |
27 // 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 |
28 // 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 |
29 // to UtilityProcessHost. | 29 // to UtilityProcessHost. |
30 class Client : public base::RefCountedThreadSafe<Client> { | 30 class Client : public base::RefCountedThreadSafe<Client> { |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 const std::string& error_message) {} | 65 const std::string& error_message) {} |
66 | 66 |
67 private: | 67 private: |
68 friend class UtilityProcessHost; | 68 friend class UtilityProcessHost; |
69 void OnMessageReceived(const IPC::Message& message); | 69 void OnMessageReceived(const IPC::Message& message); |
70 | 70 |
71 DISALLOW_COPY_AND_ASSIGN(Client); | 71 DISALLOW_COPY_AND_ASSIGN(Client); |
72 }; | 72 }; |
73 | 73 |
74 UtilityProcessHost(ResourceDispatcherHost* rdh, Client* client, | 74 UtilityProcessHost(ResourceDispatcherHost* rdh, Client* client, |
75 MessageLoop* client_loop); | 75 ChromeThread::ID client_thread_id); |
76 virtual ~UtilityProcessHost(); | 76 virtual ~UtilityProcessHost(); |
77 | 77 |
78 // Start a process to unpack the extension at the given path. The process | 78 // Start a process to unpack the extension at the given path. The process |
79 // will be given access to the directory subtree that the extension file is | 79 // will be given access to the directory subtree that the extension file is |
80 // in, so the caller is expected to have moved that file into a quarantined | 80 // in, so the caller is expected to have moved that file into a quarantined |
81 // location first. | 81 // location first. |
82 bool StartExtensionUnpacker(const FilePath& extension); | 82 bool StartExtensionUnpacker(const FilePath& extension); |
83 | 83 |
84 // Start a process to unpack and parse a web resource from the given JSON | 84 // Start a process to unpack and parse a web resource from the given JSON |
85 // data. Any links that need to be downloaded from the parsed data | 85 // data. Any links that need to be downloaded from the parsed data |
(...skipping 24 matching lines...) Expand all Loading... |
110 virtual void OnChannelError(); | 110 virtual void OnChannelError(); |
111 virtual bool CanShutdown() { return true; } | 111 virtual bool CanShutdown() { return true; } |
112 virtual URLRequestContext* GetRequestContext( | 112 virtual URLRequestContext* GetRequestContext( |
113 uint32 request_id, | 113 uint32 request_id, |
114 const ViewHostMsg_Resource_Request& request_data) { | 114 const ViewHostMsg_Resource_Request& request_data) { |
115 return NULL; | 115 return NULL; |
116 } | 116 } |
117 | 117 |
118 // A pointer to our client interface, who will be informed of progress. | 118 // A pointer to our client interface, who will be informed of progress. |
119 scoped_refptr<Client> client_; | 119 scoped_refptr<Client> client_; |
120 MessageLoop* client_loop_; | 120 ChromeThread::ID client_thread_id_; |
121 | 121 |
122 DISALLOW_COPY_AND_ASSIGN(UtilityProcessHost); | 122 DISALLOW_COPY_AND_ASSIGN(UtilityProcessHost); |
123 }; | 123 }; |
124 | 124 |
125 #endif // CHROME_BROWSER_UTILITY_PROCESS_HOST_H_ | 125 #endif // CHROME_BROWSER_UTILITY_PROCESS_HOST_H_ |
OLD | NEW |