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

Unified Diff: chrome/service/cloud_print/job_status_updater.cc

Issue 4165013: Re-landing issue 4202006 (http://codereview.chromium.org/4202006/show) which ... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 10 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/service/cloud_print/job_status_updater.h ('k') | chrome/service/cloud_print/printer_job_handler.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/service/cloud_print/job_status_updater.cc
===================================================================
--- chrome/service/cloud_print/job_status_updater.cc (revision 64444)
+++ chrome/service/cloud_print/job_status_updater.cc (working copy)
@@ -58,45 +58,36 @@
}
}
if (need_update) {
- GURL update_url = CloudPrintHelpers::GetUrlForJobStatusUpdate(
- cloud_print_server_url_, job_id_, last_job_details_);
- request_.reset(new URLFetcher(update_url, URLFetcher::GET, this));
- CloudPrintHelpers::PrepCloudPrintRequest(request_.get(), auth_token_);
- request_->Start();
+ request_ = new CloudPrintURLFetcher;
+ request_->StartGetRequest(
+ CloudPrintHelpers::GetUrlForJobStatusUpdate(
+ cloud_print_server_url_, job_id_, last_job_details_),
+ this, auth_token_, kCloudPrintAPIRetryPolicy);
}
}
}
void JobStatusUpdater::Stop() {
- request_.reset();
+ request_ = NULL;
DCHECK(delegate_);
stopped_ = true;
delegate_->OnJobCompleted(this);
}
-// URLFetcher::Delegate implementation.
-void JobStatusUpdater::OnURLFetchComplete(const URLFetcher* source,
- const GURL& url,
- const URLRequestStatus& status,
- int response_code,
- const ResponseCookies& cookies,
- const std::string& data) {
- // If there was an auth error, we are done.
- if (RC_FORBIDDEN == response_code) {
- if (delegate_) {
- delegate_->OnAuthError();
- }
- return;
- }
- int64 next_update_interval = kJobStatusUpdateInterval;
- if (!status.is_success() || (response_code != 200)) {
- next_update_interval *= 10;
- MessageLoop::current()->PostDelayedTask(
- FROM_HERE, NewRunnableMethod(this, &JobStatusUpdater::UpdateStatus),
- next_update_interval);
- } else if (last_job_details_.status ==
- cloud_print::PRINT_JOB_STATUS_COMPLETED) {
+// CloudPrintURLFetcher::Delegate implementation.
+CloudPrintURLFetcher::ResponseAction JobStatusUpdater::HandleJSONData(
+ const URLFetcher* source,
+ const GURL& url,
+ DictionaryValue* json_data,
+ bool succeeded) {
+ if (last_job_details_.status == cloud_print::PRINT_JOB_STATUS_COMPLETED) {
MessageLoop::current()->PostTask(
FROM_HERE, NewRunnableMethod(this, &JobStatusUpdater::Stop));
}
+ return CloudPrintURLFetcher::STOP_PROCESSING;
}
+
+void JobStatusUpdater::OnRequestAuthError() {
+ if (delegate_)
+ delegate_->OnAuthError();
+}
« no previous file with comments | « chrome/service/cloud_print/job_status_updater.h ('k') | chrome/service/cloud_print/printer_job_handler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698