| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/bind.h" |
| 7 #include "base/json/json_reader.h" | 8 #include "base/json/json_reader.h" |
| 8 #include "base/string_util.h" | 9 #include "base/string_util.h" |
| 9 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
| 10 #include "base/values.h" | 11 #include "base/values.h" |
| 11 #include "chrome/common/net/http_return.h" | 12 #include "chrome/common/net/http_return.h" |
| 12 #include "chrome/service/cloud_print/cloud_print_consts.h" | 13 #include "chrome/service/cloud_print/cloud_print_consts.h" |
| 13 #include "chrome/service/cloud_print/cloud_print_helpers.h" | 14 #include "chrome/service/cloud_print/cloud_print_helpers.h" |
| 14 #include "googleurl/src/gurl.h" | 15 #include "googleurl/src/gurl.h" |
| 15 | 16 |
| 16 JobStatusUpdater::JobStatusUpdater(const std::string& printer_name, | 17 JobStatusUpdater::JobStatusUpdater(const std::string& printer_name, |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 } | 78 } |
| 78 | 79 |
| 79 // CloudPrintURLFetcher::Delegate implementation. | 80 // CloudPrintURLFetcher::Delegate implementation. |
| 80 CloudPrintURLFetcher::ResponseAction JobStatusUpdater::HandleJSONData( | 81 CloudPrintURLFetcher::ResponseAction JobStatusUpdater::HandleJSONData( |
| 81 const content::URLFetcher* source, | 82 const content::URLFetcher* source, |
| 82 const GURL& url, | 83 const GURL& url, |
| 83 DictionaryValue* json_data, | 84 DictionaryValue* json_data, |
| 84 bool succeeded) { | 85 bool succeeded) { |
| 85 if (last_job_details_.status == cloud_print::PRINT_JOB_STATUS_COMPLETED) { | 86 if (last_job_details_.status == cloud_print::PRINT_JOB_STATUS_COMPLETED) { |
| 86 MessageLoop::current()->PostTask( | 87 MessageLoop::current()->PostTask( |
| 87 FROM_HERE, NewRunnableMethod(this, &JobStatusUpdater::Stop)); | 88 FROM_HERE, base::Bind(&JobStatusUpdater::Stop, this)); |
| 88 } | 89 } |
| 89 return CloudPrintURLFetcher::STOP_PROCESSING; | 90 return CloudPrintURLFetcher::STOP_PROCESSING; |
| 90 } | 91 } |
| 91 | 92 |
| 92 CloudPrintURLFetcher::ResponseAction JobStatusUpdater::OnRequestAuthError() { | 93 CloudPrintURLFetcher::ResponseAction JobStatusUpdater::OnRequestAuthError() { |
| 93 // We got an Auth error and have no idea how long it will take to refresh | 94 // We got an Auth error and have no idea how long it will take to refresh |
| 94 // auth information (may take forever). We'll drop current request and | 95 // auth information (may take forever). We'll drop current request and |
| 95 // propagate this error to the upper level. After auth issues will be | 96 // propagate this error to the upper level. After auth issues will be |
| 96 // resolved, GCP connector will restart. | 97 // resolved, GCP connector will restart. |
| 97 if (delegate_) | 98 if (delegate_) |
| 98 delegate_->OnAuthError(); | 99 delegate_->OnAuthError(); |
| 99 return CloudPrintURLFetcher::STOP_PROCESSING; | 100 return CloudPrintURLFetcher::STOP_PROCESSING; |
| 100 } | 101 } |
| 101 | 102 |
| 102 std::string JobStatusUpdater::GetAuthHeader() { | 103 std::string JobStatusUpdater::GetAuthHeader() { |
| 103 return CloudPrintHelpers::GetCloudPrintAuthHeader(); | 104 return CloudPrintHelpers::GetCloudPrintAuthHeader(); |
| 104 } | 105 } |
| 105 | 106 |
| OLD | NEW |