| 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 | 7 |
| 8 #include <list> | 8 #include <list> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 | 108 |
| 109 // Shutdown everything (the process is exiting). | 109 // Shutdown everything (the process is exiting). |
| 110 void Shutdown(); | 110 void Shutdown(); |
| 111 | 111 |
| 112 base::TimeTicks last_job_fetch_time() const { return last_job_fetch_time_; } | 112 base::TimeTicks last_job_fetch_time() const { return last_job_fetch_time_; } |
| 113 // End public interface | 113 // End public interface |
| 114 | 114 |
| 115 // Begin Delegate implementations | 115 // Begin Delegate implementations |
| 116 | 116 |
| 117 // CloudPrintURLFetcher::Delegate implementation. | 117 // CloudPrintURLFetcher::Delegate implementation. |
| 118 virtual CloudPrintURLFetcher::ResponseAction HandleRawResponse( | 118 CloudPrintURLFetcher::ResponseAction HandleRawResponse( |
| 119 const net::URLFetcher* source, | 119 const net::URLFetcher* source, |
| 120 const GURL& url, | 120 const GURL& url, |
| 121 const net::URLRequestStatus& status, | 121 const net::URLRequestStatus& status, |
| 122 int response_code, | 122 int response_code, |
| 123 const net::ResponseCookies& cookies, | 123 const net::ResponseCookies& cookies, |
| 124 const std::string& data) override; | 124 const std::string& data) override; |
| 125 virtual CloudPrintURLFetcher::ResponseAction HandleRawData( | 125 CloudPrintURLFetcher::ResponseAction HandleRawData( |
| 126 const net::URLFetcher* source, | 126 const net::URLFetcher* source, |
| 127 const GURL& url, | 127 const GURL& url, |
| 128 const std::string& data) override; | 128 const std::string& data) override; |
| 129 virtual CloudPrintURLFetcher::ResponseAction HandleJSONData( | 129 CloudPrintURLFetcher::ResponseAction HandleJSONData( |
| 130 const net::URLFetcher* source, | 130 const net::URLFetcher* source, |
| 131 const GURL& url, | 131 const GURL& url, |
| 132 base::DictionaryValue* json_data, | 132 base::DictionaryValue* json_data, |
| 133 bool succeeded) override; | 133 bool succeeded) override; |
| 134 virtual void OnRequestGiveUp() override; | 134 void OnRequestGiveUp() override; |
| 135 virtual CloudPrintURLFetcher::ResponseAction OnRequestAuthError() override; | 135 CloudPrintURLFetcher::ResponseAction OnRequestAuthError() override; |
| 136 virtual std::string GetAuthHeader() override; | 136 std::string GetAuthHeader() override; |
| 137 | 137 |
| 138 // JobStatusUpdater::Delegate implementation | 138 // JobStatusUpdater::Delegate implementation |
| 139 virtual bool OnJobCompleted(JobStatusUpdater* updater) override; | 139 bool OnJobCompleted(JobStatusUpdater* updater) override; |
| 140 virtual void OnAuthError() override; | 140 void OnAuthError() override; |
| 141 | 141 |
| 142 // PrinterWatcherDelegate implementation | 142 // PrinterWatcherDelegate implementation |
| 143 virtual void OnPrinterDeleted() override; | 143 void OnPrinterDeleted() override; |
| 144 virtual void OnPrinterChanged() override; | 144 void OnPrinterChanged() override; |
| 145 virtual void OnJobChanged() override; | 145 void OnJobChanged() override; |
| 146 | 146 |
| 147 // JobSpoolerDelegate implementation. | 147 // JobSpoolerDelegate implementation. |
| 148 // Called on print_thread_. | 148 // Called on print_thread_. |
| 149 virtual void OnJobSpoolSucceeded(const PlatformJobId& job_id) override; | 149 void OnJobSpoolSucceeded(const PlatformJobId& job_id) override; |
| 150 virtual void OnJobSpoolFailed() override; | 150 void OnJobSpoolFailed() override; |
| 151 | 151 |
| 152 // End Delegate implementations | 152 // End Delegate implementations |
| 153 | 153 |
| 154 static void ReportsStats(); | 154 static void ReportsStats(); |
| 155 | 155 |
| 156 private: | 156 private: |
| 157 friend class base::RefCountedThreadSafe<PrinterJobHandler>; | 157 friend class base::RefCountedThreadSafe<PrinterJobHandler>; |
| 158 | 158 |
| 159 enum PrintJobError { | 159 enum PrintJobError { |
| 160 JOB_SUCCESS, | 160 JOB_SUCCESS, |
| 161 JOB_DOWNLOAD_FAILED, | 161 JOB_DOWNLOAD_FAILED, |
| 162 JOB_VALIDATE_TICKET_FAILED, | 162 JOB_VALIDATE_TICKET_FAILED, |
| 163 JOB_FAILED, | 163 JOB_FAILED, |
| 164 JOB_MAX, | 164 JOB_MAX, |
| 165 }; | 165 }; |
| 166 | 166 |
| 167 // Prototype for a JSON data handler. | 167 // Prototype for a JSON data handler. |
| 168 typedef CloudPrintURLFetcher::ResponseAction | 168 typedef CloudPrintURLFetcher::ResponseAction |
| 169 (PrinterJobHandler::*JSONDataHandler)(const net::URLFetcher* source, | 169 (PrinterJobHandler::*JSONDataHandler)(const net::URLFetcher* source, |
| 170 const GURL& url, | 170 const GURL& url, |
| 171 base::DictionaryValue* json_data, | 171 base::DictionaryValue* json_data, |
| 172 bool succeeded); | 172 bool succeeded); |
| 173 // Prototype for a data handler. | 173 // Prototype for a data handler. |
| 174 typedef CloudPrintURLFetcher::ResponseAction | 174 typedef CloudPrintURLFetcher::ResponseAction |
| 175 (PrinterJobHandler::*DataHandler)(const net::URLFetcher* source, | 175 (PrinterJobHandler::*DataHandler)(const net::URLFetcher* source, |
| 176 const GURL& url, | 176 const GURL& url, |
| 177 const std::string& data); | 177 const std::string& data); |
| 178 | 178 |
| 179 virtual ~PrinterJobHandler(); | 179 ~PrinterJobHandler() override; |
| 180 | 180 |
| 181 // Begin request handlers for each state in the state machine | 181 // Begin request handlers for each state in the state machine |
| 182 CloudPrintURLFetcher::ResponseAction HandlePrinterUpdateResponse( | 182 CloudPrintURLFetcher::ResponseAction HandlePrinterUpdateResponse( |
| 183 const net::URLFetcher* source, | 183 const net::URLFetcher* source, |
| 184 const GURL& url, | 184 const GURL& url, |
| 185 base::DictionaryValue* json_data, | 185 base::DictionaryValue* json_data, |
| 186 bool succeeded); | 186 bool succeeded); |
| 187 | 187 |
| 188 CloudPrintURLFetcher::ResponseAction HandleJobMetadataResponse( | 188 CloudPrintURLFetcher::ResponseAction HandleJobMetadataResponse( |
| 189 const net::URLFetcher* source, | 189 const net::URLFetcher* source, |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 315 | 315 |
| 316 // This typedef is to workaround the issue with certain versions of | 316 // This typedef is to workaround the issue with certain versions of |
| 317 // Visual Studio where it gets confused between multiple Delegate | 317 // Visual Studio where it gets confused between multiple Delegate |
| 318 // classes and gives a C2500 error. (I saw this error on the try bots - | 318 // classes and gives a C2500 error. (I saw this error on the try bots - |
| 319 // the workaround was not needed for my machine). | 319 // the workaround was not needed for my machine). |
| 320 typedef PrinterJobHandler::Delegate PrinterJobHandlerDelegate; | 320 typedef PrinterJobHandler::Delegate PrinterJobHandlerDelegate; |
| 321 | 321 |
| 322 } // namespace cloud_print | 322 } // namespace cloud_print |
| 323 | 323 |
| 324 #endif // CHROME_SERVICE_CLOUD_PRINT_PRINTER_JOB_HANDLER_H_ | 324 #endif // CHROME_SERVICE_CLOUD_PRINT_PRINTER_JOB_HANDLER_H_ |
| OLD | NEW |