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/files/file_util.h" | 9 #include "base/files/file_util.h" |
10 #include "base/files/scoped_temp_dir.h" | 10 #include "base/files/scoped_temp_dir.h" |
(...skipping 212 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 #if defined(OS_WIN) |
234 IPC_MESSAGE_HANDLER( | 234 IPC_MESSAGE_HANDLER( |
235 ChromeUtilityHostMsg_RenderPDFPagesToMetafiles_Succeeded, | 235 ChromeUtilityHostMsg_RenderPDFPagesToMetafiles_Succeeded, |
236 OnRenderPDFPagesToMetafilesSucceeded) | 236 OnRenderPDFPagesToMetafilesSucceeded) |
237 IPC_MESSAGE_HANDLER(ChromeUtilityHostMsg_RenderPDFPagesToMetafile_Failed, | 237 IPC_MESSAGE_HANDLER(ChromeUtilityHostMsg_RenderPDFPagesToMetafile_Failed, |
238 OnRenderPDFPagesToMetafileFailed) | 238 OnRenderPDFPagesToMetafileFailed) |
239 #endif | 239 #endif |
240 IPC_MESSAGE_HANDLER( | 240 IPC_MESSAGE_HANDLER( |
241 ChromeUtilityHostMsg_GetPrinterCapsAndDefaults_Succeeded, | 241 ChromeUtilityHostMsg_GetPrinterCapsAndDefaults_Succeeded, |
242 OnGetPrinterCapsAndDefaultsSucceeded) | 242 OnGetPrinterCapsAndDefaultsSucceeded) |
243 IPC_MESSAGE_HANDLER(ChromeUtilityHostMsg_GetPrinterCapsAndDefaults_Failed, | 243 IPC_MESSAGE_HANDLER(ChromeUtilityHostMsg_GetPrinterCapsAndDefaults_Failed, |
244 OnGetPrinterCapsAndDefaultsFailed) | 244 OnGetPrinterCapsAndDefaultsFailed) |
245 IPC_MESSAGE_HANDLER( | 245 IPC_MESSAGE_HANDLER( |
246 ChromeUtilityHostMsg_GetPrinterSemanticCapsAndDefaults_Succeeded, | 246 ChromeUtilityHostMsg_GetPrinterSemanticCapsAndDefaults_Succeeded, |
247 OnGetPrinterSemanticCapsAndDefaultsSucceeded) | 247 OnGetPrinterSemanticCapsAndDefaultsSucceeded) |
248 IPC_MESSAGE_HANDLER( | 248 IPC_MESSAGE_HANDLER( |
249 ChromeUtilityHostMsg_GetPrinterSemanticCapsAndDefaults_Failed, | 249 ChromeUtilityHostMsg_GetPrinterSemanticCapsAndDefaults_Failed, |
250 OnGetPrinterSemanticCapsAndDefaultsFailed) | 250 OnGetPrinterSemanticCapsAndDefaultsFailed) |
251 IPC_MESSAGE_UNHANDLED(handled = false) | 251 IPC_MESSAGE_UNHANDLED(handled = false) |
252 IPC_END_MESSAGE_MAP() | 252 IPC_END_MESSAGE_MAP() |
253 return handled; | 253 return handled; |
254 } | 254 } |
255 | 255 |
256 base::ProcessHandle ServiceUtilityProcessHost::GetHandle() const { | 256 base::ProcessHandle ServiceUtilityProcessHost::GetHandle() const { |
257 return handle_; | 257 return handle_; |
258 } | 258 } |
259 | 259 |
260 #if defined(WIN_PDF_METAFILE_FOR_PRINTING) | 260 #if defined(OS_WIN) |
261 void ServiceUtilityProcessHost::OnRenderPDFPagesToMetafilesSucceeded( | 261 void ServiceUtilityProcessHost::OnRenderPDFPagesToMetafilesSucceeded( |
262 const std::vector<printing::PageRange>& page_ranges, | 262 const std::vector<printing::PageRange>& page_ranges, |
263 double scale_factor) { | 263 double scale_factor) { |
264 UMA_HISTOGRAM_ENUMERATION("CloudPrint.ServiceUtilityProcessHostEvent", | 264 UMA_HISTOGRAM_ENUMERATION("CloudPrint.ServiceUtilityProcessHostEvent", |
265 SERVICE_UTILITY_METAFILE_SUCCEEDED, | 265 SERVICE_UTILITY_METAFILE_SUCCEEDED, |
266 SERVICE_UTILITY_EVENT_MAX); | 266 SERVICE_UTILITY_EVENT_MAX); |
267 UMA_HISTOGRAM_TIMES("CloudPrint.ServiceUtilityMetafileTime", | 267 UMA_HISTOGRAM_TIMES("CloudPrint.ServiceUtilityMetafileTime", |
268 base::Time::Now() - start_time_); | 268 base::Time::Now() - start_time_); |
269 DCHECK(waiting_for_reply_); | 269 DCHECK(waiting_for_reply_); |
270 waiting_for_reply_ = false; | 270 waiting_for_reply_ = false; |
(...skipping 23 matching lines...) Expand all Loading... |
294 UMA_HISTOGRAM_ENUMERATION("CloudPrint.ServiceUtilityProcessHostEvent", | 294 UMA_HISTOGRAM_ENUMERATION("CloudPrint.ServiceUtilityProcessHostEvent", |
295 SERVICE_UTILITY_METAFILE_FAILED, | 295 SERVICE_UTILITY_METAFILE_FAILED, |
296 SERVICE_UTILITY_EVENT_MAX); | 296 SERVICE_UTILITY_EVENT_MAX); |
297 UMA_HISTOGRAM_TIMES("CloudPrint.ServiceUtilityMetafileFailTime", | 297 UMA_HISTOGRAM_TIMES("CloudPrint.ServiceUtilityMetafileFailTime", |
298 base::Time::Now() - start_time_); | 298 base::Time::Now() - start_time_); |
299 waiting_for_reply_ = false; | 299 waiting_for_reply_ = false; |
300 client_message_loop_proxy_->PostTask( | 300 client_message_loop_proxy_->PostTask( |
301 FROM_HERE, | 301 FROM_HERE, |
302 base::Bind(&Client::OnRenderPDFPagesToMetafileFailed, client_.get())); | 302 base::Bind(&Client::OnRenderPDFPagesToMetafileFailed, client_.get())); |
303 } | 303 } |
304 #endif // defined(WIN_PDF_METAFILE_FOR_PRINTING) | 304 #endif // defined(OS_WIN) |
305 | 305 |
306 void ServiceUtilityProcessHost::OnGetPrinterCapsAndDefaultsSucceeded( | 306 void ServiceUtilityProcessHost::OnGetPrinterCapsAndDefaultsSucceeded( |
307 const std::string& printer_name, | 307 const std::string& printer_name, |
308 const printing::PrinterCapsAndDefaults& caps_and_defaults) { | 308 const printing::PrinterCapsAndDefaults& caps_and_defaults) { |
309 DCHECK(waiting_for_reply_); | 309 DCHECK(waiting_for_reply_); |
310 UMA_HISTOGRAM_ENUMERATION("CloudPrint.ServiceUtilityProcessHostEvent", | 310 UMA_HISTOGRAM_ENUMERATION("CloudPrint.ServiceUtilityProcessHostEvent", |
311 SERVICE_UTILITY_CAPS_SUCCEEDED, | 311 SERVICE_UTILITY_CAPS_SUCCEEDED, |
312 SERVICE_UTILITY_EVENT_MAX); | 312 SERVICE_UTILITY_EVENT_MAX); |
313 UMA_HISTOGRAM_TIMES("CloudPrint.ServiceUtilityCapsTime", | 313 UMA_HISTOGRAM_TIMES("CloudPrint.ServiceUtilityCapsTime", |
314 base::Time::Now() - start_time_); | 314 base::Time::Now() - start_time_); |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
383 if (!metafile.InitFromFile(metafile_path)) { | 383 if (!metafile.InitFromFile(metafile_path)) { |
384 OnRenderPDFPagesToMetafileFailed(); | 384 OnRenderPDFPagesToMetafileFailed(); |
385 } else { | 385 } else { |
386 OnRenderPDFPagesToMetafileSucceeded(metafile, | 386 OnRenderPDFPagesToMetafileSucceeded(metafile, |
387 highest_rendered_page_number, | 387 highest_rendered_page_number, |
388 scale_factor); | 388 scale_factor); |
389 } | 389 } |
390 #endif // defined(OS_WIN) | 390 #endif // defined(OS_WIN) |
391 } | 391 } |
392 | 392 |
OLD | NEW |