| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/service/cloud_print/job_status_updater.h" | 5 #include "chrome/service/cloud_print/job_status_updater.h" |
| 6 | 6 |
| 7 #include "base/json/json_reader.h" | 7 #include "base/json/json_reader.h" |
| 8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
| 9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
| 10 #include "chrome/common/net/http_return.h" | 10 #include "chrome/common/net/http_return.h" |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 last_job_details_.Clear(); | 55 last_job_details_.Clear(); |
| 56 last_job_details_.status = cloud_print::PRINT_JOB_STATUS_COMPLETED; | 56 last_job_details_.status = cloud_print::PRINT_JOB_STATUS_COMPLETED; |
| 57 need_update = true; | 57 need_update = true; |
| 58 } | 58 } |
| 59 } | 59 } |
| 60 if (need_update) { | 60 if (need_update) { |
| 61 request_ = new CloudPrintURLFetcher; | 61 request_ = new CloudPrintURLFetcher; |
| 62 request_->StartGetRequest( | 62 request_->StartGetRequest( |
| 63 CloudPrintHelpers::GetUrlForJobStatusUpdate( | 63 CloudPrintHelpers::GetUrlForJobStatusUpdate( |
| 64 cloud_print_server_url_, job_id_, last_job_details_), | 64 cloud_print_server_url_, job_id_, last_job_details_), |
| 65 this, auth_token_, kCloudPrintAPIMaxRetryCount); | 65 this, |
| 66 auth_token_, |
| 67 kCloudPrintAPIMaxRetryCount, |
| 68 std::string()); |
| 66 } | 69 } |
| 67 } | 70 } |
| 68 } | 71 } |
| 69 | 72 |
| 70 void JobStatusUpdater::Stop() { | 73 void JobStatusUpdater::Stop() { |
| 71 request_ = NULL; | 74 request_ = NULL; |
| 72 DCHECK(delegate_); | 75 DCHECK(delegate_); |
| 73 stopped_ = true; | 76 stopped_ = true; |
| 74 delegate_->OnJobCompleted(this); | 77 delegate_->OnJobCompleted(this); |
| 75 } | 78 } |
| 76 | 79 |
| 77 // CloudPrintURLFetcher::Delegate implementation. | 80 // CloudPrintURLFetcher::Delegate implementation. |
| 78 CloudPrintURLFetcher::ResponseAction JobStatusUpdater::HandleJSONData( | 81 CloudPrintURLFetcher::ResponseAction JobStatusUpdater::HandleJSONData( |
| 79 const URLFetcher* source, | 82 const URLFetcher* source, |
| 80 const GURL& url, | 83 const GURL& url, |
| 81 DictionaryValue* json_data, | 84 DictionaryValue* json_data, |
| 82 bool succeeded) { | 85 bool succeeded) { |
| 83 if (last_job_details_.status == cloud_print::PRINT_JOB_STATUS_COMPLETED) { | 86 if (last_job_details_.status == cloud_print::PRINT_JOB_STATUS_COMPLETED) { |
| 84 MessageLoop::current()->PostTask( | 87 MessageLoop::current()->PostTask( |
| 85 FROM_HERE, NewRunnableMethod(this, &JobStatusUpdater::Stop)); | 88 FROM_HERE, NewRunnableMethod(this, &JobStatusUpdater::Stop)); |
| 86 } | 89 } |
| 87 return CloudPrintURLFetcher::STOP_PROCESSING; | 90 return CloudPrintURLFetcher::STOP_PROCESSING; |
| 88 } | 91 } |
| 89 | 92 |
| 90 void JobStatusUpdater::OnRequestAuthError() { | 93 void JobStatusUpdater::OnRequestAuthError() { |
| 91 if (delegate_) | 94 if (delegate_) |
| 92 delegate_->OnAuthError(); | 95 delegate_->OnAuthError(); |
| 93 } | 96 } |
| OLD | NEW |