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 #ifndef CHROME_SERVICE_CLOUD_PRINT_PRINTER_JOB_HANDLER_H_ | 5 #ifndef CHROME_SERVICE_CLOUD_PRINT_PRINTER_JOB_HANDLER_H_ |
6 #define CHROME_SERVICE_CLOUD_PRINT_PRINTER_JOB_HANDLER_H_ | 6 #define CHROME_SERVICE_CLOUD_PRINT_PRINTER_JOB_HANDLER_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <list> | 9 #include <list> |
10 #include <string> | 10 #include <string> |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 // Shutdown everything (the process is exiting). | 103 // Shutdown everything (the process is exiting). |
104 void Shutdown(); | 104 void Shutdown(); |
105 | 105 |
106 base::TimeTicks last_job_fetch_time() const { return last_job_fetch_time_; } | 106 base::TimeTicks last_job_fetch_time() const { return last_job_fetch_time_; } |
107 // End public interface | 107 // End public interface |
108 | 108 |
109 // Begin Delegate implementations | 109 // Begin Delegate implementations |
110 | 110 |
111 // CloudPrintURLFetcher::Delegate implementation. | 111 // CloudPrintURLFetcher::Delegate implementation. |
112 virtual CloudPrintURLFetcher::ResponseAction HandleRawResponse( | 112 virtual CloudPrintURLFetcher::ResponseAction HandleRawResponse( |
113 const content::URLFetcher* source, | 113 const net::URLFetcher* source, |
114 const GURL& url, | 114 const GURL& url, |
115 const net::URLRequestStatus& status, | 115 const net::URLRequestStatus& status, |
116 int response_code, | 116 int response_code, |
117 const net::ResponseCookies& cookies, | 117 const net::ResponseCookies& cookies, |
118 const std::string& data) OVERRIDE; | 118 const std::string& data) OVERRIDE; |
119 virtual CloudPrintURLFetcher::ResponseAction HandleRawData( | 119 virtual CloudPrintURLFetcher::ResponseAction HandleRawData( |
120 const content::URLFetcher* source, | 120 const net::URLFetcher* source, |
121 const GURL& url, | 121 const GURL& url, |
122 const std::string& data) OVERRIDE; | 122 const std::string& data) OVERRIDE; |
123 virtual CloudPrintURLFetcher::ResponseAction HandleJSONData( | 123 virtual CloudPrintURLFetcher::ResponseAction HandleJSONData( |
124 const content::URLFetcher* source, | 124 const net::URLFetcher* source, |
125 const GURL& url, | 125 const GURL& url, |
126 base::DictionaryValue* json_data, | 126 base::DictionaryValue* json_data, |
127 bool succeeded) OVERRIDE; | 127 bool succeeded) OVERRIDE; |
128 virtual void OnRequestGiveUp() OVERRIDE; | 128 virtual void OnRequestGiveUp() OVERRIDE; |
129 virtual CloudPrintURLFetcher::ResponseAction OnRequestAuthError() OVERRIDE; | 129 virtual CloudPrintURLFetcher::ResponseAction OnRequestAuthError() OVERRIDE; |
130 virtual std::string GetAuthHeader() OVERRIDE; | 130 virtual std::string GetAuthHeader() OVERRIDE; |
131 | 131 |
132 // JobStatusUpdater::Delegate implementation | 132 // JobStatusUpdater::Delegate implementation |
133 virtual bool OnJobCompleted(JobStatusUpdater* updater) OVERRIDE; | 133 virtual bool OnJobCompleted(JobStatusUpdater* updater) OVERRIDE; |
134 virtual void OnAuthError() OVERRIDE; | 134 virtual void OnAuthError() OVERRIDE; |
(...skipping 16 matching lines...) Expand all Loading... |
151 | 151 |
152 enum PrintJobError { | 152 enum PrintJobError { |
153 SUCCESS, | 153 SUCCESS, |
154 JOB_DOWNLOAD_FAILED, | 154 JOB_DOWNLOAD_FAILED, |
155 INVALID_JOB_DATA, | 155 INVALID_JOB_DATA, |
156 PRINT_FAILED, | 156 PRINT_FAILED, |
157 }; | 157 }; |
158 | 158 |
159 // Prototype for a JSON data handler. | 159 // Prototype for a JSON data handler. |
160 typedef CloudPrintURLFetcher::ResponseAction | 160 typedef CloudPrintURLFetcher::ResponseAction |
161 (PrinterJobHandler::*JSONDataHandler)(const content::URLFetcher* source, | 161 (PrinterJobHandler::*JSONDataHandler)(const net::URLFetcher* source, |
162 const GURL& url, | 162 const GURL& url, |
163 base::DictionaryValue* json_data, | 163 base::DictionaryValue* json_data, |
164 bool succeeded); | 164 bool succeeded); |
165 // Prototype for a data handler. | 165 // Prototype for a data handler. |
166 typedef CloudPrintURLFetcher::ResponseAction | 166 typedef CloudPrintURLFetcher::ResponseAction |
167 (PrinterJobHandler::*DataHandler)(const content::URLFetcher* source, | 167 (PrinterJobHandler::*DataHandler)(const net::URLFetcher* source, |
168 const GURL& url, | 168 const GURL& url, |
169 const std::string& data); | 169 const std::string& data); |
170 | 170 |
171 struct JobDetails { | 171 struct JobDetails { |
172 JobDetails(); | 172 JobDetails(); |
173 ~JobDetails(); | 173 ~JobDetails(); |
174 void Clear(); | 174 void Clear(); |
175 | 175 |
176 std::string job_id_; | 176 std::string job_id_; |
177 std::string job_title_; | 177 std::string job_title_; |
178 std::string print_ticket_; | 178 std::string print_ticket_; |
179 FilePath print_data_file_path_; | 179 FilePath print_data_file_path_; |
180 std::string print_data_mime_type_; | 180 std::string print_data_mime_type_; |
181 std::vector<std::string> tags_; | 181 std::vector<std::string> tags_; |
182 }; | 182 }; |
183 | 183 |
184 virtual ~PrinterJobHandler(); | 184 virtual ~PrinterJobHandler(); |
185 | 185 |
186 // Begin request handlers for each state in the state machine | 186 // Begin request handlers for each state in the state machine |
187 CloudPrintURLFetcher::ResponseAction HandlePrinterUpdateResponse( | 187 CloudPrintURLFetcher::ResponseAction HandlePrinterUpdateResponse( |
188 const content::URLFetcher* source, | 188 const net::URLFetcher* source, |
189 const GURL& url, | 189 const GURL& url, |
190 base::DictionaryValue* json_data, | 190 base::DictionaryValue* json_data, |
191 bool succeeded); | 191 bool succeeded); |
192 | 192 |
193 CloudPrintURLFetcher::ResponseAction HandleJobMetadataResponse( | 193 CloudPrintURLFetcher::ResponseAction HandleJobMetadataResponse( |
194 const content::URLFetcher* source, | 194 const net::URLFetcher* source, |
195 const GURL& url, | 195 const GURL& url, |
196 base::DictionaryValue* json_data, | 196 base::DictionaryValue* json_data, |
197 bool succeeded); | 197 bool succeeded); |
198 | 198 |
199 CloudPrintURLFetcher::ResponseAction HandlePrintTicketResponse( | 199 CloudPrintURLFetcher::ResponseAction HandlePrintTicketResponse( |
200 const content::URLFetcher* source, | 200 const net::URLFetcher* source, |
201 const GURL& url, | 201 const GURL& url, |
202 const std::string& data); | 202 const std::string& data); |
203 | 203 |
204 CloudPrintURLFetcher::ResponseAction HandlePrintDataResponse( | 204 CloudPrintURLFetcher::ResponseAction HandlePrintDataResponse( |
205 const content::URLFetcher* source, | 205 const net::URLFetcher* source, |
206 const GURL& url, | 206 const GURL& url, |
207 const std::string& data); | 207 const std::string& data); |
208 | 208 |
209 CloudPrintURLFetcher::ResponseAction HandleSuccessStatusUpdateResponse( | 209 CloudPrintURLFetcher::ResponseAction HandleSuccessStatusUpdateResponse( |
210 const content::URLFetcher* source, | 210 const net::URLFetcher* source, |
211 const GURL& url, | 211 const GURL& url, |
212 base::DictionaryValue* json_data, | 212 base::DictionaryValue* json_data, |
213 bool succeeded); | 213 bool succeeded); |
214 | 214 |
215 CloudPrintURLFetcher::ResponseAction HandleFailureStatusUpdateResponse( | 215 CloudPrintURLFetcher::ResponseAction HandleFailureStatusUpdateResponse( |
216 const content::URLFetcher* source, | 216 const net::URLFetcher* source, |
217 const GURL& url, | 217 const GURL& url, |
218 base::DictionaryValue* json_data, | 218 base::DictionaryValue* json_data, |
219 bool succeeded); | 219 bool succeeded); |
220 // End request handlers for each state in the state machine | 220 // End request handlers for each state in the state machine |
221 | 221 |
222 // Start the state machine. Based on the flags set this could mean updating | 222 // Start the state machine. Based on the flags set this could mean updating |
223 // printer information, deleting the printer from the server or looking for | 223 // printer information, deleting the printer from the server or looking for |
224 // new print jobs | 224 // new print jobs |
225 void Start(); | 225 void Start(); |
226 | 226 |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
304 DISALLOW_COPY_AND_ASSIGN(PrinterJobHandler); | 304 DISALLOW_COPY_AND_ASSIGN(PrinterJobHandler); |
305 }; | 305 }; |
306 | 306 |
307 // This typedef is to workaround the issue with certain versions of | 307 // This typedef is to workaround the issue with certain versions of |
308 // Visual Studio where it gets confused between multiple Delegate | 308 // Visual Studio where it gets confused between multiple Delegate |
309 // classes and gives a C2500 error. (I saw this error on the try bots - | 309 // classes and gives a C2500 error. (I saw this error on the try bots - |
310 // the workaround was not needed for my machine). | 310 // the workaround was not needed for my machine). |
311 typedef PrinterJobHandler::Delegate PrinterJobHandlerDelegate; | 311 typedef PrinterJobHandler::Delegate PrinterJobHandlerDelegate; |
312 | 312 |
313 #endif // CHROME_SERVICE_CLOUD_PRINT_PRINTER_JOB_HANDLER_H_ | 313 #endif // CHROME_SERVICE_CLOUD_PRINT_PRINTER_JOB_HANDLER_H_ |
OLD | NEW |