Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_SERVICE_SERVICE_UTILITY_PROCESS_HOST_H_ | 5 #ifndef CHROME_SERVICE_SERVICE_UTILITY_PROCESS_HOST_H_ |
| 6 #define CHROME_SERVICE_SERVICE_UTILITY_PROCESS_HOST_H_ | 6 #define CHROME_SERVICE_SERVICE_UTILITY_PROCESS_HOST_H_ |
| 7 | 7 |
| 8 #include "build/build_config.h" | 8 #include "build/build_config.h" |
| 9 | 9 |
| 10 #include <string> | 10 #include <string> |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 23 class CommandLine; | 23 class CommandLine; |
| 24 class MessageLoopProxy; | 24 class MessageLoopProxy; |
| 25 class ScopedTempDir; | 25 class ScopedTempDir; |
| 26 } // namespace base | 26 } // namespace base |
| 27 | 27 |
| 28 namespace content { | 28 namespace content { |
| 29 class ChildProcessHost; | 29 class ChildProcessHost; |
| 30 } | 30 } |
| 31 | 31 |
| 32 namespace printing { | 32 namespace printing { |
| 33 class Emf; | 33 class MetafilePlayer; |
| 34 struct PageRange; | 34 struct PageRange; |
| 35 struct PrinterCapsAndDefaults; | 35 struct PrinterCapsAndDefaults; |
| 36 struct PrinterSemanticCapsAndDefaults; | 36 struct PrinterSemanticCapsAndDefaults; |
| 37 } // namespace printing | 37 } // namespace printing |
| 38 | 38 |
| 39 // Acts as the service-side host to a utility child process. A | 39 // Acts as the service-side host to a utility child process. A |
| 40 // utility process is a short-lived sandboxed process that is created to run | 40 // utility process is a short-lived sandboxed process that is created to run |
| 41 // a specific task. | 41 // a specific task. |
| 42 class ServiceUtilityProcessHost : public content::ChildProcessHostDelegate { | 42 class ServiceUtilityProcessHost : public content::ChildProcessHostDelegate { |
| 43 public: | 43 public: |
| 44 // Consumers of ServiceUtilityProcessHost must implement this interface to | 44 // Consumers of ServiceUtilityProcessHost must implement this interface to |
| 45 // get results back. All functions are called on the thread passed along | 45 // get results back. All functions are called on the thread passed along |
| 46 // to ServiceUtilityProcessHost. | 46 // to ServiceUtilityProcessHost. |
| 47 class Client : public base::RefCountedThreadSafe<Client> { | 47 class Client : public base::RefCountedThreadSafe<Client> { |
| 48 public: | 48 public: |
| 49 Client() {} | 49 Client() {} |
| 50 | 50 |
| 51 // Called when the child process died before a reply was receieved. | 51 // Called when the child process died before a reply was receieved. |
| 52 virtual void OnChildDied() {} | 52 virtual void OnChildDied() {} |
| 53 | 53 |
| 54 // Called when at least one page in the specified PDF has been rendered | 54 // Called when at least one page in the specified PDF has been rendered |
| 55 // successfully into |metafile|. | 55 // successfully into |metafile|. |
| 56 virtual void OnRenderPDFPagesToMetafileSucceeded( | 56 virtual void OnRenderPDFPagesToMetafileSucceeded( |
| 57 const printing::Emf& metafile, | 57 const printing::MetafilePlayer& metafile, |
| 58 int highest_rendered_page_number, | 58 int highest_rendered_page_number, |
| 59 double scale_factor) {} | 59 double scale_factor) {} |
| 60 // Called when no page in the passed in PDF could be rendered. | 60 // Called when no page in the passed in PDF could be rendered. |
| 61 virtual void OnRenderPDFPagesToMetafileFailed() {} | 61 virtual void OnRenderPDFPagesToMetafileFailed() {} |
| 62 | 62 |
| 63 // Called when the printer capabilities and defaults have been | 63 // Called when the printer capabilities and defaults have been |
| 64 // retrieved successfully or if retrieval failed. | 64 // retrieved successfully or if retrieval failed. |
| 65 virtual void OnGetPrinterCapsAndDefaults( | 65 virtual void OnGetPrinterCapsAndDefaults( |
| 66 bool succedded, | 66 bool succedded, |
| 67 const std::string& printer_name, | 67 const std::string& printer_name, |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 133 // |exposed_dir| is the path to tbe exposed to the sandbox. This is ignored | 133 // |exposed_dir| is the path to tbe exposed to the sandbox. This is ignored |
| 134 // if |no_sandbox| is true. | 134 // if |no_sandbox| is true. |
| 135 bool Launch(base::CommandLine* cmd_line, | 135 bool Launch(base::CommandLine* cmd_line, |
| 136 bool no_sandbox, | 136 bool no_sandbox, |
| 137 const base::FilePath& exposed_dir); | 137 const base::FilePath& exposed_dir); |
| 138 | 138 |
| 139 base::ProcessHandle handle() const { return handle_; } | 139 base::ProcessHandle handle() const { return handle_; } |
| 140 | 140 |
| 141 // Messages handlers: | 141 // Messages handlers: |
| 142 void OnRenderPDFPagesToMetafilesSucceeded( | 142 void OnRenderPDFPagesToMetafilesSucceeded( |
| 143 const std::vector<printing::PageRange>& page_ranges, | 143 const std::vector<printing::PageRange>& page_ranges, |
|
Lei Zhang
2014/09/11 23:31:10
nit: 4 space indent
Vitaly Buka (NO REVIEWS)
2014/09/12 01:54:00
Done.
| |
| 144 double scale_factor); | 144 double scale_factor); |
| 145 void OnRenderPDFPagesToMetafileFailed(); | 145 void OnRenderPDFPagesToMetafileFailed(); |
| 146 void OnGetPrinterCapsAndDefaultsSucceeded( | 146 void OnGetPrinterCapsAndDefaultsSucceeded( |
| 147 const std::string& printer_name, | 147 const std::string& printer_name, |
| 148 const printing::PrinterCapsAndDefaults& caps_and_defaults); | 148 const printing::PrinterCapsAndDefaults& caps_and_defaults); |
| 149 void OnGetPrinterCapsAndDefaultsFailed(const std::string& printer_name); | 149 void OnGetPrinterCapsAndDefaultsFailed(const std::string& printer_name); |
| 150 void OnGetPrinterSemanticCapsAndDefaultsSucceeded( | 150 void OnGetPrinterSemanticCapsAndDefaultsSucceeded( |
| 151 const std::string& printer_name, | 151 const std::string& printer_name, |
| 152 const printing::PrinterSemanticCapsAndDefaults& caps_and_defaults); | 152 const printing::PrinterSemanticCapsAndDefaults& caps_and_defaults); |
| 153 void OnGetPrinterSemanticCapsAndDefaultsFailed( | 153 void OnGetPrinterSemanticCapsAndDefaultsFailed( |
| 154 const std::string& printer_name); | 154 const std::string& printer_name); |
| 155 | 155 |
| 156 scoped_ptr<content::ChildProcessHost> child_process_host_; | 156 scoped_ptr<content::ChildProcessHost> child_process_host_; |
| 157 base::ProcessHandle handle_; | 157 base::ProcessHandle handle_; |
| 158 // A pointer to our client interface, who will be informed of progress. | 158 // A pointer to our client interface, who will be informed of progress. |
| 159 scoped_refptr<Client> client_; | 159 scoped_refptr<Client> client_; |
| 160 scoped_refptr<base::MessageLoopProxy> client_message_loop_proxy_; | 160 scoped_refptr<base::MessageLoopProxy> client_message_loop_proxy_; |
| 161 bool waiting_for_reply_; | 161 bool waiting_for_reply_; |
| 162 // The base path to the temp file where the metafile will be written to. | 162 // The base path to the temp file where the metafile will be written to. |
| 163 base::FilePath metafile_path_; | 163 base::FilePath metafile_path_; |
| 164 // The temporary folder created for the metafile. | 164 // The temporary folder created for the metafile. |
| 165 scoped_ptr<base::ScopedTempDir> scratch_metafile_dir_; | 165 scoped_ptr<base::ScopedTempDir> scratch_metafile_dir_; |
| 166 // Start time of operation. | 166 // Start time of operation. |
| 167 base::Time start_time_; | 167 base::Time start_time_; |
| 168 | 168 |
| 169 DISALLOW_COPY_AND_ASSIGN(ServiceUtilityProcessHost); | 169 DISALLOW_COPY_AND_ASSIGN(ServiceUtilityProcessHost); |
| 170 }; | 170 }; |
| 171 | 171 |
| 172 #endif // CHROME_SERVICE_SERVICE_UTILITY_PROCESS_HOST_H_ | 172 #endif // CHROME_SERVICE_SERVICE_UTILITY_PROCESS_HOST_H_ |
| OLD | NEW |