OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/bind.h" |
8 #include "base/json/json_reader.h" | 8 #include "base/json/json_reader.h" |
9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
11 #include "base/values.h" | 11 #include "base/values.h" |
12 #include "chrome/service/cloud_print/cloud_print_consts.h" | 12 #include "chrome/service/cloud_print/cloud_print_consts.h" |
13 #include "chrome/service/cloud_print/cloud_print_helpers.h" | 13 #include "chrome/service/cloud_print/cloud_print_helpers.h" |
14 #include "googleurl/src/gurl.h" | 14 #include "googleurl/src/gurl.h" |
15 | 15 |
16 JobStatusUpdater::JobStatusUpdater(const std::string& printer_name, | 16 JobStatusUpdater::JobStatusUpdater(const std::string& printer_name, |
17 const std::string& job_id, | 17 const std::string& job_id, |
18 cloud_print::PlatformJobId& local_job_id, | 18 cloud_print::PlatformJobId& local_job_id, |
19 const GURL& cloud_print_server_url, | 19 const GURL& cloud_print_server_url, |
20 cloud_print::PrintSystem* print_system, | 20 cloud_print::PrintSystem* print_system, |
21 Delegate* delegate) | 21 Delegate* delegate) |
22 : printer_name_(printer_name), job_id_(job_id), | 22 : printer_name_(printer_name), job_id_(job_id), |
23 local_job_id_(local_job_id), | 23 local_job_id_(local_job_id), |
24 cloud_print_server_url_(cloud_print_server_url), | 24 cloud_print_server_url_(cloud_print_server_url), |
25 print_system_(print_system), delegate_(delegate), stopped_(false) { | 25 print_system_(print_system), delegate_(delegate), stopped_(false) { |
26 DCHECK(delegate_); | 26 DCHECK(delegate_); |
27 } | 27 } |
28 | 28 |
29 JobStatusUpdater::~JobStatusUpdater() {} | |
30 | |
31 // Start checking the status of the local print job. | 29 // Start checking the status of the local print job. |
32 void JobStatusUpdater::UpdateStatus() { | 30 void JobStatusUpdater::UpdateStatus() { |
33 // It does not matter if we had already sent out an update and are waiting for | 31 // It does not matter if we had already sent out an update and are waiting for |
34 // a response. This is a new update and we will simply cancel the old request | 32 // a response. This is a new update and we will simply cancel the old request |
35 // and send a new one. | 33 // and send a new one. |
36 if (!stopped_) { | 34 if (!stopped_) { |
37 bool need_update = false; | 35 bool need_update = false; |
38 // If the job has already been completed, we just need to update the server | 36 // If the job has already been completed, we just need to update the server |
39 // with that status. The *only* reason we would come back here in that case | 37 // with that status. The *only* reason we would come back here in that case |
40 // is if our last server update attempt failed. | 38 // is if our last server update attempt failed. |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 // resolved, GCP connector will restart. | 94 // resolved, GCP connector will restart. |
97 if (delegate_) | 95 if (delegate_) |
98 delegate_->OnAuthError(); | 96 delegate_->OnAuthError(); |
99 return CloudPrintURLFetcher::STOP_PROCESSING; | 97 return CloudPrintURLFetcher::STOP_PROCESSING; |
100 } | 98 } |
101 | 99 |
102 std::string JobStatusUpdater::GetAuthHeader() { | 100 std::string JobStatusUpdater::GetAuthHeader() { |
103 return CloudPrintHelpers::GetCloudPrintAuthHeader(); | 101 return CloudPrintHelpers::GetCloudPrintAuthHeader(); |
104 } | 102 } |
105 | 103 |
| 104 JobStatusUpdater::~JobStatusUpdater() {} |
OLD | NEW |