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

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

Issue 59093002: Consider error as terminal state and stop watching jobs. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 1 month 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 | « no previous file | no next file » | 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
diff --git a/chrome/service/cloud_print/job_status_updater.cc b/chrome/service/cloud_print/job_status_updater.cc
index 3334bcfb6dc0942edd4be9287cb1ff7462a78823..674091f420ce4c1ae15da772c1f57b073e60ff4e 100644
--- a/chrome/service/cloud_print/job_status_updater.cc
+++ b/chrome/service/cloud_print/job_status_updater.cc
@@ -16,6 +16,15 @@
namespace cloud_print {
+namespace {
+
+bool IsTerminalJobState(PrintJobStatus status) {
+ return status == PRINT_JOB_STATUS_ERROR ||
+ status == PRINT_JOB_STATUS_COMPLETED;
+}
+
+} // namespace
+
JobStatusUpdater::JobStatusUpdater(const std::string& printer_name,
const std::string& job_id,
PlatformJobId& local_job_id,
@@ -43,7 +52,7 @@ void JobStatusUpdater::UpdateStatus() {
// If the job has already been completed, we just need to update the server
// with that status. The *only* reason we would come back here in that case
// is if our last server update attempt failed.
- if (last_job_details_.status == PRINT_JOB_STATUS_COMPLETED) {
+ if (IsTerminalJobState(last_job_details_.status)) {
need_update = true;
} else {
PrintJobDetails details;
@@ -90,7 +99,7 @@ CloudPrintURLFetcher::ResponseAction JobStatusUpdater::HandleJSONData(
const GURL& url,
DictionaryValue* json_data,
bool succeeded) {
- if (last_job_details_.status == PRINT_JOB_STATUS_COMPLETED) {
+ if (IsTerminalJobState(last_job_details_.status)) {
base::MessageLoop::current()->PostTask(
FROM_HERE, base::Bind(&JobStatusUpdater::Stop, this));
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698