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

Side by Side Diff: chrome/service/cloud_print/printer_job_handler.cc

Issue 147953009: Fallback to CDD/CJT if connector can't initialize XPS API. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 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 | Annotate | Revision Log
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/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/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/file_util.h" 9 #include "base/file_util.h"
10 #include "base/json/json_reader.h" 10 #include "base/json/json_reader.h"
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after
309 if (!jobs.empty()) { 309 if (!jobs.empty()) {
310 if (jobs[0].time_remaining_ == base::TimeDelta()) { 310 if (jobs[0].time_remaining_ == base::TimeDelta()) {
311 job_available = true; 311 job_available = true;
312 job_details_ = jobs[0]; 312 job_details_ = jobs[0];
313 job_start_time_ = base::Time::Now(); 313 job_start_time_ = base::Time::Now();
314 base::subtle::NoBarrier_AtomicIncrement(&g_total_jobs_started, 1); 314 base::subtle::NoBarrier_AtomicIncrement(&g_total_jobs_started, 1);
315 UMA_HISTOGRAM_ENUMERATION("CloudPrint.JobHandlerEvent", 315 UMA_HISTOGRAM_ENUMERATION("CloudPrint.JobHandlerEvent",
316 JOB_HANDLER_JOB_STARTED, JOB_HANDLER_MAX); 316 JOB_HANDLER_JOB_STARTED, JOB_HANDLER_MAX);
317 SetNextDataHandler(&PrinterJobHandler::HandlePrintTicketResponse); 317 SetNextDataHandler(&PrinterJobHandler::HandlePrintTicketResponse);
318 request_ = CloudPrintURLFetcher::Create(); 318 request_ = CloudPrintURLFetcher::Create();
319 request_->StartGetRequest(CloudPrintURLFetcher::REQUEST_TICKET, 319 if (print_system_->UseCddAndCjt()) {
320 GURL(job_details_.print_ticket_url_), this, kJobDataMaxRetryCount, 320 request_->StartGetRequest(
321 std::string()); 321 CloudPrintURLFetcher::REQUEST_TICKET,
322 GetUrlForJobCjt(cloud_print_server_url_, job_details_.job_id_,
323 job_fetch_reason_),
324 this, kJobDataMaxRetryCount, std::string());
325 } else {
326 request_->StartGetRequest(
327 CloudPrintURLFetcher::REQUEST_TICKET,
328 GURL(job_details_.print_ticket_url_), this, kJobDataMaxRetryCount,
329 std::string());
330 }
322 } else { 331 } else {
323 job_available = false; 332 job_available = false;
324 base::MessageLoop::current()->PostDelayedTask( 333 base::MessageLoop::current()->PostDelayedTask(
325 FROM_HERE, 334 FROM_HERE,
326 base::Bind(&PrinterJobHandler::RunScheduledJobCheck, this), 335 base::Bind(&PrinterJobHandler::RunScheduledJobCheck, this),
327 jobs[0].time_remaining_); 336 jobs[0].time_remaining_);
328 } 337 }
329 } 338 }
330 } 339 }
331 340
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after
676 std::string mime_boundary; 685 std::string mime_boundary;
677 CreateMimeBoundaryForUpload(&mime_boundary); 686 CreateMimeBoundaryForUpload(&mime_boundary);
678 687
679 if (succeeded) { 688 if (succeeded) {
680 std::string caps_hash = 689 std::string caps_hash =
681 base::MD5String(caps_and_defaults.printer_capabilities); 690 base::MD5String(caps_and_defaults.printer_capabilities);
682 if (caps_hash != printer_info_cloud_.caps_hash) { 691 if (caps_hash != printer_info_cloud_.caps_hash) {
683 // Hashes don't match, we need to upload new capabilities (the defaults 692 // Hashes don't match, we need to upload new capabilities (the defaults
684 // go for free along with the capabilities) 693 // go for free along with the capabilities)
685 printer_info_cloud_.caps_hash = caps_hash; 694 printer_info_cloud_.caps_hash = caps_hash;
686 if (caps_and_defaults.caps_mime_type == kContentTypeCDD) { 695 if (caps_and_defaults.caps_mime_type == kContentTypeJSON) {
696 DCHECK(print_system_->UseCddAndCjt());
687 net::AddMultipartValueForUpload(kUseCDD, "true", mime_boundary, 697 net::AddMultipartValueForUpload(kUseCDD, "true", mime_boundary,
688 std::string(), &post_data); 698 std::string(), &post_data);
689 } 699 }
690 net::AddMultipartValueForUpload(kPrinterCapsValue, 700 net::AddMultipartValueForUpload(kPrinterCapsValue,
691 caps_and_defaults.printer_capabilities, mime_boundary, 701 caps_and_defaults.printer_capabilities, mime_boundary,
692 caps_and_defaults.caps_mime_type, &post_data); 702 caps_and_defaults.caps_mime_type, &post_data);
693 net::AddMultipartValueForUpload(kPrinterDefaultsValue, 703 net::AddMultipartValueForUpload(kPrinterDefaultsValue,
694 caps_and_defaults.printer_defaults, mime_boundary, 704 caps_and_defaults.printer_defaults, mime_boundary,
695 caps_and_defaults.defaults_mime_type, &post_data); 705 caps_and_defaults.defaults_mime_type, &post_data);
696 net::AddMultipartValueForUpload(kPrinterCapsHashValue, 706 net::AddMultipartValueForUpload(kPrinterCapsHashValue,
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
796 job_details.print_data_mime_type_, 806 job_details.print_data_mime_type_,
797 printer_name, 807 printer_name,
798 base::UTF16ToUTF8(document_name), 808 base::UTF16ToUTF8(document_name),
799 job_details.tags_, 809 job_details.tags_,
800 this)) { 810 this)) {
801 OnJobSpoolFailed(); 811 OnJobSpoolFailed();
802 } 812 }
803 } 813 }
804 814
805 } // namespace cloud_print 815 } // namespace cloud_print
OLDNEW
« no previous file with comments | « chrome/service/cloud_print/print_system_win.cc ('k') | chrome/service/cloud_print/printer_job_handler_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698