Chromium Code Reviews| Index: chrome/service/service_utility_process_host.h |
| diff --git a/chrome/service/service_utility_process_host.h b/chrome/service/service_utility_process_host.h |
| index 9ad97ddb4498888157de3684c69b6c5619d9407b..7c83b59dfb6aa23dfda4cdbd98e7e85051c9cc77 100644 |
| --- a/chrome/service/service_utility_process_host.h |
| +++ b/chrome/service/service_utility_process_host.h |
| @@ -7,20 +7,16 @@ |
| #include "build/build_config.h" |
| -#include <string> |
| -#include <vector> |
| - |
| -#include "base/basictypes.h" |
| -#include "base/files/file_path.h" |
| #include "base/memory/ref_counted.h" |
| +#include "base/memory/weak_ptr.h" |
| #include "base/memory/scoped_ptr.h" |
| -#include "base/process/process.h" |
| #include "content/public/common/child_process_host_delegate.h" |
| -#include "ipc/ipc_channel.h" |
| -#include "printing/pdf_render_settings.h" |
| +#include "ipc/ipc_platform_file.h" |
| namespace base { |
| class CommandLine; |
| +class File; |
| +class FilePath; |
| class MessageLoopProxy; |
| class ScopedTempDir; |
| } // namespace base |
| @@ -31,6 +27,7 @@ class ChildProcessHost; |
| namespace printing { |
| class MetafilePlayer; |
| +class PdfRenderSettings; |
| struct PageRange; |
| struct PrinterCapsAndDefaults; |
| struct PrinterSemanticCapsAndDefaults; |
| @@ -51,13 +48,13 @@ class ServiceUtilityProcessHost : public content::ChildProcessHostDelegate { |
| // Called when the child process died before a reply was receieved. |
| virtual void OnChildDied() {} |
| - // Called when at least one page in the specified PDF has been rendered |
| - // successfully into |metafile|. |
| - virtual void OnRenderPDFPagesToMetafileSucceeded( |
| - const printing::MetafilePlayer& metafile, |
| - int highest_rendered_page_number, |
| - double scale_factor) {} |
| - // Called when no page in the passed in PDF could be rendered. |
| + virtual void OnRenderPDFPagesToMetafilePageDone( |
| + double scale_factor, |
| + const printing::MetafilePlayer& emf) {} |
| + |
| + // Called when at all pages in the PDF has been rendered successfully. |
| + virtual void OnRenderPDFPagesToMetafileSucceeded() {} |
| + // Called when at least one page in PDF could be rendered. |
| virtual void OnRenderPDFPagesToMetafileFailed() {} |
| // Called when the printer capabilities and defaults have been |
| @@ -82,9 +79,7 @@ class ServiceUtilityProcessHost : public content::ChildProcessHostDelegate { |
| friend class ServiceUtilityProcessHost; |
| // Invoked when a metafile file is ready. |
| - void MetafileAvailable(const base::FilePath& metafile_path, |
| - int highest_rendered_page_number, |
| - double scale_factor); |
| + void MetafileAvailable(double scale_factor, base::File file); |
| DISALLOW_COPY_AND_ASSIGN(Client); |
| }; |
| @@ -98,8 +93,7 @@ class ServiceUtilityProcessHost : public content::ChildProcessHostDelegate { |
| // pages than the specified page ranges, it will render as many as available. |
| bool StartRenderPDFPagesToMetafile( |
| const base::FilePath& pdf_path, |
| - const printing::PdfRenderSettings& render_settings, |
| - const std::vector<printing::PageRange>& page_ranges); |
| + const printing::PdfRenderSettings& render_settings); |
| // Starts a process to get capabilities and defaults for the specified |
| // printer. Used on Windows to isolate the service process from printer driver |
| @@ -113,6 +107,8 @@ class ServiceUtilityProcessHost : public content::ChildProcessHostDelegate { |
| // in a sandbox. Returns result as printing::PrinterSemanticCapsAndDefaults. |
| bool StartGetPrinterSemanticCapsAndDefaults(const std::string& printer_name); |
| + bool Send(IPC::Message* msg); |
| + |
| protected: |
| // Allows this method to be overridden for tests. |
| virtual base::FilePath GetUtilityProcessCmd(); |
| @@ -123,26 +119,21 @@ class ServiceUtilityProcessHost : public content::ChildProcessHostDelegate { |
| virtual base::ProcessHandle GetHandle() const OVERRIDE; |
| private: |
| - // Starts a process. Returns true iff it succeeded. |exposed_dir| is the |
| - // path to the exposed to the sandbox. This is ignored if |no_sandbox| is |
| - // true. |
| - bool StartProcess(bool no_sandbox, const base::FilePath& exposed_dir); |
| + // Starts a process. Returns true iff it succeeded. |
| + bool StartProcess(bool no_sandbox); |
| // Launch the child process synchronously. |
| - // TODO(sanjeevr): Determine whether we need to make the launch asynchronous. |
| - // |exposed_dir| is the path to tbe exposed to the sandbox. This is ignored |
| - // if |no_sandbox| is true. |
| - bool Launch(base::CommandLine* cmd_line, |
| - bool no_sandbox, |
| - const base::FilePath& exposed_dir); |
| + bool Launch(base::CommandLine* cmd_line, bool no_sandbox); |
| base::ProcessHandle handle() const { return handle_; } |
| + void OnMetafileSpooled(); |
| + /*void ReplayCreateFileIfReady(); |
|
Lei Zhang
2014/09/15 21:49:53
dead code? (and in .cc file)
Vitaly Buka (NO REVIEWS)
2014/09/15 22:33:50
As I wrote before this part is not updated from pa
|
| + void FailReplyOnCreate();*/ |
| + |
| // Messages handlers: |
| - void OnRenderPDFPagesToMetafilesSucceeded( |
| - const std::vector<printing::PageRange>& page_ranges, |
| - double scale_factor); |
| - void OnRenderPDFPagesToMetafileFailed(); |
| + void OnRenderPDFPagesToMetafilesPageCount(int page_count) {}; |
|
Lei Zhang
2014/09/15 21:49:53
Don't you need the page count so you know how many
Vitaly Buka (NO REVIEWS)
2014/09/15 22:33:50
ditto
On 2014/09/15 21:49:53, Lei Zhang wrote:
|
| + void OnRenderPDFPagesToMetafilesPageDone(bool success, double scale_factor); |
| void OnGetPrinterCapsAndDefaultsSucceeded( |
| const std::string& printer_name, |
| const printing::PrinterCapsAndDefaults& caps_and_defaults); |
| @@ -159,13 +150,22 @@ class ServiceUtilityProcessHost : public content::ChildProcessHostDelegate { |
| scoped_refptr<Client> client_; |
| scoped_refptr<base::MessageLoopProxy> client_message_loop_proxy_; |
| bool waiting_for_reply_; |
| - // The base path to the temp file where the metafile will be written to. |
| - base::FilePath metafile_path_; |
| - // The temporary folder created for the metafile. |
| - scoped_ptr<base::ScopedTempDir> scratch_metafile_dir_; |
| + |
| // Start time of operation. |
| base::Time start_time_; |
| + // Output file for current page converted by utility process. |
| + base::File emf_file_; |
| + |
| + // Delayed reply for on request for new output file by utility process. |
| + // We want to delay conversion if client is not fast enough. |
| + IPC::Message* create_file_reply_msg_; |
| + |
| + // Number in-progress files sent to client. |
| + int number_of_emf_in_progress_; |
| + |
| + base::WeakPtrFactory<ServiceUtilityProcessHost> weak_ptr_factory_; |
| + |
| DISALLOW_COPY_AND_ASSIGN(ServiceUtilityProcessHost); |
| }; |