Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(534)

Side by Side Diff: chrome/service/service_utility_process_host.cc

Issue 2706943003: Remove some unused cloud print histograms. (Closed)
Patch Set: Remove some unused cloud print histograms. Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/service/service_utility_process_host.h ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <stdint.h> 7 #include <stdint.h>
8 8
9 #include <queue> 9 #include <queue>
10 #include <utility> 10 #include <utility>
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 175
176 ServiceUtilityProcessHost::~ServiceUtilityProcessHost() { 176 ServiceUtilityProcessHost::~ServiceUtilityProcessHost() {
177 // We need to kill the child process when the host dies. 177 // We need to kill the child process when the host dies.
178 process_.Terminate(content::RESULT_CODE_NORMAL_EXIT, false); 178 process_.Terminate(content::RESULT_CODE_NORMAL_EXIT, false);
179 } 179 }
180 180
181 bool ServiceUtilityProcessHost::StartRenderPDFPagesToMetafile( 181 bool ServiceUtilityProcessHost::StartRenderPDFPagesToMetafile(
182 const base::FilePath& pdf_path, 182 const base::FilePath& pdf_path,
183 const printing::PdfRenderSettings& render_settings) { 183 const printing::PdfRenderSettings& render_settings) {
184 ReportUmaEvent(SERVICE_UTILITY_METAFILE_REQUEST); 184 ReportUmaEvent(SERVICE_UTILITY_METAFILE_REQUEST);
185 start_time_ = base::Time::Now();
186 base::File pdf_file(pdf_path, base::File::FLAG_OPEN | base::File::FLAG_READ | 185 base::File pdf_file(pdf_path, base::File::FLAG_OPEN | base::File::FLAG_READ |
187 base::File::FLAG_DELETE_ON_CLOSE); 186 base::File::FLAG_DELETE_ON_CLOSE);
188 if (!pdf_file.IsValid() || !StartProcess(false)) 187 if (!pdf_file.IsValid() || !StartProcess(false))
189 return false; 188 return false;
190 189
191 DCHECK(!waiting_for_reply_); 190 DCHECK(!waiting_for_reply_);
192 waiting_for_reply_ = true; 191 waiting_for_reply_ = true;
193 192
194 pdf_to_emf_state_.reset(new PdfToEmfState(this)); 193 pdf_to_emf_state_.reset(new PdfToEmfState(this));
195 return pdf_to_emf_state_->Start(std::move(pdf_file), render_settings); 194 return pdf_to_emf_state_->Start(std::move(pdf_file), render_settings);
196 } 195 }
197 196
198 bool ServiceUtilityProcessHost::StartGetPrinterCapsAndDefaults( 197 bool ServiceUtilityProcessHost::StartGetPrinterCapsAndDefaults(
199 const std::string& printer_name) { 198 const std::string& printer_name) {
200 ReportUmaEvent(SERVICE_UTILITY_CAPS_REQUEST); 199 ReportUmaEvent(SERVICE_UTILITY_CAPS_REQUEST);
201 start_time_ = base::Time::Now();
202 if (!StartProcess(true)) 200 if (!StartProcess(true))
203 return false; 201 return false;
204 DCHECK(!waiting_for_reply_); 202 DCHECK(!waiting_for_reply_);
205 waiting_for_reply_ = true; 203 waiting_for_reply_ = true;
206 return Send(new ChromeUtilityMsg_GetPrinterCapsAndDefaults(printer_name)); 204 return Send(new ChromeUtilityMsg_GetPrinterCapsAndDefaults(printer_name));
207 } 205 }
208 206
209 bool ServiceUtilityProcessHost::StartGetPrinterSemanticCapsAndDefaults( 207 bool ServiceUtilityProcessHost::StartGetPrinterSemanticCapsAndDefaults(
210 const std::string& printer_name) { 208 const std::string& printer_name) {
211 ReportUmaEvent(SERVICE_UTILITY_SEMANTIC_CAPS_REQUEST); 209 ReportUmaEvent(SERVICE_UTILITY_SEMANTIC_CAPS_REQUEST);
212 start_time_ = base::Time::Now();
213 if (!StartProcess(true)) 210 if (!StartProcess(true))
214 return false; 211 return false;
215 DCHECK(!waiting_for_reply_); 212 DCHECK(!waiting_for_reply_);
216 waiting_for_reply_ = true; 213 waiting_for_reply_ = true;
217 return Send( 214 return Send(
218 new ChromeUtilityMsg_GetPrinterSemanticCapsAndDefaults(printer_name)); 215 new ChromeUtilityMsg_GetPrinterSemanticCapsAndDefaults(printer_name));
219 } 216 }
220 217
221 bool ServiceUtilityProcessHost::StartProcess(bool no_sandbox) { 218 bool ServiceUtilityProcessHost::StartProcess(bool no_sandbox) {
222 std::string mojo_channel_token = 219 std::string mojo_channel_token =
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
294 return ChildProcessHost::GetChildPath(ChildProcessHost::CHILD_NORMAL); 291 return ChildProcessHost::GetChildPath(ChildProcessHost::CHILD_NORMAL);
295 } 292 }
296 293
297 void ServiceUtilityProcessHost::OnChildDisconnected() { 294 void ServiceUtilityProcessHost::OnChildDisconnected() {
298 if (waiting_for_reply_) { 295 if (waiting_for_reply_) {
299 // If we are yet to receive a reply then notify the client that the 296 // If we are yet to receive a reply then notify the client that the
300 // child died. 297 // child died.
301 client_task_runner_->PostTask( 298 client_task_runner_->PostTask(
302 FROM_HERE, base::Bind(&Client::OnChildDied, client_.get())); 299 FROM_HERE, base::Bind(&Client::OnChildDied, client_.get()));
303 ReportUmaEvent(SERVICE_UTILITY_DISCONNECTED); 300 ReportUmaEvent(SERVICE_UTILITY_DISCONNECTED);
304 UMA_HISTOGRAM_TIMES("CloudPrint.ServiceUtilityDisconnectTime",
305 base::Time::Now() - start_time_);
306 } 301 }
307 delete this; 302 delete this;
308 } 303 }
309 304
310 bool ServiceUtilityProcessHost::OnMessageReceived(const IPC::Message& message) { 305 bool ServiceUtilityProcessHost::OnMessageReceived(const IPC::Message& message) {
311 bool handled = true; 306 bool handled = true;
312 IPC_BEGIN_MESSAGE_MAP(ServiceUtilityProcessHost, message) 307 IPC_BEGIN_MESSAGE_MAP(ServiceUtilityProcessHost, message)
313 IPC_MESSAGE_HANDLER( 308 IPC_MESSAGE_HANDLER(
314 ChromeUtilityHostMsg_RenderPDFPagesToMetafiles_PageCount, 309 ChromeUtilityHostMsg_RenderPDFPagesToMetafiles_PageCount,
315 OnRenderPDFPagesToMetafilesPageCount) 310 OnRenderPDFPagesToMetafilesPageCount)
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
365 base::Bind(&ServiceUtilityProcessHost::OnMetafileSpooled, 360 base::Bind(&ServiceUtilityProcessHost::OnMetafileSpooled,
366 weak_ptr_factory_.GetWeakPtr())); 361 weak_ptr_factory_.GetWeakPtr()));
367 } 362 }
368 363
369 void ServiceUtilityProcessHost::OnPDFToEmfFinished(bool success) { 364 void ServiceUtilityProcessHost::OnPDFToEmfFinished(bool success) {
370 if (!waiting_for_reply_) 365 if (!waiting_for_reply_)
371 return; 366 return;
372 waiting_for_reply_ = false; 367 waiting_for_reply_ = false;
373 if (success) { 368 if (success) {
374 ReportUmaEvent(SERVICE_UTILITY_METAFILE_SUCCEEDED); 369 ReportUmaEvent(SERVICE_UTILITY_METAFILE_SUCCEEDED);
375 UMA_HISTOGRAM_TIMES("CloudPrint.ServiceUtilityMetafileTime",
376 base::Time::Now() - start_time_);
377 } else { 370 } else {
378 ReportUmaEvent(SERVICE_UTILITY_METAFILE_FAILED); 371 ReportUmaEvent(SERVICE_UTILITY_METAFILE_FAILED);
379 UMA_HISTOGRAM_TIMES("CloudPrint.ServiceUtilityMetafileFailTime",
380 base::Time::Now() - start_time_);
381 } 372 }
382 client_task_runner_->PostTask( 373 client_task_runner_->PostTask(
383 FROM_HERE, base::Bind(&Client::OnRenderPDFPagesToMetafileDone, 374 FROM_HERE, base::Bind(&Client::OnRenderPDFPagesToMetafileDone,
384 client_.get(), success)); 375 client_.get(), success));
385 pdf_to_emf_state_.reset(); 376 pdf_to_emf_state_.reset();
386 } 377 }
387 378
388 void ServiceUtilityProcessHost::OnGetPrinterCapsAndDefaultsSucceeded( 379 void ServiceUtilityProcessHost::OnGetPrinterCapsAndDefaultsSucceeded(
389 const std::string& printer_name, 380 const std::string& printer_name,
390 const printing::PrinterCapsAndDefaults& caps_and_defaults) { 381 const printing::PrinterCapsAndDefaults& caps_and_defaults) {
391 DCHECK(waiting_for_reply_); 382 DCHECK(waiting_for_reply_);
392 ReportUmaEvent(SERVICE_UTILITY_CAPS_SUCCEEDED); 383 ReportUmaEvent(SERVICE_UTILITY_CAPS_SUCCEEDED);
393 UMA_HISTOGRAM_TIMES("CloudPrint.ServiceUtilityCapsTime",
394 base::Time::Now() - start_time_);
395 waiting_for_reply_ = false; 384 waiting_for_reply_ = false;
396 client_task_runner_->PostTask( 385 client_task_runner_->PostTask(
397 FROM_HERE, base::Bind(&Client::OnGetPrinterCapsAndDefaults, client_.get(), 386 FROM_HERE, base::Bind(&Client::OnGetPrinterCapsAndDefaults, client_.get(),
398 true, printer_name, caps_and_defaults)); 387 true, printer_name, caps_and_defaults));
399 } 388 }
400 389
401 void ServiceUtilityProcessHost::OnGetPrinterSemanticCapsAndDefaultsSucceeded( 390 void ServiceUtilityProcessHost::OnGetPrinterSemanticCapsAndDefaultsSucceeded(
402 const std::string& printer_name, 391 const std::string& printer_name,
403 const printing::PrinterSemanticCapsAndDefaults& caps_and_defaults) { 392 const printing::PrinterSemanticCapsAndDefaults& caps_and_defaults) {
404 DCHECK(waiting_for_reply_); 393 DCHECK(waiting_for_reply_);
405 ReportUmaEvent(SERVICE_UTILITY_SEMANTIC_CAPS_SUCCEEDED); 394 ReportUmaEvent(SERVICE_UTILITY_SEMANTIC_CAPS_SUCCEEDED);
406 UMA_HISTOGRAM_TIMES("CloudPrint.ServiceUtilitySemanticCapsTime",
407 base::Time::Now() - start_time_);
408 waiting_for_reply_ = false; 395 waiting_for_reply_ = false;
409 client_task_runner_->PostTask( 396 client_task_runner_->PostTask(
410 FROM_HERE, 397 FROM_HERE,
411 base::Bind(&Client::OnGetPrinterSemanticCapsAndDefaults, client_.get(), 398 base::Bind(&Client::OnGetPrinterSemanticCapsAndDefaults, client_.get(),
412 true, printer_name, caps_and_defaults)); 399 true, printer_name, caps_and_defaults));
413 } 400 }
414 401
415 void ServiceUtilityProcessHost::OnGetPrinterCapsAndDefaultsFailed( 402 void ServiceUtilityProcessHost::OnGetPrinterCapsAndDefaultsFailed(
416 const std::string& printer_name) { 403 const std::string& printer_name) {
417 DCHECK(waiting_for_reply_); 404 DCHECK(waiting_for_reply_);
418 ReportUmaEvent(SERVICE_UTILITY_CAPS_FAILED); 405 ReportUmaEvent(SERVICE_UTILITY_CAPS_FAILED);
419 UMA_HISTOGRAM_TIMES("CloudPrint.ServiceUtilityCapsFailTime",
420 base::Time::Now() - start_time_);
421 waiting_for_reply_ = false; 406 waiting_for_reply_ = false;
422 client_task_runner_->PostTask( 407 client_task_runner_->PostTask(
423 FROM_HERE, 408 FROM_HERE,
424 base::Bind(&Client::OnGetPrinterCapsAndDefaults, client_.get(), false, 409 base::Bind(&Client::OnGetPrinterCapsAndDefaults, client_.get(), false,
425 printer_name, printing::PrinterCapsAndDefaults())); 410 printer_name, printing::PrinterCapsAndDefaults()));
426 } 411 }
427 412
428 void ServiceUtilityProcessHost::OnGetPrinterSemanticCapsAndDefaultsFailed( 413 void ServiceUtilityProcessHost::OnGetPrinterSemanticCapsAndDefaultsFailed(
429 const std::string& printer_name) { 414 const std::string& printer_name) {
430 DCHECK(waiting_for_reply_); 415 DCHECK(waiting_for_reply_);
431 ReportUmaEvent(SERVICE_UTILITY_SEMANTIC_CAPS_FAILED); 416 ReportUmaEvent(SERVICE_UTILITY_SEMANTIC_CAPS_FAILED);
432 UMA_HISTOGRAM_TIMES("CloudPrint.ServiceUtilitySemanticCapsFailTime",
433 base::Time::Now() - start_time_);
434 waiting_for_reply_ = false; 417 waiting_for_reply_ = false;
435 client_task_runner_->PostTask( 418 client_task_runner_->PostTask(
436 FROM_HERE, base::Bind(&Client::OnGetPrinterSemanticCapsAndDefaults, 419 FROM_HERE, base::Bind(&Client::OnGetPrinterSemanticCapsAndDefaults,
437 client_.get(), false, printer_name, 420 client_.get(), false, printer_name,
438 printing::PrinterSemanticCapsAndDefaults())); 421 printing::PrinterSemanticCapsAndDefaults()));
439 } 422 }
440 423
441 bool ServiceUtilityProcessHost::Client::MetafileAvailable(float scale_factor, 424 bool ServiceUtilityProcessHost::Client::MetafileAvailable(float scale_factor,
442 base::File file) { 425 base::File file) {
443 file.Seek(base::File::FROM_BEGIN, 0); 426 file.Seek(base::File::FROM_BEGIN, 0);
444 int64_t size = file.GetLength(); 427 int64_t size = file.GetLength();
445 if (size <= 0) { 428 if (size <= 0) {
446 OnRenderPDFPagesToMetafileDone(false); 429 OnRenderPDFPagesToMetafileDone(false);
447 return false; 430 return false;
448 } 431 }
449 std::vector<char> data(size); 432 std::vector<char> data(size);
450 if (file.ReadAtCurrentPos(data.data(), data.size()) != size) { 433 if (file.ReadAtCurrentPos(data.data(), data.size()) != size) {
451 OnRenderPDFPagesToMetafileDone(false); 434 OnRenderPDFPagesToMetafileDone(false);
452 return false; 435 return false;
453 } 436 }
454 printing::Emf emf; 437 printing::Emf emf;
455 if (!emf.InitFromData(data.data(), data.size())) { 438 if (!emf.InitFromData(data.data(), data.size())) {
456 OnRenderPDFPagesToMetafileDone(false); 439 OnRenderPDFPagesToMetafileDone(false);
457 return false; 440 return false;
458 } 441 }
459 OnRenderPDFPagesToMetafilePageDone(scale_factor, emf); 442 OnRenderPDFPagesToMetafilePageDone(scale_factor, emf);
460 return true; 443 return true;
461 } 444 }
OLDNEW
« no previous file with comments | « chrome/service/service_utility_process_host.h ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698