diff options
author | gene@google.com <gene@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-05-05 19:48:53 +0000 |
---|---|---|
committer | gene@google.com <gene@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-05-05 19:48:53 +0000 |
commit | 7ab27064b11f3b425c66c3c51a7b0333b2baf644 (patch) | |
tree | 69b64ce5fa82ec4d5cb16a19941108b298d4c3df | |
parent | e2539b12439542a8b1c4cfc821d29404077a771d (diff) | |
download | chromium_src-7ab27064b11f3b425c66c3c51a7b0333b2baf644.zip chromium_src-7ab27064b11f3b425c66c3c51a7b0333b2baf644.tar.gz chromium_src-7ab27064b11f3b425c66c3c51a7b0333b2baf644.tar.bz2 |
Mark job as error if we failed to fetch job data from the server after several tries.
Do not retry on 415 error, because request will never succeed (as per discussion with Abhijit)
BUG=none
TEST=Verify proxy marks jobs as Error, if we failed to convert on server side.
Review URL: http://codereview.chromium.org/6901159
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@84283 0039d316-1c4b-4281-b951-d872f2087c98
-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, |