| 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 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
| 12 #include "base/ref_counted.h" | 12 #include "base/ref_counted.h" |
| 13 #include "base/task.h" | 13 #include "base/task.h" |
| 14 #include "chrome/browser/child_process_host.h" | 14 #include "chrome/browser/browser_child_process_host.h" |
| 15 #include "chrome/browser/chrome_thread.h" | 15 #include "chrome/browser/chrome_thread.h" |
| 16 #include "chrome/common/extensions/update_manifest.h" | 16 #include "chrome/common/extensions/update_manifest.h" |
| 17 #include "ipc/ipc_channel.h" | 17 #include "ipc/ipc_channel.h" |
| 18 #include "third_party/skia/include/core/SkBitmap.h" | 18 #include "third_party/skia/include/core/SkBitmap.h" |
| 19 | 19 |
| 20 class CommandLine; | 20 class CommandLine; |
| 21 class DictionaryValue; | 21 class DictionaryValue; |
| 22 class ListValue; | 22 class ListValue; |
| 23 | 23 |
| 24 // This class acts as the browser-side host to a utility child process. A | 24 // This class acts as the browser-side host to a utility child process. A |
| 25 // utility process is a short-lived sandboxed process that is created to run | 25 // utility process is a short-lived sandboxed process that is created to run |
| 26 // a specific task. This class lives solely on the IO thread. | 26 // a specific task. This class lives solely on the IO thread. |
| 27 class UtilityProcessHost : public ChildProcessHost { | 27 class UtilityProcessHost : public BrowserChildProcessHost { |
| 28 public: | 28 public: |
| 29 // An interface to be implemented by consumers of the utility process to | 29 // An interface to be implemented by consumers of the utility process to |
| 30 // get results back. All functions are called on the thread passed along | 30 // get results back. All functions are called on the thread passed along |
| 31 // to UtilityProcessHost. | 31 // to UtilityProcessHost. |
| 32 class Client : public base::RefCountedThreadSafe<Client> { | 32 class Client : public base::RefCountedThreadSafe<Client> { |
| 33 public: | 33 public: |
| 34 Client() {} | 34 Client() {} |
| 35 | 35 |
| 36 // Called when the process has crashed. | 36 // Called when the process has crashed. |
| 37 virtual void OnProcessCrashed() {} | 37 virtual void OnProcessCrashed() {} |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 // Allow these methods to be overridden for tests. | 114 // Allow these methods to be overridden for tests. |
| 115 virtual FilePath GetUtilityProcessCmd(); | 115 virtual FilePath GetUtilityProcessCmd(); |
| 116 | 116 |
| 117 private: | 117 private: |
| 118 // Starts a process. Returns true iff it succeeded. | 118 // Starts a process. Returns true iff it succeeded. |
| 119 bool StartProcess(const FilePath& exposed_dir); | 119 bool StartProcess(const FilePath& exposed_dir); |
| 120 | 120 |
| 121 // IPC messages: | 121 // IPC messages: |
| 122 void OnMessageReceived(const IPC::Message& message); | 122 void OnMessageReceived(const IPC::Message& message); |
| 123 | 123 |
| 124 // ChildProcessHost: | 124 // BrowserChildProcessHost: |
| 125 virtual void OnProcessCrashed(); | 125 virtual void OnProcessCrashed(); |
| 126 virtual bool CanShutdown() { return true; } | 126 virtual bool CanShutdown() { return true; } |
| 127 virtual URLRequestContext* GetRequestContext( | 127 virtual URLRequestContext* GetRequestContext( |
| 128 uint32 request_id, | 128 uint32 request_id, |
| 129 const ViewHostMsg_Resource_Request& request_data) { | 129 const ViewHostMsg_Resource_Request& request_data) { |
| 130 return NULL; | 130 return NULL; |
| 131 } | 131 } |
| 132 | 132 |
| 133 // A pointer to our client interface, who will be informed of progress. | 133 // A pointer to our client interface, who will be informed of progress. |
| 134 scoped_refptr<Client> client_; | 134 scoped_refptr<Client> client_; |
| 135 ChromeThread::ID client_thread_id_; | 135 ChromeThread::ID client_thread_id_; |
| 136 | 136 |
| 137 DISALLOW_COPY_AND_ASSIGN(UtilityProcessHost); | 137 DISALLOW_COPY_AND_ASSIGN(UtilityProcessHost); |
| 138 }; | 138 }; |
| 139 | 139 |
| 140 #endif // CHROME_BROWSER_UTILITY_PROCESS_HOST_H_ | 140 #endif // CHROME_BROWSER_UTILITY_PROCESS_HOST_H_ |
| OLD | NEW |