diff options
-rw-r--r-- | chrome/common/net/http_return.h | 1 | ||||
-rw-r--r-- | chrome/service/cloud_print/printer_job_handler.cc | 27 | ||||
-rw-r--r-- | chrome/service/cloud_print/printer_job_handler.h | 7 |
3 files changed, 34 insertions, 1 deletions
diff --git a/chrome/common/net/http_return.h b/chrome/common/net/http_return.h index 517a849..f2059cb 100644 --- a/chrome/common/net/http_return.h +++ b/chrome/common/net/http_return.h @@ -13,6 +13,7 @@ enum HTTPReturnCode { RC_BAD_REQUEST = 400, RC_UNAUTHORIZED = 401, RC_FORBIDDEN = 403, + RC_UNSUPPORTED_MEDIA_TYPE = 415, RC_INTERNAL_SERVER_ERROR = 500, }; diff --git a/chrome/service/cloud_print/printer_job_handler.cc b/chrome/service/cloud_print/printer_job_handler.cc index 572accc..60d75ed 100644 --- a/chrome/service/cloud_print/printer_job_handler.cc +++ b/chrome/service/cloud_print/printer_job_handler.cc @@ -274,6 +274,26 @@ void PrinterJobHandler::OnReceivePrinterCaps( } // CloudPrintURLFetcher::Delegate implementation. +CloudPrintURLFetcher::ResponseAction PrinterJobHandler::HandleRawResponse( + const URLFetcher* source, + const GURL& url, + const net::URLRequestStatus& status, + int response_code, + const ResponseCookies& cookies, + const std::string& data) { + // 415 (Unsupported media type) error while fetching data from the server + // means data conversion error. Stop fetching process and mark job as error. + if (next_data_handler_ == (&PrinterJobHandler::HandlePrintDataResponse) && + response_code == RC_UNSUPPORTED_MEDIA_TYPE) { + MessageLoop::current()->PostTask( + FROM_HERE, + NewRunnableMethod(this, &PrinterJobHandler::JobFailed, + JOB_DOWNLOAD_FAILED)); + return CloudPrintURLFetcher::STOP_PROCESSING; + } + return CloudPrintURLFetcher::CONTINUE_PROCESSING; +} + CloudPrintURLFetcher::ResponseAction PrinterJobHandler::HandleRawData( const URLFetcher* source, const GURL& url, @@ -296,9 +316,14 @@ CloudPrintURLFetcher::ResponseAction PrinterJobHandler::HandleJSONData( } void PrinterJobHandler::OnRequestGiveUp() { + // The only time we call CloudPrintURLFetcher::StartGetRequest() with a + // specified number of retries, is when we are trying to fetch print job + // data. So, this function will be reached only if we failed to get job data. + // In that case, we should make job as error and should not try it later. MessageLoop::current()->PostTask( FROM_HERE, - NewRunnableMethod(this, &PrinterJobHandler::Stop)); + NewRunnableMethod(this, &PrinterJobHandler::JobFailed, + JOB_DOWNLOAD_FAILED)); } void PrinterJobHandler::OnRequestAuthError() { diff --git a/chrome/service/cloud_print/printer_job_handler.h b/chrome/service/cloud_print/printer_job_handler.h index 6ac9cbd..574f52b 100644 --- a/chrome/service/cloud_print/printer_job_handler.h +++ b/chrome/service/cloud_print/printer_job_handler.h @@ -127,6 +127,13 @@ class PrinterJobHandler : public base::RefCountedThreadSafe<PrinterJobHandler>, // Begin Delegate implementations // CloudPrintURLFetcher::Delegate implementation. + virtual CloudPrintURLFetcher::ResponseAction HandleRawResponse( + const URLFetcher* source, + const GURL& url, + const net::URLRequestStatus& status, + int response_code, + const ResponseCookies& cookies, + const std::string& data); virtual CloudPrintURLFetcher::ResponseAction HandleRawData( const URLFetcher* source, const GURL& url, |