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 "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 // get results back. All functions are called on the thread passed along | 42 // get results back. All functions are called on the thread passed along |
43 // to ServiceUtilityProcessHost. | 43 // to ServiceUtilityProcessHost. |
44 class Client : public base::RefCountedThreadSafe<Client> { | 44 class Client : public base::RefCountedThreadSafe<Client> { |
45 public: | 45 public: |
46 Client() {} | 46 Client() {} |
47 | 47 |
48 // Called when the child process died before a reply was receieved. | 48 // Called when the child process died before a reply was receieved. |
49 virtual void OnChildDied() {} | 49 virtual void OnChildDied() {} |
50 | 50 |
51 virtual void OnRenderPDFPagesToMetafilePageDone( | 51 virtual void OnRenderPDFPagesToMetafilePageDone( |
52 double scale_factor, | 52 float scale_factor, |
53 const printing::MetafilePlayer& emf) {} | 53 const printing::MetafilePlayer& emf) {} |
54 | 54 |
55 // Called when at all pages in the PDF has been rendered. | 55 // Called when at all pages in the PDF has been rendered. |
56 virtual void OnRenderPDFPagesToMetafileDone(bool success) {} | 56 virtual void OnRenderPDFPagesToMetafileDone(bool success) {} |
57 | 57 |
58 // Called when the printer capabilities and defaults have been | 58 // Called when the printer capabilities and defaults have been |
59 // retrieved successfully or if retrieval failed. | 59 // retrieved successfully or if retrieval failed. |
60 virtual void OnGetPrinterCapsAndDefaults( | 60 virtual void OnGetPrinterCapsAndDefaults( |
61 bool succedded, | 61 bool succedded, |
62 const std::string& printer_name, | 62 const std::string& printer_name, |
63 const printing::PrinterCapsAndDefaults& caps_and_defaults) {} | 63 const printing::PrinterCapsAndDefaults& caps_and_defaults) {} |
64 | 64 |
65 // Called when the printer capabilities and defaults have been | 65 // Called when the printer capabilities and defaults have been |
66 // retrieved successfully or if retrieval failed. | 66 // retrieved successfully or if retrieval failed. |
67 virtual void OnGetPrinterSemanticCapsAndDefaults( | 67 virtual void OnGetPrinterSemanticCapsAndDefaults( |
68 bool succedded, | 68 bool succedded, |
69 const std::string& printer_name, | 69 const std::string& printer_name, |
70 const printing::PrinterSemanticCapsAndDefaults& caps_and_defaults) {} | 70 const printing::PrinterSemanticCapsAndDefaults& caps_and_defaults) {} |
71 | 71 |
72 protected: | 72 protected: |
73 virtual ~Client() {} | 73 virtual ~Client() {} |
74 | 74 |
75 private: | 75 private: |
76 friend class base::RefCountedThreadSafe<Client>; | 76 friend class base::RefCountedThreadSafe<Client>; |
77 friend class ServiceUtilityProcessHost; | 77 friend class ServiceUtilityProcessHost; |
78 | 78 |
79 // Invoked when a metafile file is ready. | 79 // Invoked when a metafile file is ready. |
80 // Returns true if metafile successfully loaded from |file|. | 80 // Returns true if metafile successfully loaded from |file|. |
81 bool MetafileAvailable(double scale_factor, base::File file); | 81 bool MetafileAvailable(float scale_factor, base::File file); |
82 | 82 |
83 DISALLOW_COPY_AND_ASSIGN(Client); | 83 DISALLOW_COPY_AND_ASSIGN(Client); |
84 }; | 84 }; |
85 | 85 |
86 ServiceUtilityProcessHost(Client* client, | 86 ServiceUtilityProcessHost(Client* client, |
87 base::MessageLoopProxy* client_message_loop_proxy); | 87 base::MessageLoopProxy* client_message_loop_proxy); |
88 virtual ~ServiceUtilityProcessHost(); | 88 virtual ~ServiceUtilityProcessHost(); |
89 | 89 |
90 // Starts a process to render the specified pages in the given PDF file into | 90 // Starts a process to render the specified pages in the given PDF file into |
91 // a metafile. Currently only implemented for Windows. If the PDF has fewer | 91 // a metafile. Currently only implemented for Windows. If the PDF has fewer |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 // Launch the child process synchronously. | 124 // Launch the child process synchronously. |
125 bool Launch(base::CommandLine* cmd_line, bool no_sandbox); | 125 bool Launch(base::CommandLine* cmd_line, bool no_sandbox); |
126 | 126 |
127 base::ProcessHandle handle() const { return handle_; } | 127 base::ProcessHandle handle() const { return handle_; } |
128 | 128 |
129 void OnMetafileSpooled(bool success); | 129 void OnMetafileSpooled(bool success); |
130 void OnPDFToEmfFinished(bool success); | 130 void OnPDFToEmfFinished(bool success); |
131 | 131 |
132 // Messages handlers: | 132 // Messages handlers: |
133 void OnRenderPDFPagesToMetafilesPageCount(int page_count); | 133 void OnRenderPDFPagesToMetafilesPageCount(int page_count); |
134 void OnRenderPDFPagesToMetafilesPageDone(bool success, double scale_factor); | 134 void OnRenderPDFPagesToMetafilesPageDone(bool success, float scale_factor); |
135 void OnGetPrinterCapsAndDefaultsSucceeded( | 135 void OnGetPrinterCapsAndDefaultsSucceeded( |
136 const std::string& printer_name, | 136 const std::string& printer_name, |
137 const printing::PrinterCapsAndDefaults& caps_and_defaults); | 137 const printing::PrinterCapsAndDefaults& caps_and_defaults); |
138 void OnGetPrinterCapsAndDefaultsFailed(const std::string& printer_name); | 138 void OnGetPrinterCapsAndDefaultsFailed(const std::string& printer_name); |
139 void OnGetPrinterSemanticCapsAndDefaultsSucceeded( | 139 void OnGetPrinterSemanticCapsAndDefaultsSucceeded( |
140 const std::string& printer_name, | 140 const std::string& printer_name, |
141 const printing::PrinterSemanticCapsAndDefaults& caps_and_defaults); | 141 const printing::PrinterSemanticCapsAndDefaults& caps_and_defaults); |
142 void OnGetPrinterSemanticCapsAndDefaultsFailed( | 142 void OnGetPrinterSemanticCapsAndDefaultsFailed( |
143 const std::string& printer_name); | 143 const std::string& printer_name); |
144 | 144 |
145 scoped_ptr<content::ChildProcessHost> child_process_host_; | 145 scoped_ptr<content::ChildProcessHost> child_process_host_; |
146 base::ProcessHandle handle_; | 146 base::ProcessHandle handle_; |
147 // A pointer to our client interface, who will be informed of progress. | 147 // A pointer to our client interface, who will be informed of progress. |
148 scoped_refptr<Client> client_; | 148 scoped_refptr<Client> client_; |
149 scoped_refptr<base::MessageLoopProxy> client_message_loop_proxy_; | 149 scoped_refptr<base::MessageLoopProxy> client_message_loop_proxy_; |
150 bool waiting_for_reply_; | 150 bool waiting_for_reply_; |
151 | 151 |
152 // Start time of operation. | 152 // Start time of operation. |
153 base::Time start_time_; | 153 base::Time start_time_; |
154 | 154 |
155 class PdfToEmfState; | 155 class PdfToEmfState; |
156 scoped_ptr<PdfToEmfState> pdf_to_emf_state_; | 156 scoped_ptr<PdfToEmfState> pdf_to_emf_state_; |
157 | 157 |
158 base::WeakPtrFactory<ServiceUtilityProcessHost> weak_ptr_factory_; | 158 base::WeakPtrFactory<ServiceUtilityProcessHost> weak_ptr_factory_; |
159 | 159 |
160 DISALLOW_COPY_AND_ASSIGN(ServiceUtilityProcessHost); | 160 DISALLOW_COPY_AND_ASSIGN(ServiceUtilityProcessHost); |
161 }; | 161 }; |
162 | 162 |
163 #endif // CHROME_SERVICE_SERVICE_UTILITY_PROCESS_HOST_H_ | 163 #endif // CHROME_SERVICE_SERVICE_UTILITY_PROCESS_HOST_H_ |
OLD | NEW |