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/location.h" |
9 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
| 11 #include "base/single_thread_task_runner.h" |
10 #include "base/strings/string_util.h" | 12 #include "base/strings/string_util.h" |
11 #include "base/strings/utf_string_conversions.h" | 13 #include "base/strings/utf_string_conversions.h" |
| 14 #include "base/thread_task_runner_handle.h" |
12 #include "base/values.h" | 15 #include "base/values.h" |
13 #include "chrome/common/cloud_print/cloud_print_constants.h" | 16 #include "chrome/common/cloud_print/cloud_print_constants.h" |
14 #include "chrome/service/cloud_print/cloud_print_service_helpers.h" | 17 #include "chrome/service/cloud_print/cloud_print_service_helpers.h" |
15 #include "url/gurl.h" | 18 #include "url/gurl.h" |
16 | 19 |
17 namespace cloud_print { | 20 namespace cloud_print { |
18 | 21 |
19 namespace { | 22 namespace { |
20 | 23 |
21 bool IsTerminalJobState(PrintJobStatus status) { | 24 bool IsTerminalJobState(PrintJobStatus status) { |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 delegate_->OnJobCompleted(this); | 96 delegate_->OnJobCompleted(this); |
94 } | 97 } |
95 | 98 |
96 // CloudPrintURLFetcher::Delegate implementation. | 99 // CloudPrintURLFetcher::Delegate implementation. |
97 CloudPrintURLFetcher::ResponseAction JobStatusUpdater::HandleJSONData( | 100 CloudPrintURLFetcher::ResponseAction JobStatusUpdater::HandleJSONData( |
98 const net::URLFetcher* source, | 101 const net::URLFetcher* source, |
99 const GURL& url, | 102 const GURL& url, |
100 base::DictionaryValue* json_data, | 103 base::DictionaryValue* json_data, |
101 bool succeeded) { | 104 bool succeeded) { |
102 if (IsTerminalJobState(last_job_details_.status)) { | 105 if (IsTerminalJobState(last_job_details_.status)) { |
103 base::MessageLoop::current()->PostTask( | 106 base::ThreadTaskRunnerHandle::Get()->PostTask( |
104 FROM_HERE, base::Bind(&JobStatusUpdater::Stop, this)); | 107 FROM_HERE, base::Bind(&JobStatusUpdater::Stop, this)); |
105 } | 108 } |
106 return CloudPrintURLFetcher::STOP_PROCESSING; | 109 return CloudPrintURLFetcher::STOP_PROCESSING; |
107 } | 110 } |
108 | 111 |
109 CloudPrintURLFetcher::ResponseAction JobStatusUpdater::OnRequestAuthError() { | 112 CloudPrintURLFetcher::ResponseAction JobStatusUpdater::OnRequestAuthError() { |
110 // We got an Auth error and have no idea how long it will take to refresh | 113 // We got an Auth error and have no idea how long it will take to refresh |
111 // auth information (may take forever). We'll drop current request and | 114 // auth information (may take forever). We'll drop current request and |
112 // propagate this error to the upper level. After auth issues will be | 115 // propagate this error to the upper level. After auth issues will be |
113 // resolved, GCP connector will restart. | 116 // resolved, GCP connector will restart. |
114 if (delegate_) | 117 if (delegate_) |
115 delegate_->OnAuthError(); | 118 delegate_->OnAuthError(); |
116 return CloudPrintURLFetcher::STOP_PROCESSING; | 119 return CloudPrintURLFetcher::STOP_PROCESSING; |
117 } | 120 } |
118 | 121 |
119 std::string JobStatusUpdater::GetAuthHeader() { | 122 std::string JobStatusUpdater::GetAuthHeader() { |
120 return GetCloudPrintAuthHeaderFromStore(); | 123 return GetCloudPrintAuthHeaderFromStore(); |
121 } | 124 } |
122 | 125 |
123 JobStatusUpdater::~JobStatusUpdater() {} | 126 JobStatusUpdater::~JobStatusUpdater() {} |
124 | 127 |
125 } // namespace cloud_print | 128 } // namespace cloud_print |
OLD | NEW |