| 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 | 10 |
| 10 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
| 11 #include "base/ref_counted.h" | 12 #include "base/ref_counted.h" |
| 12 #include "base/task.h" | 13 #include "base/task.h" |
| 13 #include "chrome/common/child_process_host.h" | 14 #include "chrome/common/child_process_host.h" |
| 14 #include "chrome/common/ipc_channel.h" | 15 #include "chrome/common/ipc_channel.h" |
| 15 | 16 |
| 16 class CommandLine; | 17 class CommandLine; |
| 18 class DictionaryValue; |
| 17 class MessageLoop; | 19 class MessageLoop; |
| 20 class SkBitmap; |
| 18 | 21 |
| 19 // 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 |
| 20 // 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 |
| 21 // a specific task. This class lives solely on the IO thread. | 24 // a specific task. This class lives solely on the IO thread. |
| 22 class UtilityProcessHost : public ChildProcessHost { | 25 class UtilityProcessHost : public ChildProcessHost { |
| 23 public: | 26 public: |
| 24 // 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 |
| 25 // 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 |
| 26 // to UtilityProcessHost. | 29 // to UtilityProcessHost. |
| 27 class Client : public base::RefCountedThreadSafe<Client> { | 30 class Client : public base::RefCountedThreadSafe<Client> { |
| 28 public: | 31 public: |
| 29 Client() {} | 32 Client() {} |
| 30 virtual ~Client() {} | 33 virtual ~Client() {} |
| 31 | 34 |
| 32 // Called when the process has crashed. | 35 // Called when the process has crashed. |
| 33 virtual void OnProcessCrashed() {} | 36 virtual void OnProcessCrashed() {} |
| 34 | 37 |
| 35 // Called when the process sends a reply to an UnpackExtension message. | 38 // Called when the extension has unpacked successfully. |manifest| is the |
| 36 // If success if false, error_message contains a description of the problem. | 39 // parsed manifest.json file. |images| contains a list of decoded images |
| 37 virtual void OnUnpackExtensionReply(bool success, | 40 // and the associated paths where those images live on disk. |
| 38 const std::string& error_message) {} | 41 virtual void OnUnpackExtensionSucceeded( |
| 42 const DictionaryValue& manifest, |
| 43 const std::vector< Tuple2<SkBitmap, FilePath> >& images) {} |
| 44 |
| 45 // Called when an error occurred while unpacking the extension. |
| 46 // |error_message| contains a description of the problem. |
| 47 virtual void OnUnpackExtensionFailed(const std::string& error_message) {} |
| 48 |
| 39 private: | 49 private: |
| 40 friend class UtilityProcessHost; | 50 friend class UtilityProcessHost; |
| 41 void OnMessageReceived(const IPC::Message& message); | 51 void OnMessageReceived(const IPC::Message& message); |
| 42 | 52 |
| 43 DISALLOW_COPY_AND_ASSIGN(Client); | 53 DISALLOW_COPY_AND_ASSIGN(Client); |
| 44 }; | 54 }; |
| 45 | 55 |
| 46 UtilityProcessHost(ResourceDispatcherHost* rdh, Client* client, | 56 UtilityProcessHost(ResourceDispatcherHost* rdh, Client* client, |
| 47 MessageLoop* client_loop); | 57 MessageLoop* client_loop); |
| 48 ~UtilityProcessHost(); | 58 ~UtilityProcessHost(); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 70 } | 80 } |
| 71 | 81 |
| 72 // A pointer to our client interface, who will be informed of progress. | 82 // A pointer to our client interface, who will be informed of progress. |
| 73 scoped_refptr<Client> client_; | 83 scoped_refptr<Client> client_; |
| 74 MessageLoop* client_loop_; | 84 MessageLoop* client_loop_; |
| 75 | 85 |
| 76 DISALLOW_COPY_AND_ASSIGN(UtilityProcessHost); | 86 DISALLOW_COPY_AND_ASSIGN(UtilityProcessHost); |
| 77 }; | 87 }; |
| 78 | 88 |
| 79 #endif // CHROME_BROWSER_UTILITY_PROCESS_HOST_H_ | 89 #endif // CHROME_BROWSER_UTILITY_PROCESS_HOST_H_ |
| OLD | NEW |