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 #include "chrome/service/service_utility_process_host.h" | 5 #include "chrome/service/service_utility_process_host.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
10 #include "base/files/scoped_temp_dir.h" | 10 #include "base/files/scoped_temp_dir.h" |
11 #include "base/logging.h" | 11 #include "base/logging.h" |
12 #include "base/message_loop/message_loop.h" | 12 #include "base/message_loop/message_loop.h" |
13 #include "base/message_loop/message_loop_proxy.h" | 13 #include "base/message_loop/message_loop_proxy.h" |
14 #include "base/metrics/histogram.h" | 14 #include "base/metrics/histogram.h" |
15 #include "base/process/kill.h" | 15 #include "base/process/kill.h" |
16 #include "base/strings/utf_string_conversions.h" | 16 #include "base/strings/utf_string_conversions.h" |
17 #include "chrome/common/chrome_switches.h" | 17 #include "chrome/common/chrome_switches.h" |
18 #include "chrome/common/chrome_utility_messages.h" | 18 #include "chrome/common/chrome_utility_printing_messages.h" |
19 #include "content/public/common/child_process_host.h" | 19 #include "content/public/common/child_process_host.h" |
20 #include "content/public/common/result_codes.h" | 20 #include "content/public/common/result_codes.h" |
21 #include "content/public/common/sandbox_init.h" | 21 #include "content/public/common/sandbox_init.h" |
22 #include "ipc/ipc_switches.h" | 22 #include "ipc/ipc_switches.h" |
23 #include "printing/page_range.h" | 23 #include "printing/page_range.h" |
24 #include "ui/base/ui_base_switches.h" | 24 #include "ui/base/ui_base_switches.h" |
25 #include "ui/gfx/rect.h" | 25 #include "ui/gfx/rect.h" |
26 | 26 |
27 #if defined(OS_WIN) | 27 #if defined(OS_WIN) |
28 #include "base/files/file_path.h" | 28 #include "base/files/file_path.h" |
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
223 SERVICE_UTILITY_EVENT_MAX); | 223 SERVICE_UTILITY_EVENT_MAX); |
224 UMA_HISTOGRAM_TIMES("CloudPrint.ServiceUtilityDisconnectTime", | 224 UMA_HISTOGRAM_TIMES("CloudPrint.ServiceUtilityDisconnectTime", |
225 base::Time::Now() - start_time_); | 225 base::Time::Now() - start_time_); |
226 } | 226 } |
227 delete this; | 227 delete this; |
228 } | 228 } |
229 | 229 |
230 bool ServiceUtilityProcessHost::OnMessageReceived(const IPC::Message& message) { | 230 bool ServiceUtilityProcessHost::OnMessageReceived(const IPC::Message& message) { |
231 bool handled = true; | 231 bool handled = true; |
232 IPC_BEGIN_MESSAGE_MAP(ServiceUtilityProcessHost, message) | 232 IPC_BEGIN_MESSAGE_MAP(ServiceUtilityProcessHost, message) |
| 233 #if defined(WIN_PDF_METAFILE_FOR_PRINTING) |
233 IPC_MESSAGE_HANDLER( | 234 IPC_MESSAGE_HANDLER( |
234 ChromeUtilityHostMsg_RenderPDFPagesToMetafiles_Succeeded, | 235 ChromeUtilityHostMsg_RenderPDFPagesToMetafiles_Succeeded, |
235 OnRenderPDFPagesToMetafilesSucceeded) | 236 OnRenderPDFPagesToMetafilesSucceeded) |
236 IPC_MESSAGE_HANDLER(ChromeUtilityHostMsg_RenderPDFPagesToMetafile_Failed, | 237 IPC_MESSAGE_HANDLER(ChromeUtilityHostMsg_RenderPDFPagesToMetafile_Failed, |
237 OnRenderPDFPagesToMetafileFailed) | 238 OnRenderPDFPagesToMetafileFailed) |
| 239 #endif |
238 IPC_MESSAGE_HANDLER( | 240 IPC_MESSAGE_HANDLER( |
239 ChromeUtilityHostMsg_GetPrinterCapsAndDefaults_Succeeded, | 241 ChromeUtilityHostMsg_GetPrinterCapsAndDefaults_Succeeded, |
240 OnGetPrinterCapsAndDefaultsSucceeded) | 242 OnGetPrinterCapsAndDefaultsSucceeded) |
241 IPC_MESSAGE_HANDLER(ChromeUtilityHostMsg_GetPrinterCapsAndDefaults_Failed, | 243 IPC_MESSAGE_HANDLER(ChromeUtilityHostMsg_GetPrinterCapsAndDefaults_Failed, |
242 OnGetPrinterCapsAndDefaultsFailed) | 244 OnGetPrinterCapsAndDefaultsFailed) |
243 IPC_MESSAGE_HANDLER( | 245 IPC_MESSAGE_HANDLER( |
244 ChromeUtilityHostMsg_GetPrinterSemanticCapsAndDefaults_Succeeded, | 246 ChromeUtilityHostMsg_GetPrinterSemanticCapsAndDefaults_Succeeded, |
245 OnGetPrinterSemanticCapsAndDefaultsSucceeded) | 247 OnGetPrinterSemanticCapsAndDefaultsSucceeded) |
246 IPC_MESSAGE_HANDLER( | 248 IPC_MESSAGE_HANDLER( |
247 ChromeUtilityHostMsg_GetPrinterSemanticCapsAndDefaults_Failed, | 249 ChromeUtilityHostMsg_GetPrinterSemanticCapsAndDefaults_Failed, |
248 OnGetPrinterSemanticCapsAndDefaultsFailed) | 250 OnGetPrinterSemanticCapsAndDefaultsFailed) |
249 IPC_MESSAGE_UNHANDLED(handled = false) | 251 IPC_MESSAGE_UNHANDLED(handled = false) |
250 IPC_END_MESSAGE_MAP() | 252 IPC_END_MESSAGE_MAP() |
251 return handled; | 253 return handled; |
252 } | 254 } |
253 | 255 |
254 base::ProcessHandle ServiceUtilityProcessHost::GetHandle() const { | 256 base::ProcessHandle ServiceUtilityProcessHost::GetHandle() const { |
255 return handle_; | 257 return handle_; |
256 } | 258 } |
257 | 259 |
| 260 #if defined(WIN_PDF_METAFILE_FOR_PRINTING) |
258 void ServiceUtilityProcessHost::OnRenderPDFPagesToMetafilesSucceeded( | 261 void ServiceUtilityProcessHost::OnRenderPDFPagesToMetafilesSucceeded( |
259 const std::vector<printing::PageRange>& page_ranges, | 262 const std::vector<printing::PageRange>& page_ranges, |
260 double scale_factor) { | 263 double scale_factor) { |
261 UMA_HISTOGRAM_ENUMERATION("CloudPrint.ServiceUtilityProcessHostEvent", | 264 UMA_HISTOGRAM_ENUMERATION("CloudPrint.ServiceUtilityProcessHostEvent", |
262 SERVICE_UTILITY_METAFILE_SUCCEEDED, | 265 SERVICE_UTILITY_METAFILE_SUCCEEDED, |
263 SERVICE_UTILITY_EVENT_MAX); | 266 SERVICE_UTILITY_EVENT_MAX); |
264 UMA_HISTOGRAM_TIMES("CloudPrint.ServiceUtilityMetafileTime", | 267 UMA_HISTOGRAM_TIMES("CloudPrint.ServiceUtilityMetafileTime", |
265 base::Time::Now() - start_time_); | 268 base::Time::Now() - start_time_); |
266 DCHECK(waiting_for_reply_); | 269 DCHECK(waiting_for_reply_); |
267 waiting_for_reply_ = false; | 270 waiting_for_reply_ = false; |
(...skipping 23 matching lines...) Expand all Loading... |
291 UMA_HISTOGRAM_ENUMERATION("CloudPrint.ServiceUtilityProcessHostEvent", | 294 UMA_HISTOGRAM_ENUMERATION("CloudPrint.ServiceUtilityProcessHostEvent", |
292 SERVICE_UTILITY_METAFILE_FAILED, | 295 SERVICE_UTILITY_METAFILE_FAILED, |
293 SERVICE_UTILITY_EVENT_MAX); | 296 SERVICE_UTILITY_EVENT_MAX); |
294 UMA_HISTOGRAM_TIMES("CloudPrint.ServiceUtilityMetafileFailTime", | 297 UMA_HISTOGRAM_TIMES("CloudPrint.ServiceUtilityMetafileFailTime", |
295 base::Time::Now() - start_time_); | 298 base::Time::Now() - start_time_); |
296 waiting_for_reply_ = false; | 299 waiting_for_reply_ = false; |
297 client_message_loop_proxy_->PostTask( | 300 client_message_loop_proxy_->PostTask( |
298 FROM_HERE, | 301 FROM_HERE, |
299 base::Bind(&Client::OnRenderPDFPagesToMetafileFailed, client_.get())); | 302 base::Bind(&Client::OnRenderPDFPagesToMetafileFailed, client_.get())); |
300 } | 303 } |
| 304 #endif // defined(WIN_PDF_METAFILE_FOR_PRINTING) |
301 | 305 |
302 void ServiceUtilityProcessHost::OnGetPrinterCapsAndDefaultsSucceeded( | 306 void ServiceUtilityProcessHost::OnGetPrinterCapsAndDefaultsSucceeded( |
303 const std::string& printer_name, | 307 const std::string& printer_name, |
304 const printing::PrinterCapsAndDefaults& caps_and_defaults) { | 308 const printing::PrinterCapsAndDefaults& caps_and_defaults) { |
305 DCHECK(waiting_for_reply_); | 309 DCHECK(waiting_for_reply_); |
306 UMA_HISTOGRAM_ENUMERATION("CloudPrint.ServiceUtilityProcessHostEvent", | 310 UMA_HISTOGRAM_ENUMERATION("CloudPrint.ServiceUtilityProcessHostEvent", |
307 SERVICE_UTILITY_CAPS_SUCCEEDED, | 311 SERVICE_UTILITY_CAPS_SUCCEEDED, |
308 SERVICE_UTILITY_EVENT_MAX); | 312 SERVICE_UTILITY_EVENT_MAX); |
309 UMA_HISTOGRAM_TIMES("CloudPrint.ServiceUtilityCapsTime", | 313 UMA_HISTOGRAM_TIMES("CloudPrint.ServiceUtilityCapsTime", |
310 base::Time::Now() - start_time_); | 314 base::Time::Now() - start_time_); |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
379 if (!metafile.InitFromFile(metafile_path)) { | 383 if (!metafile.InitFromFile(metafile_path)) { |
380 OnRenderPDFPagesToMetafileFailed(); | 384 OnRenderPDFPagesToMetafileFailed(); |
381 } else { | 385 } else { |
382 OnRenderPDFPagesToMetafileSucceeded(metafile, | 386 OnRenderPDFPagesToMetafileSucceeded(metafile, |
383 highest_rendered_page_number, | 387 highest_rendered_page_number, |
384 scale_factor); | 388 scale_factor); |
385 } | 389 } |
386 #endif // defined(OS_WIN) | 390 #endif // defined(OS_WIN) |
387 } | 391 } |
388 | 392 |
OLD | NEW |