OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_BROWSER_LOCAL_DISCOVERY_PRIVET_HTTP_IMPL_H_ | 5 #ifndef CHROME_BROWSER_LOCAL_DISCOVERY_PRIVET_HTTP_IMPL_H_ |
6 #define CHROME_BROWSER_LOCAL_DISCOVERY_PRIVET_HTTP_IMPL_H_ | 6 #define CHROME_BROWSER_LOCAL_DISCOVERY_PRIVET_HTTP_IMPL_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 public PrivetURLFetcher::Delegate, | 149 public PrivetURLFetcher::Delegate, |
150 public PrivetInfoOperation::Delegate { | 150 public PrivetInfoOperation::Delegate { |
151 public: | 151 public: |
152 PrivetLocalPrintOperationImpl( | 152 PrivetLocalPrintOperationImpl( |
153 PrivetHTTPClientImpl* privet_client, | 153 PrivetHTTPClientImpl* privet_client, |
154 PrivetLocalPrintOperation::Delegate* delegate); | 154 PrivetLocalPrintOperation::Delegate* delegate); |
155 | 155 |
156 virtual ~PrivetLocalPrintOperationImpl(); | 156 virtual ~PrivetLocalPrintOperationImpl(); |
157 virtual void Start() OVERRIDE; | 157 virtual void Start() OVERRIDE; |
158 | 158 |
159 virtual void SendData(const std::string& data) OVERRIDE; | 159 virtual void SetData(scoped_refptr<base::RefCountedBytes> data) OVERRIDE; |
160 virtual void SendDataFile(const base::FilePath& data) OVERRIDE; | |
161 | 160 |
162 virtual void SetTicket(const std::string& ticket) OVERRIDE; | 161 virtual void SetTicket(const std::string& ticket) OVERRIDE; |
163 | 162 |
164 virtual void SetUsername(const std::string& user) OVERRIDE; | 163 virtual void SetUsername(const std::string& user) OVERRIDE; |
165 | 164 |
166 virtual void SetJobname(const std::string& jobname) OVERRIDE; | 165 virtual void SetJobname(const std::string& jobname) OVERRIDE; |
167 | 166 |
168 virtual void SetOffline(bool offline) OVERRIDE; | 167 virtual void SetOffline(bool offline) OVERRIDE; |
169 | 168 |
| 169 virtual void SetPWGRasterConverterForTesting( |
| 170 scoped_ptr<PWGRasterConverter> pwg_raster_converter) OVERRIDE; |
| 171 |
170 virtual PrivetHTTPClient* GetHTTPClient() OVERRIDE; | 172 virtual PrivetHTTPClient* GetHTTPClient() OVERRIDE; |
171 | 173 |
172 virtual void OnError(PrivetURLFetcher* fetcher, | 174 virtual void OnError(PrivetURLFetcher* fetcher, |
173 PrivetURLFetcher::ErrorType error) OVERRIDE; | 175 PrivetURLFetcher::ErrorType error) OVERRIDE; |
174 virtual void OnParsedJson(PrivetURLFetcher* fetcher, | 176 virtual void OnParsedJson(PrivetURLFetcher* fetcher, |
175 const base::DictionaryValue* value, | 177 const base::DictionaryValue* value, |
176 bool has_error) OVERRIDE; | 178 bool has_error) OVERRIDE; |
177 virtual void OnNeedPrivetToken( | 179 virtual void OnNeedPrivetToken( |
178 PrivetURLFetcher* fetcher, | 180 PrivetURLFetcher* fetcher, |
179 const PrivetURLFetcher::TokenCallback& callback) OVERRIDE; | 181 const PrivetURLFetcher::TokenCallback& callback) OVERRIDE; |
180 | 182 |
181 virtual void OnPrivetInfoDone(PrivetInfoOperation* operation, | 183 virtual void OnPrivetInfoDone(PrivetInfoOperation* operation, |
182 int http_code, | 184 int http_code, |
183 const base::DictionaryValue* value) OVERRIDE; | 185 const base::DictionaryValue* value) OVERRIDE; |
184 private: | 186 private: |
185 typedef base::Callback<void(bool, const base::DictionaryValue* value)> | 187 typedef base::Callback<void(bool, const base::DictionaryValue* value)> |
186 ResponseCallback; | 188 ResponseCallback; |
187 | 189 |
188 void StartInitialRequest(); | 190 void StartInitialRequest(); |
189 void GetCapabilities(); | 191 void GetCapabilities(); |
190 void DoCreatejob(); | 192 void DoCreatejob(); |
191 void DoSubmitdoc(); | 193 void DoSubmitdoc(); |
192 | 194 |
| 195 void StartConvertToPWG(); |
| 196 void StartPrinting(); |
| 197 |
193 void OnCapabilitiesResponse(bool has_error, | 198 void OnCapabilitiesResponse(bool has_error, |
194 const base::DictionaryValue* value); | 199 const base::DictionaryValue* value); |
195 void OnSubmitdocResponse(bool has_error, | 200 void OnSubmitdocResponse(bool has_error, |
196 const base::DictionaryValue* value); | 201 const base::DictionaryValue* value); |
197 void OnCreatejobResponse(bool has_error, | 202 void OnCreatejobResponse(bool has_error, |
198 const base::DictionaryValue* value); | 203 const base::DictionaryValue* value); |
199 | 204 void OnPWGRasterConverted(bool success, const base::FilePath& pwg_file_path); |
200 void SendDataInternal(); | |
201 | 205 |
202 PrivetHTTPClientImpl* privet_client_; | 206 PrivetHTTPClientImpl* privet_client_; |
203 PrivetLocalPrintOperation::Delegate* delegate_; | 207 PrivetLocalPrintOperation::Delegate* delegate_; |
204 | 208 |
205 ResponseCallback current_response_; | 209 ResponseCallback current_response_; |
206 | 210 |
207 std::string ticket_; | 211 std::string ticket_; |
208 std::string data_; | 212 scoped_refptr<base::RefCountedBytes> data_; |
209 base::FilePath data_file_; | 213 base::FilePath pwg_file_path_; |
210 | 214 |
211 bool use_pdf_; | 215 bool use_pdf_; |
212 bool has_capabilities_; | 216 bool has_capabilities_; |
213 bool has_extended_workflow_; | 217 bool has_extended_workflow_; |
214 bool started_; | 218 bool started_; |
215 bool offline_; | 219 bool offline_; |
216 | 220 |
217 std::string user_; | 221 std::string user_; |
218 std::string jobname_; | 222 std::string jobname_; |
219 | 223 |
220 std::string jobid_; | 224 std::string jobid_; |
221 | 225 |
222 int invalid_job_retries_; | 226 int invalid_job_retries_; |
223 | 227 |
224 scoped_ptr<PrivetURLFetcher> url_fetcher_; | 228 scoped_ptr<PrivetURLFetcher> url_fetcher_; |
225 scoped_ptr<PrivetInfoOperation> info_operation_; | 229 scoped_ptr<PrivetInfoOperation> info_operation_; |
| 230 scoped_ptr<PWGRasterConverter> pwg_raster_converter_; |
226 | 231 |
227 base::WeakPtrFactory<PrivetLocalPrintOperationImpl> weak_factory_; | 232 base::WeakPtrFactory<PrivetLocalPrintOperationImpl> weak_factory_; |
228 }; | 233 }; |
229 | 234 |
230 class PrivetHTTPClientImpl : public PrivetHTTPClient, | 235 class PrivetHTTPClientImpl : public PrivetHTTPClient, |
231 public PrivetInfoOperation::Delegate { | 236 public PrivetInfoOperation::Delegate { |
232 public: | 237 public: |
233 PrivetHTTPClientImpl( | 238 PrivetHTTPClientImpl( |
234 const std::string& name, | 239 const std::string& name, |
235 const net::HostPortPair& host_port, | 240 const net::HostPortPair& host_port, |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
275 PrivetURLFetcherFactory fetcher_factory_; | 280 PrivetURLFetcherFactory fetcher_factory_; |
276 net::HostPortPair host_port_; | 281 net::HostPortPair host_port_; |
277 scoped_ptr<base::DictionaryValue> cached_info_; | 282 scoped_ptr<base::DictionaryValue> cached_info_; |
278 | 283 |
279 scoped_ptr<PrivetInfoOperation> info_operation_; | 284 scoped_ptr<PrivetInfoOperation> info_operation_; |
280 TokenCallbackVector token_callbacks_; | 285 TokenCallbackVector token_callbacks_; |
281 }; | 286 }; |
282 | 287 |
283 } // namespace local_discovery | 288 } // namespace local_discovery |
284 #endif // CHROME_BROWSER_LOCAL_DISCOVERY_PRIVET_HTTP_IMPL_H_ | 289 #endif // CHROME_BROWSER_LOCAL_DISCOVERY_PRIVET_HTTP_IMPL_H_ |
OLD | NEW |