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" |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 | 69 |
70 void JobStatusUpdater::Stop() { | 70 void JobStatusUpdater::Stop() { |
71 request_ = NULL; | 71 request_ = NULL; |
72 DCHECK(delegate_); | 72 DCHECK(delegate_); |
73 stopped_ = true; | 73 stopped_ = true; |
74 delegate_->OnJobCompleted(this); | 74 delegate_->OnJobCompleted(this); |
75 } | 75 } |
76 | 76 |
77 // CloudPrintURLFetcher::Delegate implementation. | 77 // CloudPrintURLFetcher::Delegate implementation. |
78 CloudPrintURLFetcher::ResponseAction JobStatusUpdater::HandleJSONData( | 78 CloudPrintURLFetcher::ResponseAction JobStatusUpdater::HandleJSONData( |
79 const content::URLFetcher* source, | 79 const net::URLFetcher* source, |
80 const GURL& url, | 80 const GURL& url, |
81 DictionaryValue* json_data, | 81 DictionaryValue* json_data, |
82 bool succeeded) { | 82 bool succeeded) { |
83 if (last_job_details_.status == cloud_print::PRINT_JOB_STATUS_COMPLETED) { | 83 if (last_job_details_.status == cloud_print::PRINT_JOB_STATUS_COMPLETED) { |
84 MessageLoop::current()->PostTask( | 84 MessageLoop::current()->PostTask( |
85 FROM_HERE, base::Bind(&JobStatusUpdater::Stop, this)); | 85 FROM_HERE, base::Bind(&JobStatusUpdater::Stop, this)); |
86 } | 86 } |
87 return CloudPrintURLFetcher::STOP_PROCESSING; | 87 return CloudPrintURLFetcher::STOP_PROCESSING; |
88 } | 88 } |
89 | 89 |
90 CloudPrintURLFetcher::ResponseAction JobStatusUpdater::OnRequestAuthError() { | 90 CloudPrintURLFetcher::ResponseAction JobStatusUpdater::OnRequestAuthError() { |
91 // We got an Auth error and have no idea how long it will take to refresh | 91 // We got an Auth error and have no idea how long it will take to refresh |
92 // auth information (may take forever). We'll drop current request and | 92 // auth information (may take forever). We'll drop current request and |
93 // propagate this error to the upper level. After auth issues will be | 93 // propagate this error to the upper level. After auth issues will be |
94 // resolved, GCP connector will restart. | 94 // resolved, GCP connector will restart. |
95 if (delegate_) | 95 if (delegate_) |
96 delegate_->OnAuthError(); | 96 delegate_->OnAuthError(); |
97 return CloudPrintURLFetcher::STOP_PROCESSING; | 97 return CloudPrintURLFetcher::STOP_PROCESSING; |
98 } | 98 } |
99 | 99 |
100 std::string JobStatusUpdater::GetAuthHeader() { | 100 std::string JobStatusUpdater::GetAuthHeader() { |
101 return CloudPrintHelpers::GetCloudPrintAuthHeaderFromStore(); | 101 return CloudPrintHelpers::GetCloudPrintAuthHeaderFromStore(); |
102 } | 102 } |
103 | 103 |
104 JobStatusUpdater::~JobStatusUpdater() {} | 104 JobStatusUpdater::~JobStatusUpdater() {} |
OLD | NEW |