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 <memory> | 8 #include <memory> |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "base/macros.h" | 11 #include "base/macros.h" |
12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
13 #include "base/memory/weak_ptr.h" | 13 #include "base/memory/weak_ptr.h" |
14 #include "components/printing/common/printing.mojom.h" | |
14 #include "content/public/common/child_process_host_delegate.h" | 15 #include "content/public/common/child_process_host_delegate.h" |
15 #include "ipc/ipc_platform_file.h" | 16 #include "ipc/ipc_platform_file.h" |
16 | 17 |
17 namespace base { | 18 namespace base { |
18 class CommandLine; | 19 class CommandLine; |
19 class File; | 20 class File; |
20 class FilePath; | 21 class FilePath; |
21 class SingleThreadTaskRunner; | 22 class SingleThreadTaskRunner; |
22 } // namespace base | 23 } // namespace base |
23 | 24 |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
99 // in a sandbox. | 100 // in a sandbox. |
100 bool StartGetPrinterCapsAndDefaults(const std::string& printer_name); | 101 bool StartGetPrinterCapsAndDefaults(const std::string& printer_name); |
101 | 102 |
102 // Starts a process to get capabilities and defaults for the specified | 103 // Starts a process to get capabilities and defaults for the specified |
103 // printer. Used on Windows to isolate the service process from printer driver | 104 // printer. Used on Windows to isolate the service process from printer driver |
104 // crashes by executing this in a separate process. The process does not run | 105 // crashes by executing this in a separate process. The process does not run |
105 // in a sandbox. Returns result as printing::PrinterSemanticCapsAndDefaults. | 106 // in a sandbox. Returns result as printing::PrinterSemanticCapsAndDefaults. |
106 bool StartGetPrinterSemanticCapsAndDefaults(const std::string& printer_name); | 107 bool StartGetPrinterSemanticCapsAndDefaults(const std::string& printer_name); |
107 | 108 |
108 protected: | 109 protected: |
109 bool Send(IPC::Message* msg); | |
110 | |
111 // Allows this method to be overridden for tests. | 110 // Allows this method to be overridden for tests. |
112 virtual base::FilePath GetUtilityProcessCmd(); | 111 virtual base::FilePath GetUtilityProcessCmd(); |
113 | 112 |
114 // ChildProcessHostDelegate implementation: | 113 // ChildProcessHostDelegate implementation: |
115 void OnChildDisconnected() override; | 114 void OnChildDisconnected() override; |
116 bool OnMessageReceived(const IPC::Message& message) override; | 115 bool OnMessageReceived(const IPC::Message& message) override; |
117 const base::Process& GetProcess() const override; | 116 const base::Process& GetProcess() const override; |
118 | 117 |
118 printing::mojom::Printing* printing(); | |
119 printing::mojom::PrintingPtr printing_; | |
Sam McNally
2016/12/12 06:09:20
Why is this protected?
tibell
2016/12/13 23:41:55
Done.
| |
120 | |
119 private: | 121 private: |
120 // Starts a process. Returns true iff it succeeded. | 122 // Starts a process. Returns true iff it succeeded. |
121 bool StartProcess(bool no_sandbox); | 123 bool StartProcess(bool no_sandbox); |
122 | 124 |
123 // Launch the child process synchronously. | 125 // Launch the child process synchronously. |
124 bool Launch(base::CommandLine* cmd_line, bool no_sandbox); | 126 bool Launch(base::CommandLine* cmd_line, bool no_sandbox); |
125 | 127 |
126 base::ProcessHandle handle() const { return process_.Handle(); } | 128 base::ProcessHandle handle() const { return process_.Handle(); } |
127 | 129 |
128 void OnMetafileSpooled(bool success); | 130 void OnMetafileSpooled(bool success); |
129 void OnPDFToEmfFinished(bool success); | 131 void OnPDFToEmfFinished(bool success); |
130 | 132 |
131 // Messages handlers: | 133 // Messages handlers: |
132 void OnRenderPDFPagesToMetafilesPageCount(int page_count); | 134 void OnRenderPDFPagesToMetafilesPageCount(int page_count); |
133 void OnRenderPDFPagesToMetafilesPageDone(bool success, float scale_factor); | 135 void OnRenderPDFPagesToMetafilesPageDone(bool success, float scale_factor); |
134 void OnGetPrinterCapsAndDefaultsSucceeded( | 136 void OnGetPrinterCapsAndDefaults( |
135 const std::string& printer_name, | 137 const std::string& printer_name, |
136 const printing::PrinterCapsAndDefaults& caps_and_defaults); | 138 const base::Optional<printing::PrinterCapsAndDefaults>& |
137 void OnGetPrinterCapsAndDefaultsFailed(const std::string& printer_name); | 139 caps_and_defaults); |
138 void OnGetPrinterSemanticCapsAndDefaultsSucceeded( | 140 void OnGetPrinterSemanticCapsAndDefaults( |
139 const std::string& printer_name, | 141 const std::string& printer_name, |
140 const printing::PrinterSemanticCapsAndDefaults& caps_and_defaults); | 142 const base::Optional<printing::PrinterSemanticCapsAndDefaults>& |
141 void OnGetPrinterSemanticCapsAndDefaultsFailed( | 143 caps_and_defaults); |
142 const std::string& printer_name); | |
143 | 144 |
144 std::unique_ptr<content::ChildProcessHost> child_process_host_; | 145 std::unique_ptr<content::ChildProcessHost> child_process_host_; |
145 base::Process process_; | 146 base::Process process_; |
146 // 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. |
147 scoped_refptr<Client> client_; | 148 scoped_refptr<Client> client_; |
148 scoped_refptr<base::SingleThreadTaskRunner> client_task_runner_; | 149 scoped_refptr<base::SingleThreadTaskRunner> client_task_runner_; |
149 bool waiting_for_reply_; | 150 bool waiting_for_reply_; |
150 const std::string mojo_child_token_; | 151 const std::string mojo_child_token_; |
151 | 152 |
152 // Start time of operation. | 153 // Start time of operation. |
153 base::Time start_time_; | 154 base::Time start_time_; |
154 | 155 |
155 class PdfToEmfState; | 156 class PdfToEmfState; |
156 std::unique_ptr<PdfToEmfState> pdf_to_emf_state_; | 157 std::unique_ptr<PdfToEmfState> pdf_to_emf_state_; |
157 | 158 |
158 base::WeakPtrFactory<ServiceUtilityProcessHost> weak_ptr_factory_; | 159 base::WeakPtrFactory<ServiceUtilityProcessHost> weak_ptr_factory_; |
159 | 160 |
160 DISALLOW_COPY_AND_ASSIGN(ServiceUtilityProcessHost); | 161 DISALLOW_COPY_AND_ASSIGN(ServiceUtilityProcessHost); |
161 }; | 162 }; |
162 | 163 |
163 #endif // CHROME_SERVICE_SERVICE_UTILITY_PROCESS_HOST_H_ | 164 #endif // CHROME_SERVICE_SERVICE_UTILITY_PROCESS_HOST_H_ |
OLD | NEW |