Consider error as terminal state and stop watching jobs.

BUG=138629

Review URL: https://codereview.chromium.org/59093002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@233153 0039d316-1c4b-4281-b951-d872f2087c98
parent a078e25b
......@@ -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));
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment