OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/cloud_print/printer_job_handler.h" | 5 #include "chrome/service/cloud_print/printer_job_handler.h" |
6 | 6 |
| 7 #include "base/bind.h" |
7 #include "base/file_util.h" | 8 #include "base/file_util.h" |
8 #include "base/json/json_reader.h" | 9 #include "base/json/json_reader.h" |
9 #include "base/md5.h" | 10 #include "base/md5.h" |
10 #include "base/stringprintf.h" | 11 #include "base/stringprintf.h" |
11 #include "base/utf_string_conversions.h" | 12 #include "base/utf_string_conversions.h" |
12 #include "base/values.h" | 13 #include "base/values.h" |
13 #include "chrome/common/net/http_return.h" | 14 #include "chrome/common/net/http_return.h" |
14 #include "chrome/service/cloud_print/cloud_print_consts.h" | 15 #include "chrome/service/cloud_print/cloud_print_consts.h" |
15 #include "chrome/service/cloud_print/cloud_print_helpers.h" | 16 #include "chrome/service/cloud_print/cloud_print_helpers.h" |
16 #include "chrome/service/cloud_print/job_status_updater.h" | 17 #include "chrome/service/cloud_print/job_status_updater.h" |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 } | 122 } |
122 } | 123 } |
123 | 124 |
124 void PrinterJobHandler::Stop() { | 125 void PrinterJobHandler::Stop() { |
125 VLOG(1) << "CP_CONNECTOR: Stop printer job handler, id: " | 126 VLOG(1) << "CP_CONNECTOR: Stop printer job handler, id: " |
126 << printer_info_cloud_.printer_id; | 127 << printer_info_cloud_.printer_id; |
127 task_in_progress_ = false; | 128 task_in_progress_ = false; |
128 Reset(); | 129 Reset(); |
129 if (HavePendingTasks()) { | 130 if (HavePendingTasks()) { |
130 MessageLoop::current()->PostTask( | 131 MessageLoop::current()->PostTask( |
131 FROM_HERE, NewRunnableMethod(this, &PrinterJobHandler::Start)); | 132 FROM_HERE, base::Bind(&PrinterJobHandler::Start, this)); |
132 } | 133 } |
133 } | 134 } |
134 | 135 |
135 void PrinterJobHandler::CheckForJobs(const std::string& reason) { | 136 void PrinterJobHandler::CheckForJobs(const std::string& reason) { |
136 VLOG(1) << "CP_CONNECTOR: CheckForJobs, id: " | 137 VLOG(1) << "CP_CONNECTOR: CheckForJobs, id: " |
137 << printer_info_cloud_.printer_id | 138 << printer_info_cloud_.printer_id |
138 << ", reason: " << reason | 139 << ", reason: " << reason |
139 << ", task in progress: " << task_in_progress_; | 140 << ", task in progress: " << task_in_progress_; |
140 job_fetch_reason_ = reason; | 141 job_fetch_reason_ = reason; |
141 job_check_pending_ = true; | 142 job_check_pending_ = true; |
142 if (!task_in_progress_) { | 143 if (!task_in_progress_) { |
143 MessageLoop::current()->PostTask( | 144 MessageLoop::current()->PostTask( |
144 FROM_HERE, NewRunnableMethod(this, &PrinterJobHandler::Start)); | 145 FROM_HERE, base::Bind(&PrinterJobHandler::Start, this)); |
145 } | 146 } |
146 } | 147 } |
147 | 148 |
148 bool PrinterJobHandler::UpdatePrinterInfo() { | 149 bool PrinterJobHandler::UpdatePrinterInfo() { |
149 if (!printer_watcher_) { | 150 if (!printer_watcher_) { |
150 LOG(ERROR) << "CP_CONNECTOR: Printer watcher is missing." | 151 LOG(ERROR) << "CP_CONNECTOR: Printer watcher is missing." |
151 << "Check printer server url for printer id: " | 152 << "Check printer server url for printer id: " |
152 << printer_info_cloud_.printer_id; | 153 << printer_info_cloud_.printer_id; |
153 return false; | 154 return false; |
154 } | 155 } |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
252 CloudPrintHelpers::GetUrlForPrinterUpdate( | 253 CloudPrintHelpers::GetUrlForPrinterUpdate( |
253 cloud_print_server_url_, printer_info_cloud_.printer_id), | 254 cloud_print_server_url_, printer_info_cloud_.printer_id), |
254 this, | 255 this, |
255 kCloudPrintAPIMaxRetryCount, | 256 kCloudPrintAPIMaxRetryCount, |
256 mime_type, | 257 mime_type, |
257 post_data, | 258 post_data, |
258 std::string()); | 259 std::string()); |
259 } else { | 260 } else { |
260 // We are done here. Go to the Stop state | 261 // We are done here. Go to the Stop state |
261 MessageLoop::current()->PostTask( | 262 MessageLoop::current()->PostTask( |
262 FROM_HERE, NewRunnableMethod(this, &PrinterJobHandler::Stop)); | 263 FROM_HERE, base::Bind(&PrinterJobHandler::Stop, this)); |
263 } | 264 } |
264 } | 265 } |
265 | 266 |
266 // CloudPrintURLFetcher::Delegate implementation. | 267 // CloudPrintURLFetcher::Delegate implementation. |
267 CloudPrintURLFetcher::ResponseAction PrinterJobHandler::HandleRawResponse( | 268 CloudPrintURLFetcher::ResponseAction PrinterJobHandler::HandleRawResponse( |
268 const content::URLFetcher* source, | 269 const content::URLFetcher* source, |
269 const GURL& url, | 270 const GURL& url, |
270 const net::URLRequestStatus& status, | 271 const net::URLRequestStatus& status, |
271 int response_code, | 272 int response_code, |
272 const net::ResponseCookies& cookies, | 273 const net::ResponseCookies& cookies, |
273 const std::string& data) { | 274 const std::string& data) { |
274 // 415 (Unsupported media type) error while fetching data from the server | 275 // 415 (Unsupported media type) error while fetching data from the server |
275 // means data conversion error. Stop fetching process and mark job as error. | 276 // means data conversion error. Stop fetching process and mark job as error. |
276 if (next_data_handler_ == (&PrinterJobHandler::HandlePrintDataResponse) && | 277 if (next_data_handler_ == (&PrinterJobHandler::HandlePrintDataResponse) && |
277 response_code == RC_UNSUPPORTED_MEDIA_TYPE) { | 278 response_code == RC_UNSUPPORTED_MEDIA_TYPE) { |
278 MessageLoop::current()->PostTask( | 279 MessageLoop::current()->PostTask( |
279 FROM_HERE, | 280 FROM_HERE, |
280 NewRunnableMethod(this, &PrinterJobHandler::JobFailed, | 281 base::Bind(&PrinterJobHandler::JobFailed, this, JOB_DOWNLOAD_FAILED)); |
281 JOB_DOWNLOAD_FAILED)); | |
282 return CloudPrintURLFetcher::STOP_PROCESSING; | 282 return CloudPrintURLFetcher::STOP_PROCESSING; |
283 } | 283 } |
284 return CloudPrintURLFetcher::CONTINUE_PROCESSING; | 284 return CloudPrintURLFetcher::CONTINUE_PROCESSING; |
285 } | 285 } |
286 | 286 |
287 CloudPrintURLFetcher::ResponseAction PrinterJobHandler::HandleRawData( | 287 CloudPrintURLFetcher::ResponseAction PrinterJobHandler::HandleRawData( |
288 const content::URLFetcher* source, | 288 const content::URLFetcher* source, |
289 const GURL& url, | 289 const GURL& url, |
290 const std::string& data) { | 290 const std::string& data) { |
291 if (!next_data_handler_) | 291 if (!next_data_handler_) |
(...skipping 10 matching lines...) Expand all Loading... |
302 return (this->*next_json_data_handler_)(source, url, json_data, succeeded); | 302 return (this->*next_json_data_handler_)(source, url, json_data, succeeded); |
303 } | 303 } |
304 | 304 |
305 void PrinterJobHandler::OnRequestGiveUp() { | 305 void PrinterJobHandler::OnRequestGiveUp() { |
306 // The only time we call CloudPrintURLFetcher::StartGetRequest() with a | 306 // The only time we call CloudPrintURLFetcher::StartGetRequest() with a |
307 // specified number of retries, is when we are trying to fetch print job | 307 // specified number of retries, is when we are trying to fetch print job |
308 // data. So, this function will be reached only if we failed to get job data. | 308 // data. So, this function will be reached only if we failed to get job data. |
309 // In that case, we should make job as error and should not try it later. | 309 // In that case, we should make job as error and should not try it later. |
310 MessageLoop::current()->PostTask( | 310 MessageLoop::current()->PostTask( |
311 FROM_HERE, | 311 FROM_HERE, |
312 NewRunnableMethod(this, &PrinterJobHandler::JobFailed, | 312 base::Bind(&PrinterJobHandler::JobFailed, this, JOB_DOWNLOAD_FAILED)); |
313 JOB_DOWNLOAD_FAILED)); | |
314 } | 313 } |
315 | 314 |
316 CloudPrintURLFetcher::ResponseAction PrinterJobHandler::OnRequestAuthError() { | 315 CloudPrintURLFetcher::ResponseAction PrinterJobHandler::OnRequestAuthError() { |
317 // TODO(gene): We might consider stop processing if we get auth error here. | 316 // TODO(gene): We might consider stop processing if we get auth error here. |
318 OnAuthError(); | 317 OnAuthError(); |
319 // Continue processing as a network error. | 318 // Continue processing as a network error. |
320 return CloudPrintURLFetcher::CONTINUE_PROCESSING; | 319 return CloudPrintURLFetcher::CONTINUE_PROCESSING; |
321 } | 320 } |
322 | 321 |
323 std::string PrinterJobHandler::GetAuthHeader() { | 322 std::string PrinterJobHandler::GetAuthHeader() { |
(...skipping 21 matching lines...) Expand all Loading... |
345 | 344 |
346 void PrinterJobHandler::OnPrinterDeleted() { | 345 void PrinterJobHandler::OnPrinterDeleted() { |
347 if (delegate_) | 346 if (delegate_) |
348 delegate_->OnPrinterDeleted(printer_info_cloud_.printer_id); | 347 delegate_->OnPrinterDeleted(printer_info_cloud_.printer_id); |
349 } | 348 } |
350 | 349 |
351 void PrinterJobHandler::OnPrinterChanged() { | 350 void PrinterJobHandler::OnPrinterChanged() { |
352 printer_update_pending_ = true; | 351 printer_update_pending_ = true; |
353 if (!task_in_progress_) { | 352 if (!task_in_progress_) { |
354 MessageLoop::current()->PostTask( | 353 MessageLoop::current()->PostTask( |
355 FROM_HERE, NewRunnableMethod(this, &PrinterJobHandler::Start)); | 354 FROM_HERE, base::Bind(&PrinterJobHandler::Start, this)); |
356 } | 355 } |
357 } | 356 } |
358 | 357 |
359 void PrinterJobHandler::OnJobChanged() { | 358 void PrinterJobHandler::OnJobChanged() { |
360 // Some job on the printer changed. Loop through all our JobStatusUpdaters | 359 // Some job on the printer changed. Loop through all our JobStatusUpdaters |
361 // and have them check for updates. | 360 // and have them check for updates. |
362 for (JobStatusUpdaterList::iterator index = job_status_updater_list_.begin(); | 361 for (JobStatusUpdaterList::iterator index = job_status_updater_list_.begin(); |
363 index != job_status_updater_list_.end(); index++) { | 362 index != job_status_updater_list_.end(); index++) { |
364 MessageLoop::current()->PostTask( | 363 MessageLoop::current()->PostTask( |
365 FROM_HERE, NewRunnableMethod(index->get(), | 364 FROM_HERE, base::Bind(&JobStatusUpdater::UpdateStatus, index->get())); |
366 &JobStatusUpdater::UpdateStatus)); | |
367 } | 365 } |
368 } | 366 } |
369 | 367 |
370 // Begin Response handlers | 368 // Begin Response handlers |
371 CloudPrintURLFetcher::ResponseAction | 369 CloudPrintURLFetcher::ResponseAction |
372 PrinterJobHandler::HandlePrinterUpdateResponse( | 370 PrinterJobHandler::HandlePrinterUpdateResponse( |
373 const content::URLFetcher* source, | 371 const content::URLFetcher* source, |
374 const GURL& url, | 372 const GURL& url, |
375 DictionaryValue* json_data, | 373 DictionaryValue* json_data, |
376 bool succeeded) { | 374 bool succeeded) { |
377 VLOG(1) << "CP_CONNECTOR: Handle printer update response, id: " | 375 VLOG(1) << "CP_CONNECTOR: Handle printer update response, id: " |
378 << printer_info_cloud_.printer_id; | 376 << printer_info_cloud_.printer_id; |
379 // We are done here. Go to the Stop state | 377 // We are done here. Go to the Stop state |
380 MessageLoop::current()->PostTask( | 378 MessageLoop::current()->PostTask( |
381 FROM_HERE, NewRunnableMethod(this, &PrinterJobHandler::Stop)); | 379 FROM_HERE, base::Bind(&PrinterJobHandler::Stop, this)); |
382 return CloudPrintURLFetcher::STOP_PROCESSING; | 380 return CloudPrintURLFetcher::STOP_PROCESSING; |
383 } | 381 } |
384 | 382 |
385 CloudPrintURLFetcher::ResponseAction | 383 CloudPrintURLFetcher::ResponseAction |
386 PrinterJobHandler::HandleJobMetadataResponse( | 384 PrinterJobHandler::HandleJobMetadataResponse( |
387 const content::URLFetcher* source, | 385 const content::URLFetcher* source, |
388 const GURL& url, | 386 const GURL& url, |
389 DictionaryValue* json_data, | 387 DictionaryValue* json_data, |
390 bool succeeded) { | 388 bool succeeded) { |
391 VLOG(1) << "CP_CONNECTOR: Handle job metadata response, id: " | 389 VLOG(1) << "CP_CONNECTOR: Handle job metadata response, id: " |
(...skipping 28 matching lines...) Expand all Loading... |
420 request_->StartGetRequest(GURL(print_ticket_url.c_str()), | 418 request_->StartGetRequest(GURL(print_ticket_url.c_str()), |
421 this, | 419 this, |
422 kCloudPrintAPIMaxRetryCount, | 420 kCloudPrintAPIMaxRetryCount, |
423 std::string()); | 421 std::string()); |
424 } | 422 } |
425 } | 423 } |
426 } | 424 } |
427 // If no jobs are available, go to the Stop state. | 425 // If no jobs are available, go to the Stop state. |
428 if (!job_available) | 426 if (!job_available) |
429 MessageLoop::current()->PostTask( | 427 MessageLoop::current()->PostTask( |
430 FROM_HERE, NewRunnableMethod(this, &PrinterJobHandler::Stop)); | 428 FROM_HERE, base::Bind(&PrinterJobHandler::Stop, this)); |
431 return CloudPrintURLFetcher::STOP_PROCESSING; | 429 return CloudPrintURLFetcher::STOP_PROCESSING; |
432 } | 430 } |
433 | 431 |
434 CloudPrintURLFetcher::ResponseAction | 432 CloudPrintURLFetcher::ResponseAction |
435 PrinterJobHandler::HandlePrintTicketResponse(const content::URLFetcher* source, | 433 PrinterJobHandler::HandlePrintTicketResponse(const content::URLFetcher* source, |
436 const GURL& url, | 434 const GURL& url, |
437 const std::string& data) { | 435 const std::string& data) { |
438 VLOG(1) << "CP_CONNECTOR: Handle print ticket response, id: " | 436 VLOG(1) << "CP_CONNECTOR: Handle print ticket response, id: " |
439 << printer_info_cloud_.printer_id; | 437 << printer_info_cloud_.printer_id; |
440 if (print_system_->ValidatePrintTicket(printer_info_.printer_name, data)) { | 438 if (print_system_->ValidatePrintTicket(printer_info_.printer_name, data)) { |
(...skipping 12 matching lines...) Expand all Loading... |
453 } | 451 } |
454 return CloudPrintURLFetcher::STOP_PROCESSING; | 452 return CloudPrintURLFetcher::STOP_PROCESSING; |
455 } | 453 } |
456 | 454 |
457 CloudPrintURLFetcher::ResponseAction | 455 CloudPrintURLFetcher::ResponseAction |
458 PrinterJobHandler::HandlePrintDataResponse(const content::URLFetcher* source, | 456 PrinterJobHandler::HandlePrintDataResponse(const content::URLFetcher* source, |
459 const GURL& url, | 457 const GURL& url, |
460 const std::string& data) { | 458 const std::string& data) { |
461 VLOG(1) << "CP_CONNECTOR: Handle print data response, id: " | 459 VLOG(1) << "CP_CONNECTOR: Handle print data response, id: " |
462 << printer_info_cloud_.printer_id; | 460 << printer_info_cloud_.printer_id; |
463 Task* next_task = NULL; | 461 base::Closure next_task; |
464 if (file_util::CreateTemporaryFile(&job_details_.print_data_file_path_)) { | 462 if (file_util::CreateTemporaryFile(&job_details_.print_data_file_path_)) { |
465 int ret = file_util::WriteFile(job_details_.print_data_file_path_, | 463 int ret = file_util::WriteFile(job_details_.print_data_file_path_, |
466 data.c_str(), | 464 data.c_str(), |
467 data.length()); | 465 data.length()); |
468 source->GetResponseHeaders()->GetMimeType( | 466 source->GetResponseHeaders()->GetMimeType( |
469 &job_details_.print_data_mime_type_); | 467 &job_details_.print_data_mime_type_); |
470 DCHECK(ret == static_cast<int>(data.length())); | 468 DCHECK(ret == static_cast<int>(data.length())); |
471 if (ret == static_cast<int>(data.length())) { | 469 if (ret == static_cast<int>(data.length())) { |
472 next_task = NewRunnableMethod(this, &PrinterJobHandler::StartPrinting); | 470 next_task = base::Bind(&PrinterJobHandler::StartPrinting, this); |
473 } | 471 } |
474 } | 472 } |
475 // If there was no task allocated above, then there was an error in | 473 // If there was no task allocated above, then there was an error in |
476 // saving the print data, bail out here. | 474 // saving the print data, bail out here. |
477 if (!next_task) { | 475 if (next_task.is_null()) { |
478 next_task = NewRunnableMethod(this, &PrinterJobHandler::JobFailed, | 476 next_task = base::Bind(&PrinterJobHandler::JobFailed, this, |
479 JOB_DOWNLOAD_FAILED); | 477 JOB_DOWNLOAD_FAILED); |
480 } | 478 } |
481 MessageLoop::current()->PostTask(FROM_HERE, next_task); | 479 MessageLoop::current()->PostTask(FROM_HERE, next_task); |
482 return CloudPrintURLFetcher::STOP_PROCESSING; | 480 return CloudPrintURLFetcher::STOP_PROCESSING; |
483 } | 481 } |
484 | 482 |
485 CloudPrintURLFetcher::ResponseAction | 483 CloudPrintURLFetcher::ResponseAction |
486 PrinterJobHandler::HandleSuccessStatusUpdateResponse( | 484 PrinterJobHandler::HandleSuccessStatusUpdateResponse( |
487 const content::URLFetcher* source, | 485 const content::URLFetcher* source, |
488 const GURL& url, | 486 const GURL& url, |
489 DictionaryValue* json_data, | 487 DictionaryValue* json_data, |
490 bool succeeded) { | 488 bool succeeded) { |
491 VLOG(1) << "CP_CONNECTOR: Handle success status update response, id: " | 489 VLOG(1) << "CP_CONNECTOR: Handle success status update response, id: " |
492 << printer_info_cloud_.printer_id; | 490 << printer_info_cloud_.printer_id; |
493 // The print job has been spooled locally. We now need to create an object | 491 // The print job has been spooled locally. We now need to create an object |
494 // that monitors the status of the job and updates the server. | 492 // that monitors the status of the job and updates the server. |
495 scoped_refptr<JobStatusUpdater> job_status_updater( | 493 scoped_refptr<JobStatusUpdater> job_status_updater( |
496 new JobStatusUpdater(printer_info_.printer_name, job_details_.job_id_, | 494 new JobStatusUpdater(printer_info_.printer_name, job_details_.job_id_, |
497 local_job_id_, cloud_print_server_url_, | 495 local_job_id_, cloud_print_server_url_, |
498 print_system_.get(), this)); | 496 print_system_.get(), this)); |
499 job_status_updater_list_.push_back(job_status_updater); | 497 job_status_updater_list_.push_back(job_status_updater); |
500 MessageLoop::current()->PostTask( | 498 MessageLoop::current()->PostTask( |
501 FROM_HERE, NewRunnableMethod(job_status_updater.get(), | 499 FROM_HERE, base::Bind(&JobStatusUpdater::UpdateStatus, |
502 &JobStatusUpdater::UpdateStatus)); | 500 job_status_updater.get())); |
503 if (succeeded) { | 501 if (succeeded) { |
504 // Since we just printed successfully, we want to look for more jobs. | 502 // Since we just printed successfully, we want to look for more jobs. |
505 CheckForJobs(kJobFetchReasonQueryMore); | 503 CheckForJobs(kJobFetchReasonQueryMore); |
506 } | 504 } |
507 MessageLoop::current()->PostTask( | 505 MessageLoop::current()->PostTask( |
508 FROM_HERE, NewRunnableMethod(this, &PrinterJobHandler::Stop)); | 506 FROM_HERE, base::Bind(&PrinterJobHandler::Stop, this)); |
509 return CloudPrintURLFetcher::STOP_PROCESSING; | 507 return CloudPrintURLFetcher::STOP_PROCESSING; |
510 } | 508 } |
511 | 509 |
512 CloudPrintURLFetcher::ResponseAction | 510 CloudPrintURLFetcher::ResponseAction |
513 PrinterJobHandler::HandleFailureStatusUpdateResponse( | 511 PrinterJobHandler::HandleFailureStatusUpdateResponse( |
514 const content::URLFetcher* source, | 512 const content::URLFetcher* source, |
515 const GURL& url, | 513 const GURL& url, |
516 DictionaryValue* json_data, | 514 DictionaryValue* json_data, |
517 bool succeeded) { | 515 bool succeeded) { |
518 VLOG(1) << "CP_CONNECTOR: Handle failure status update response, id: " | 516 VLOG(1) << "CP_CONNECTOR: Handle failure status update response, id: " |
519 << printer_info_cloud_.printer_id; | 517 << printer_info_cloud_.printer_id; |
520 MessageLoop::current()->PostTask( | 518 MessageLoop::current()->PostTask( |
521 FROM_HERE, NewRunnableMethod(this, &PrinterJobHandler::Stop)); | 519 FROM_HERE, base::Bind(&PrinterJobHandler::Stop, this)); |
522 return CloudPrintURLFetcher::STOP_PROCESSING; | 520 return CloudPrintURLFetcher::STOP_PROCESSING; |
523 } | 521 } |
524 // End Response handlers | 522 // End Response handlers |
525 | 523 |
526 void PrinterJobHandler::StartPrinting() { | 524 void PrinterJobHandler::StartPrinting() { |
527 VLOG(1) << "CP_CONNECTOR: Start printing, id: " | 525 VLOG(1) << "CP_CONNECTOR: Start printing, id: " |
528 << printer_info_cloud_.printer_id; | 526 << printer_info_cloud_.printer_id; |
529 // We are done with the request object for now. | 527 // We are done with the request object for now. |
530 request_ = NULL; | 528 request_ = NULL; |
531 if (!shutting_down_) { | 529 if (!shutting_down_) { |
532 if (!print_thread_.Start()) { | 530 if (!print_thread_.Start()) { |
533 JobFailed(PRINT_FAILED); | 531 JobFailed(PRINT_FAILED); |
534 } else { | 532 } else { |
535 print_thread_.message_loop()->PostTask( | 533 print_thread_.message_loop()->PostTask( |
536 FROM_HERE, NewRunnableMethod(this, &PrinterJobHandler::DoPrint, | 534 FROM_HERE, base::Bind(&PrinterJobHandler::DoPrint, this, job_details_, |
537 job_details_, | 535 printer_info_.printer_name)); |
538 printer_info_.printer_name)); | |
539 } | 536 } |
540 } | 537 } |
541 } | 538 } |
542 | 539 |
543 void PrinterJobHandler::JobFailed(PrintJobError error) { | 540 void PrinterJobHandler::JobFailed(PrintJobError error) { |
544 VLOG(1) << "CP_CONNECTOR: Job failed, id: " << printer_info_cloud_.printer_id; | 541 VLOG(1) << "CP_CONNECTOR: Job failed, id: " << printer_info_cloud_.printer_id; |
545 if (!shutting_down_) { | 542 if (!shutting_down_) { |
546 UpdateJobStatus(cloud_print::PRINT_JOB_STATUS_ERROR, error); | 543 UpdateJobStatus(cloud_print::PRINT_JOB_STATUS_ERROR, error); |
547 } | 544 } |
548 } | 545 } |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
633 job_details.tags_, | 630 job_details.tags_, |
634 this)) { | 631 this)) { |
635 OnJobSpoolFailed(); | 632 OnJobSpoolFailed(); |
636 } | 633 } |
637 } | 634 } |
638 | 635 |
639 void PrinterJobHandler::OnJobSpoolSucceeded( | 636 void PrinterJobHandler::OnJobSpoolSucceeded( |
640 const cloud_print::PlatformJobId& job_id) { | 637 const cloud_print::PlatformJobId& job_id) { |
641 DCHECK(MessageLoop::current() == print_thread_.message_loop()); | 638 DCHECK(MessageLoop::current() == print_thread_.message_loop()); |
642 job_spooler_ = NULL; | 639 job_spooler_ = NULL; |
643 job_handler_message_loop_proxy_->PostTask(FROM_HERE, | 640 job_handler_message_loop_proxy_->PostTask( |
644 NewRunnableMethod(this, | 641 FROM_HERE, base::Bind(&PrinterJobHandler::JobSpooled, this, job_id)); |
645 &PrinterJobHandler::JobSpooled, | |
646 job_id)); | |
647 } | 642 } |
648 | 643 |
649 void PrinterJobHandler::OnJobSpoolFailed() { | 644 void PrinterJobHandler::OnJobSpoolFailed() { |
650 DCHECK(MessageLoop::current() == print_thread_.message_loop()); | 645 DCHECK(MessageLoop::current() == print_thread_.message_loop()); |
651 job_spooler_ = NULL; | 646 job_spooler_ = NULL; |
652 job_handler_message_loop_proxy_->PostTask(FROM_HERE, | 647 job_handler_message_loop_proxy_->PostTask( |
653 NewRunnableMethod(this, | 648 FROM_HERE, base::Bind(&PrinterJobHandler::JobFailed, this, PRINT_FAILED)); |
654 &PrinterJobHandler::JobFailed, | |
655 PRINT_FAILED)); | |
656 } | 649 } |
OLD | NEW |